| 1916 | } |
| 1917 | |
| 1918 | bool FileSystem::DeleteFilePath(const char* path, Error* error) |
| 1919 | { |
| 1920 | if (path[0] == '\0') |
| 1921 | { |
| 1922 | Error::SetStringView(error, "Path is empty."); |
| 1923 | return false; |
| 1924 | } |
| 1925 | |
| 1926 | const std::wstring wpath = GetWin32Path(path); |
| 1927 | const DWORD fileAttributes = GetFileAttributesW(wpath.c_str()); |
| 1928 | if (fileAttributes == INVALID_FILE_ATTRIBUTES || fileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 1929 | { |
| 1930 | Error::SetStringView(error, "File does not exist."); |
| 1931 | return false; |
| 1932 | } |
| 1933 | |
| 1934 | if (!DeleteFileW(wpath.c_str())) |
| 1935 | { |
| 1936 | Error::SetWin32(error, "DeleteFileW() failed: ", GetLastError()); |
| 1937 | return false; |
| 1938 | } |
| 1939 | |
| 1940 | return true; |
| 1941 | } |
| 1942 | |
| 1943 | bool FileSystem::RenamePath(const char* old_path, const char* new_path, Error* error) |
| 1944 | { |
nothing calls this directly
no test coverage detected