@@ -62,65 +62,65 @@ void InitializeTestCallbacks()
6262// Here you can add non-inline helper function implementations
6363
6464// Example: Helper function to create test directory
65- bool CreateTestDirectory (const std::wstring & path)
65+ bool CreateTestDirectory (const HutaoString & path)
6666{
67- if (CreateDirectoryW (path.c_str (), nullptr ) || GetLastError () == ERROR_ALREADY_EXISTS)
67+ if (CreateDirectoryW (path.Data (), nullptr ) || GetLastError () == ERROR_ALREADY_EXISTS)
6868 {
69- wprintf (L" Created test directory: %s\n " , path.c_str ());
69+ wprintf (L" Created test directory: %s\n " , path.Data ());
7070 return true ;
7171 }
7272 else
7373 {
74- wprintf (L" Failed to create test directory: %s, error code: %d\n " , path.c_str (), GetLastError ());
74+ wprintf (L" Failed to create test directory: %s, error code: %d\n " , path.Data (), GetLastError ());
7575 return false ;
7676 }
7777}
7878
7979// Example: Helper function to delete test file
80- bool DeleteTestFile (const std::wstring & path)
80+ bool DeleteTestFile (const HutaoString & path)
8181{
82- if (DeleteFileW (path.c_str ()) || GetLastError () == ERROR_FILE_NOT_FOUND)
82+ if (DeleteFileW (path.Data ()) || GetLastError () == ERROR_FILE_NOT_FOUND)
8383 {
84- wprintf (L" Deleted test file: %s\n " , path.c_str ());
84+ wprintf (L" Deleted test file: %s\n " , path.Data ());
8585 return true ;
8686 }
8787 else
8888 {
89- wprintf (L" Failed to delete test file: %s, error code: %d\n " , path.c_str (), GetLastError ());
89+ wprintf (L" Failed to delete test file: %s, error code: %d\n " , path.Data (), GetLastError ());
9090 return false ;
9191 }
9292}
9393
9494// Example: Helper function to verify file existence
95- bool VerifyFileExists (const std::wstring & path)
95+ bool VerifyFileExists (const HutaoString & path)
9696{
97- DWORD attributes = GetFileAttributesW (path.c_str ());
97+ DWORD attributes = GetFileAttributesW (path.Data ());
9898 if (attributes != INVALID_FILE_ATTRIBUTES && !(attributes & FILE_ATTRIBUTE_DIRECTORY))
9999 {
100- wprintf (L" File exists: %s\n " , path.c_str ());
100+ wprintf (L" File exists: %s\n " , path.Data ());
101101 return true ;
102102 }
103103 else
104104 {
105- wprintf (L" File does not exist: %s\n " , path.c_str ());
105+ wprintf (L" File does not exist: %s\n " , path.Data ());
106106 return false ;
107107 }
108108}
109109
110110// Example: Helper function to get file size
111- uint64_t GetFileSizeHelper (const std::wstring & path)
111+ uint64_t GetFileSizeHelper (const HutaoString & path)
112112{
113- HANDLE hFile = CreateFileW (path.c_str (), GENERIC_READ, FILE_SHARE_READ, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
113+ HANDLE hFile = CreateFileW (path.Data (), GENERIC_READ, FILE_SHARE_READ, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
114114 if (hFile == INVALID_HANDLE_VALUE)
115115 {
116- wprintf (L" Cannot open file to get size: %s, error code: %d\n " , path.c_str (), GetLastError ());
116+ wprintf (L" Cannot open file to get size: %s, error code: %d\n " , path.Data (), GetLastError ());
117117 return 0 ;
118118 }
119119
120120 LARGE_INTEGER fileSize;
121121 if (!GetFileSizeEx (hFile, &fileSize))
122122 {
123- wprintf (L" Failed to get file size: %s, error code: %d\n " , path.c_str (), GetLastError ());
123+ wprintf (L" Failed to get file size: %s, error code: %d\n " , path.Data (), GetLastError ());
124124 CloseHandle (hFile);
125125 return 0 ;
126126 }
0 commit comments