Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_A11y/accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
char docsFontsDir[TFE_MAX_PATH];
const char* docsDir = TFE_Paths::getPath(PATH_USER_DOCUMENTS);
sprintf(docsFontsDir, "%sFonts/", docsDir);
if (!FileUtil::directoryExits(docsFontsDir))
if (!FileUtil::directoryExists(docsFontsDir))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. :)

{
FileUtil::makeDirectory(docsFontsDir);
}
Expand Down Expand Up @@ -278,7 +278,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
char docsCaptionsDir[TFE_MAX_PATH];
const char* docsDir = TFE_Paths::getPath(PATH_USER_DOCUMENTS);
sprintf(docsCaptionsDir, "%sCaptions/", docsDir);
if (!FileUtil::directoryExits(docsCaptionsDir))
if (!FileUtil::directoryExists(docsCaptionsDir))
{
FileUtil::makeDirectory(docsCaptionsDir);
}
Expand Down
6 changes: 3 additions & 3 deletions TheForceEngine/TFE_Editor/AssetBrowser/assetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ namespace AssetBrowser

void exportSelected()
{
if (!FileUtil::directoryExits(s_editorConfig.exportPath))
if (!FileUtil::directoryExists(s_editorConfig.exportPath))
{
showMessageBox("ERROR", getErrorMsg(ERROR_INVALID_EXPORT_PATH), s_editorConfig.exportPath);
return;
Expand Down Expand Up @@ -2115,7 +2115,7 @@ namespace AssetBrowser

char subDir[TFE_MAX_PATH];
sprintf(subDir, "%s%s", path, assetSubPath[asset->type]);
if (!FileUtil::directoryExits(subDir))
if (!FileUtil::directoryExists(subDir))
{
FileUtil::makeDirectory(subDir);
}
Expand Down Expand Up @@ -2236,7 +2236,7 @@ namespace AssetBrowser

void importSelected()
{
if (!FileUtil::directoryExits(s_editorConfig.editorPath))
if (!FileUtil::directoryExists(s_editorConfig.editorPath))
{
showMessageBox("ERROR", getErrorMsg(ERROR_INVALID_EXPORT_PATH), s_editorConfig.editorPath);
return;
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_Editor/LevelEditor/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ namespace LevelEditor
else
{
// Save the custom templates to the editor export path, if it exists.
if (FileUtil::directoryExits(s_editorConfig.exportPath))
if (FileUtil::directoryExists(s_editorConfig.exportPath))
{
char path[TFE_MAX_PATH];
strcpy(path, s_editorConfig.exportPath);
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Editor/LevelEditor/levelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3149,13 +3149,13 @@ namespace LevelEditor

char autosaveDir[TFE_MAX_PATH];
sprintf(autosaveDir, "%s/Autosaves/", project->path);
if (!FileUtil::directoryExits(autosaveDir))
if (!FileUtil::directoryExists(autosaveDir))
{
FileUtil::makeDirectory(autosaveDir);
}
strcat(autosaveDir, s_level.slot.c_str());
strcat(autosaveDir, "/");
if (!FileUtil::directoryExits(autosaveDir))
if (!FileUtil::directoryExists(autosaveDir))
{
FileUtil::makeDirectory(autosaveDir);
}
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Editor/LevelEditor/snapshotUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ namespace LevelEditor
if (!project->active) { return; }

sprintf(s_snapshotDir, "%s/Snapshots/", project->path);
if (!FileUtil::directoryExits(s_snapshotDir))
if (!FileUtil::directoryExists(s_snapshotDir))
{
FileUtil::makeDirectory(s_snapshotDir);
}
strcat(s_snapshotDir, s_level.slot.c_str());
strcat(s_snapshotDir, "/");
if (!FileUtil::directoryExits(s_snapshotDir))
if (!FileUtil::directoryExists(s_snapshotDir))
{
FileUtil::makeDirectory(s_snapshotDir);
}
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_Editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ namespace TFE_Editor
{
sprintf(tmpDir, "%s/Temp", s_editorConfig.editorPath);
FileUtil::fixupPath(tmpDir);
if (!FileUtil::directoryExits(tmpDir))
if (!FileUtil::directoryExists(tmpDir))
{
FileUtil::makeDirectory(tmpDir);
}
Expand Down
8 changes: 4 additions & 4 deletions TheForceEngine/TFE_Editor/editorProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ namespace TFE_Editor
}

// Validate that the path exists.
if (!FileUtil::directoryExits(s_curProject.path))
if (!FileUtil::directoryExists(s_curProject.path))
{
// Replace it with the current path.
FileUtil::getFilePath(filepath, s_curProject.path);

if (!FileUtil::directoryExits(s_curProject.path))
if (!FileUtil::directoryExists(s_curProject.path))
{
TFE_System::logWrite(LOG_ERROR, "Editor Project", "Editor Project Path '%s' does not exist.", s_curProject.path);
removeFromRecents(s_curProject.path);
Expand Down Expand Up @@ -387,14 +387,14 @@ namespace TFE_Editor
sprintf(s_curProject.path, "%s/%s", s_curProject.path, s_curProject.name);
FileUtil::fixupPath(s_curProject.path);

if (!FileUtil::directoryExits(s_curProject.path))
if (!FileUtil::directoryExists(s_curProject.path))
{
FileUtil::makeDirectory(s_curProject.path);
}
}
else if (newProject)
{
if (!FileUtil::directoryExits(s_curProject.path))
if (!FileUtil::directoryExists(s_curProject.path))
{
// TODO: Show message box.
TFE_System::logWrite(LOG_ERROR, "Editor Project", "Editor Project Path '%s' does not exist, creation failed.", s_curProject.path);
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_FileSystem/fileutil-posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace FileUtil
}
}

bool directoryExits(const char *path, char *outPath)
bool directoryExists(const char *path, char *outPath)
{
char *ret;

Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_FileSystem/fileutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace FileUtil
DeleteFile(srcFile);
}

bool directoryExits(const char* path, char* outPath)
bool directoryExists(const char* path, char* outPath)
{
DWORD attr = GetFileAttributesA(path);
if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) { return false; }
Expand All @@ -230,7 +230,7 @@ namespace FileUtil

bool exists( const char *path )
{
return !(GetFileAttributesA(path)==INVALID_FILE_ATTRIBUTES && GetLastError()==ERROR_FILE_NOT_FOUND);
return !(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_SUCCESS);
}

u64 getModifiedTime( const char* path )
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_FileSystem/fileutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace FileUtil
void deleteFile(const char* srcFile);

bool exists(const char* path);
bool directoryExits(const char* path, char* outPath = nullptr);
bool directoryExists(const char* path, char* outPath = nullptr);
u64 getModifiedTime(const char* path);

void fixupPath(char* path);
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_FileSystem/paths-posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace TFE_Paths
{
char workpath[TFE_MAX_PATH];

if (!FileUtil::directoryExits(fullPath, workpath))
if (!FileUtil::directoryExists(fullPath, workpath))
return;

for (auto it = s_searchPaths.begin(); it != s_searchPaths.end(); it++)
Expand All @@ -268,7 +268,7 @@ namespace TFE_Paths
{
char workpath[TFE_MAX_PATH];

if (!FileUtil::directoryExits(fullPath, workpath))
if (!FileUtil::directoryExists(fullPath, workpath))
return;

for (auto it = s_searchPaths.begin(); it != s_searchPaths.end(); it++)
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_FileSystem/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace TFE_Paths

void addSearchPath(const char* fullPath)
{
if (FileUtil::directoryExits(fullPath))
if (FileUtil::directoryExists(fullPath))
{
const size_t count = s_searchPaths.size();
const std::string* path = s_searchPaths.data();
Expand All @@ -234,7 +234,7 @@ namespace TFE_Paths

void addSearchPathToHead(const char* fullPath)
{
if (FileUtil::directoryExits(fullPath))
if (FileUtil::directoryExists(fullPath))
{
const size_t count = s_searchPaths.size();
const std::string* path = s_searchPaths.data();
Expand Down
8 changes: 4 additions & 4 deletions TheForceEngine/TFE_FrontEndUI/modLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace TFE_FrontEndUI
void createModDirIfNeeded(char * directory)
{
TFE_Paths::fixupPathAsDirectory(directory);
if (!FileUtil::directoryExits(directory))
if (!FileUtil::directoryExists(directory))
{
FileUtil::makeDirectory(directory);
}
Expand Down Expand Up @@ -136,17 +136,17 @@ namespace TFE_FrontEndUI

s32 modPathCount = 0;
char modPaths[3][TFE_MAX_PATH];
if (FileUtil::directoryExits(sourceDataModDir))
if (FileUtil::directoryExists(sourceDataModDir))
{
strcpy(modPaths[modPathCount], sourceDataModDir);
modPathCount++;
}
if (FileUtil::directoryExits(programDataModDir))
if (FileUtil::directoryExists(programDataModDir))
{
strcpy(modPaths[modPathCount], programDataModDir);
modPathCount++;
}
if (FileUtil::directoryExits(programDirModDir))
if (FileUtil::directoryExists(programDirModDir))
{
strcpy(modPaths[modPathCount], programDirModDir);
modPathCount++;
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Game/saveSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ namespace TFE_SaveSystem
{
char relativeBasePath[TFE_MAX_PATH];
TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "Saves/", relativeBasePath);
if (!FileUtil::directoryExits(s_gameSavePath))
if (!FileUtil::directoryExists(s_gameSavePath))
{
FileUtil::makeDirectory(relativeBasePath);
}
Expand All @@ -341,7 +341,7 @@ namespace TFE_SaveSystem
sprintf(relativePath, "Saves/%s/", TFE_Settings::c_gameName[id]);

TFE_Paths::appendPath(PATH_USER_DOCUMENTS, relativePath, s_gameSavePath);
if (!FileUtil::directoryExits(s_gameSavePath))
if (!FileUtil::directoryExists(s_gameSavePath))
{
FileUtil::makeDirectory(s_gameSavePath);
}
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Input/replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ namespace TFE_Input
TFE_Paths::fixupPathAsDirectory(s_replayDir);

// Check TFE/Replays first
if (!FileUtil::directoryExits(s_replayDir))
if (!FileUtil::directoryExists(s_replayDir))
{
sprintf(s_replayDir, "%sReplays/", TFE_Paths::getPath(PATH_USER_DOCUMENTS));
TFE_Paths::fixupPathAsDirectory(s_replayDir);
// Otherwise check <USER>/TheForceEngine/Replays
if (!FileUtil::directoryExits(s_replayDir))
if (!FileUtil::directoryExists(s_replayDir))
{
FileUtil::makeDirectory(s_replayDir);
}
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ namespace TFE_Settings
const char* const * locations = c_gameLocations[gameId];
for (u32 i = 0; i < c_hardcodedPathCount[gameId]; i++)
{
if (FileUtil::directoryExits(locations[i]))
if (FileUtil::directoryExists(locations[i]))
{
strcpy(s_gameSettings.header[gameId].sourcePath, locations[i]);
pathValid = true;
Expand Down Expand Up @@ -1313,7 +1313,7 @@ namespace TFE_Settings

bool validatePath(const char* path, const char* sentinel)
{
if (!FileUtil::directoryExits(path)) { return false; }
if (!FileUtil::directoryExists(path)) { return false; }

char sentinelPath[TFE_MAX_PATH];
sprintf(sentinelPath, "%s%s", path, sentinel);
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,15 @@ int main(int argc, char* argv[])
// Create a screenshot directory
char screenshotDir[TFE_MAX_PATH];
TFE_Paths::appendPath(TFE_PathType::PATH_USER_DOCUMENTS, "Screenshots/", screenshotDir);
if (!FileUtil::directoryExits(screenshotDir))
if (!FileUtil::directoryExists(screenshotDir))
{
FileUtil::makeDirectory(screenshotDir);
}

// Create a mods temporary directory.
char tempPath[TFE_MAX_PATH];
sprintf(tempPath, "%sTemp/", TFE_Paths::getPath(PATH_PROGRAM_DATA));
if (!FileUtil::directoryExits(tempPath))
if (!FileUtil::directoryExists(tempPath))
{
FileUtil::makeDirectory(tempPath);
}
Expand Down