mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-12 23:54:17 +00:00
fixed: for deleting files and folders on Windows we have to call the Unicode variants of these functions.
This commit is contained in:
parent
3318e540b6
commit
81dade9ed5
6 changed files with 32 additions and 16 deletions
|
@ -84,7 +84,7 @@ int FSavegameManagerBase::RemoveSaveSlot(int index)
|
|||
int listindex = SaveGames[0]->bNoDelete ? index - 1 : index;
|
||||
if (listindex < 0) return index;
|
||||
|
||||
remove(SaveGames[index]->Filename.GetChars());
|
||||
RemoveFile(SaveGames[index]->Filename.GetChars());
|
||||
UnloadSaveData();
|
||||
|
||||
FSaveGameNode *file = SaveGames[index];
|
||||
|
@ -274,7 +274,7 @@ DEFINE_ACTION_FUNCTION(FSavegameManager, DoSave)
|
|||
|
||||
unsigned FSavegameManagerBase::ExtractSaveData(int index)
|
||||
{
|
||||
FResourceFile *resf;
|
||||
std::unique_ptr<FResourceFile> resf;
|
||||
FSaveGameNode *node;
|
||||
|
||||
if (index == -1)
|
||||
|
@ -295,7 +295,7 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
|
|||
(node = SaveGames[index]) &&
|
||||
!node->Filename.IsEmpty() &&
|
||||
!node->bOldVersion &&
|
||||
(resf = FResourceFile::OpenResourceFile(node->Filename.GetChars(), true)) != nullptr)
|
||||
( (resf.reset(FResourceFile::OpenResourceFile(node->Filename.GetChars(), true))), resf != nullptr))
|
||||
{
|
||||
auto info = resf->FindEntry("info.json");
|
||||
if (info < 0)
|
||||
|
@ -329,7 +329,6 @@ unsigned FSavegameManagerBase::ExtractSaveData(int index)
|
|||
}
|
||||
}
|
||||
}
|
||||
delete resf;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
|
|
@ -593,6 +593,26 @@ void CreatePath(const char *fn)
|
|||
}
|
||||
#endif
|
||||
|
||||
void RemoveFile(const char* file)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
remove(file);
|
||||
#else
|
||||
auto wpath = WideString(file);
|
||||
_wremove(wpath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
int RemoveDir(const char* file)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return rmdir(file);
|
||||
#else
|
||||
auto wpath = WideString(file);
|
||||
return _wrmdir(wpath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// strbin -- In-place version
|
||||
|
|
|
@ -71,6 +71,8 @@ int strbin (char *str);
|
|||
FString strbin1 (const char *start);
|
||||
|
||||
void CreatePath(const char * fn);
|
||||
void RemoveFile(const char* file);
|
||||
int RemoveDir(const char* file);
|
||||
|
||||
FString ExpandEnvVars(const char *searchpathstring);
|
||||
FString NicePath(const char *path);
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "m_swap.h"
|
||||
#include "w_zip.h"
|
||||
#include "fs_decompress.h"
|
||||
#include "cmdlib.h"
|
||||
|
||||
using FileSys::FCompressedBuffer;
|
||||
|
||||
|
@ -201,7 +202,7 @@ bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t con
|
|||
if (pos == -1)
|
||||
{
|
||||
delete f;
|
||||
remove(filename);
|
||||
RemoveFile(filename);
|
||||
return false;
|
||||
}
|
||||
positions.Push(pos);
|
||||
|
@ -213,7 +214,7 @@ bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t con
|
|||
if (AppendCentralDirectory(f, content[i], dostime, positions[i]) < 0)
|
||||
{
|
||||
delete f;
|
||||
remove(filename);
|
||||
RemoveFile(filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t con
|
|||
if (f->Write(&dirend, sizeof(dirend)) != sizeof(dirend))
|
||||
{
|
||||
delete f;
|
||||
remove(filename);
|
||||
RemoveFile(filename);
|
||||
return false;
|
||||
}
|
||||
delete f;
|
||||
|
|
|
@ -3079,7 +3079,7 @@ bool G_CheckDemoStatus (void)
|
|||
const size_t size = demo_p - demobuffer;
|
||||
saved = fw->Write(demobuffer, size) == size;
|
||||
delete fw;
|
||||
if (!saved) remove(demoname.GetChars());
|
||||
if (!saved) RemoveFile(demoname.GetChars());
|
||||
}
|
||||
M_Free (demobuffer);
|
||||
demorecording = false;
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
|
||||
#else
|
||||
#include <direct.h>
|
||||
|
||||
#define rmdir _rmdir
|
||||
|
||||
#endif
|
||||
|
||||
#include <miniz.h>
|
||||
|
@ -1215,11 +1209,11 @@ UNSAFE_CCMD(clearnodecache)
|
|||
{
|
||||
if (list[i].isDirectory)
|
||||
{
|
||||
rmdir(list[i].FilePath.c_str());
|
||||
RemoveDir(list[i].FilePath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
remove(list[i].FilePath.c_str());
|
||||
RemoveFile(list[i].FilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue