Skip to content

Commit

Permalink
create parent directory if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdy committed Sep 1, 2021
1 parent c51b6cd commit 1bc969d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions binfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ struct FileUtils {
*/
static FILE* OpenBinaryFile(const std::string& FilePath, bool Create = false, uint32_t offset = 0) {
FILE* r = nullptr;
auto filePath = Fs::path(FilePath);
if(!Fs::exists(filePath.parent_path())) {
Fs::create_directories(filePath.parent_path());
}
if (Fs::exists(FilePath) || Create) {
r = std::fopen(FilePath.c_str(), Create ? "wbe" : "r+be");
if (fseek(r, offset, SEEK_SET) != 0) {
Expand Down

0 comments on commit 1bc969d

Please sign in to comment.