1
0
Fork 0

Codechange: use std::string for FiosIsRoot

pull/10896/head
Rubidium 2023-05-30 22:37:33 +02:00 committed by rubidium42
parent 13789d1703
commit f2e704b9a7
4 changed files with 8 additions and 8 deletions

View File

@ -35,7 +35,7 @@ static std::string *_fios_path = nullptr;
SortingBits _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; SortingBits _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
/* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */ /* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */
extern bool FiosIsRoot(const char *path); extern bool FiosIsRoot(const std::string &path);
extern bool FiosIsValidFile(const std::string &path, const struct dirent *ent, struct stat *sb); extern bool FiosIsValidFile(const std::string &path, const struct dirent *ent, struct stat *sb);
extern bool FiosIsHiddenFile(const struct dirent *ent); extern bool FiosIsHiddenFile(const struct dirent *ent);
extern void FiosGetDrives(FileList &file_list); extern void FiosGetDrives(FileList &file_list);
@ -366,7 +366,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
assert(_fios_path != nullptr); assert(_fios_path != nullptr);
/* A parent directory link exists if we are not in the root directory */ /* A parent directory link exists if we are not in the root directory */
if (!FiosIsRoot(_fios_path->c_str())) { if (!FiosIsRoot(*_fios_path)) {
fios = &file_list.emplace_back(); fios = &file_list.emplace_back();
fios->type = FIOS_TYPE_PARENT; fios->type = FIOS_TYPE_PARENT;
fios->mtime = 0; fios->mtime = 0;

View File

@ -36,9 +36,9 @@
# include <i86.h> # include <i86.h>
#endif #endif
bool FiosIsRoot(const char *file) bool FiosIsRoot(const std::string &file)
{ {
return file[3] == '\0'; return file.size() == 3; // C:\...
} }
void FiosGetDrives(FileList &file_list) void FiosGetDrives(FileList &file_list)

View File

@ -57,9 +57,9 @@
#include "../../safeguards.h" #include "../../safeguards.h"
bool FiosIsRoot(const char *path) bool FiosIsRoot(const std::string &path)
{ {
return path[1] == '\0'; return path == PATHSEP;
} }
void FiosGetDrives(FileList &file_list) void FiosGetDrives(FileList &file_list)

View File

@ -168,9 +168,9 @@ int closedir(DIR *d)
return 0; return 0;
} }
bool FiosIsRoot(const char *file) bool FiosIsRoot(const std::string &file)
{ {
return file[3] == '\0'; // C:\... return file.size() == 3; // C:\...
} }
void FiosGetDrives(FileList &file_list) void FiosGetDrives(FileList &file_list)