-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from CommitteeOfZero/quicksaving
Quicksaving + More robust files API
- Loading branch information
Showing
18 changed files
with
387 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "filemeta.h" | ||
#include "../log.h" | ||
#include <system_error> | ||
|
||
namespace Impacto { | ||
namespace Io { | ||
|
||
int64_t GetFileSize(std::string const& path) { | ||
std::error_code ec; | ||
uintmax_t result = std::filesystem::file_size(path, ec); | ||
if (ec) { | ||
ImpLog(LL_Error, LC_IO, | ||
"Error getting file size of file \"%s\", error: \"%s\"\n", | ||
path.c_str(), ec.message().c_str()); | ||
return IoError_Fail; | ||
} | ||
// Hopefully no one has a file of size between int64_t max and uint64_t max | ||
return static_cast<int64_t>(result); | ||
} | ||
|
||
IoError PathExists(std::string const& path) { | ||
std::error_code ec; | ||
bool result = std::filesystem::exists(path, ec); | ||
if (ec) { | ||
ImpLog(LL_Error, LC_IO, | ||
"Error checking for file existence for file \"%s\", error: \"%s\"\n", | ||
path.c_str(), ec.message().c_str()); | ||
return IoError_Fail; | ||
} | ||
return result == false ? IoError_NotFound : IoError_OK; | ||
} | ||
|
||
int8_t CreateDirectories(std::string const& path) { | ||
std::error_code ec; | ||
bool result = std::filesystem::create_directories(path, ec); | ||
if (ec) { | ||
ImpLog(LL_Error, LC_IO, | ||
"Error creating directories for file \"%s\", error: \"%s\"\n", | ||
path.c_str(), ec.message().c_str()); | ||
return IoError_Fail; | ||
} | ||
return result; | ||
} | ||
|
||
IoError GetFilePermissions(std::string const& path, | ||
FilePermissionsFlags& flags) { | ||
std::error_code ec; | ||
flags = std::filesystem::status(path, ec).permissions(); | ||
if (ec) { | ||
ImpLog(LL_Error, LC_IO, | ||
"Error retrieving permissions for file \"%s\", error: \"%s\"\n", | ||
path.c_str(), ec.message().c_str()); | ||
return IoError_Fail; | ||
} | ||
return IoError_OK; | ||
} | ||
|
||
} // namespace Io | ||
} // namespace Impacto |
Oops, something went wrong.