Skip to content

Commit

Permalink
fix save error
Browse files Browse the repository at this point in the history
  • Loading branch information
wetor committed Oct 2, 2019
1 parent 6f24e3b commit e8503c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/ScriptHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "Utils.h"
#include "coding2utf16.h"

#include <sys/stat.h>
#include <dirent.h>
extern Coding2UTF16 *coding2utf16;

#define TMP_SCRIPT_BUF_LEN 4096
Expand Down Expand Up @@ -143,6 +145,18 @@ void ScriptHandler::setSaveDir(const char *path)
if (save_dir) delete[] save_dir;
save_dir = new char[ strlen(path)+1 ];
strcpy(save_dir, path);

DIR *dir;
int ret=0;
if ((dir = opendir(save_dir)) == NULL)
{
ret=mkdir(save_dir, 777);
}
else
{
closedir(dir);
}

}

FILE *ScriptHandler::fopen( const char *path, const char *mode, bool use_save_dir )
Expand All @@ -156,7 +170,6 @@ FILE *ScriptHandler::fopen( const char *path, const char *mode, bool use_save_di
for ( unsigned int i=0 ; i<strlen( filename ) ; i++ )
if ( filename[i] == '/' || filename[i] == '\\' )
filename[i] = DELIMITER;

return ::fopen( filename, mode );
}

Expand Down

0 comments on commit e8503c7

Please sign in to comment.