mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-03-10 18:21:42 +00:00
Implement FileOps::touch() and FileOps::removeFile() for Win32
This commit is contained in:
parent
6418b44924
commit
f8d7cb3b4a
1 changed files with 21 additions and 2 deletions
|
@ -173,7 +173,13 @@ void FileOps::removeFile(const char* src) throw (IOException)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
throw IOException("not implemented");
|
if (!DeleteFile(src))
|
||||||
|
{
|
||||||
|
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
throw IOException("Unable to remove file " + std::string(src));
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +221,20 @@ void FileOps::touch(const char* path) throw (IOException)
|
||||||
throw IOException("Unable to touch file " + std::string(path));
|
throw IOException("Unable to touch file " + std::string(path));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
throw IOException("not implemented");
|
HANDLE result = CreateFile(path,GENERIC_WRITE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
|
0,
|
||||||
|
CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0);
|
||||||
|
if (result == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
throw IOException("Unable to touch file " + std::string(path));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CloseHandle(result);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue