MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DeleteFilePath

Method DeleteFilePath

common/FileSystem.cpp:1918–1941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1916}
1917
1918bool 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
1943bool FileSystem::RenamePath(const char* old_path, const char* new_path, Error* error)
1944{

Callers

nothing calls this directly

Calls 4

GetFileAttributesWFunction · 0.85
GetLastErrorFunction · 0.85
statClass · 0.70
c_strMethod · 0.45

Tested by

no test coverage detected