early-access version 1666

This commit is contained in:
pineappleEA
2021-05-08 21:25:29 +02:00
parent d948f410cd
commit 5e268d25d7
4 changed files with 34 additions and 8 deletions

View File

@@ -93,9 +93,23 @@ VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
// Current usages of CreateFile expect to delete the contents of an existing file.
if (FS::IsFile(path)) {
FS::IOFile temp{path, FS::FileAccessMode::Write, FS::FileType::BinaryFile};
if (!temp.IsOpen()) {
return nullptr;
}
temp.Close();
return OpenFile(path, perms);
}
if (!FS::NewFile(path)) {
return nullptr;
}
return OpenFile(path, perms);
}