mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-28 06:32:26 +00:00
added windows implementation of sys_removedir and used snprintf in the unix one
This commit is contained in:
parent
867046bb8b
commit
d82708b448
2 changed files with 32 additions and 1 deletions
|
@ -504,7 +504,7 @@ Sys_RemoveDir(const char *path)
|
||||||
{
|
{
|
||||||
while ((file = readdir(directory)) != NULL)
|
while ((file = readdir(directory)) != NULL)
|
||||||
{
|
{
|
||||||
sprintf(filepath, "%s/%s", path, file->d_name);
|
snprintf(filepath, MAX_OSPATH, "%s/%s", path, file->d_name);
|
||||||
Sys_Remove(filepath);
|
Sys_Remove(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,6 +556,37 @@ Sys_Rename(const char *from, const char *to)
|
||||||
return _wrename(wfrom, wto);
|
return _wrename(wfrom, wto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Sys_RemoveDir(const char *path)
|
||||||
|
{
|
||||||
|
WCHAR wpath[MAX_OSPATH] = {0};
|
||||||
|
WCHAR wpathwithwildcard[MAX_OSPATH] = {0};
|
||||||
|
WCHAR wpathwithfilename[MAX_OSPATH] = {0};
|
||||||
|
WIN32_FIND_DATAW fd;
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_OSPATH);
|
||||||
|
|
||||||
|
wcscat_s(wpathwithwildcard, MAX_OSPATH, wpath);
|
||||||
|
wcscat_s(wpathwithwildcard, MAX_OSPATH, L"\\*.*");
|
||||||
|
|
||||||
|
HANDLE hFind = FindFirstFileW(wpathwithwildcard, &fd);
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
wmemset(wpathwithfilename, 0, MAX_OSPATH);
|
||||||
|
wcscat_s(wpathwithfilename, MAX_OSPATH, wpath);
|
||||||
|
wcscat_s(wpathwithfilename, MAX_OSPATH, fd.cFileName);
|
||||||
|
|
||||||
|
DeleteFileW(wpathwithfilename);
|
||||||
|
}
|
||||||
|
while (FindNextFileW(hFind, &fd));
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveDirectoryW(wpath);
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================================================================= */
|
/* ======================================================================= */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
|
Loading…
Reference in a new issue