diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 25 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.h | 5 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 15 |
3 files changed, 27 insertions, 18 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 8b097ad25e..1e55e39e31 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -66,7 +66,7 @@ bool DirAccessUnix::file_exists(String p_file) { if (p_file.is_rel_path()) - p_file=current_dir+"/"+p_file; + p_file=current_dir.plus_file(p_file); else p_file=fix_path(p_file); @@ -104,7 +104,7 @@ bool DirAccessUnix::dir_exists(String p_dir) { uint64_t DirAccessUnix::get_modified_time(String p_file) { if (p_file.is_rel_path()) - p_file=current_dir+"/"+p_file; + p_file=current_dir.plus_file(p_file); else p_file=fix_path(p_file); @@ -138,11 +138,9 @@ String DirAccessUnix::get_next() { //typedef struct stat Stat; struct stat flags; - String fname; - if (fname.parse_utf8(entry->d_name)) - fname=entry->d_name; //no utf8, maybe latin? + String fname = fix_unicode_name(entry->d_name); - String f=current_dir+"/"+fname; + String f=current_dir.plus_file(fname); if (stat(f.utf8().get_data(),&flags)==0) { @@ -201,8 +199,17 @@ Error DirAccessUnix::make_dir(String p_dir) { GLOBAL_LOCK_FUNCTION - p_dir=fix_path(p_dir); - + if (p_dir.is_rel_path()) + p_dir=get_current_dir().plus_file(p_dir); + else + p_dir=fix_path(p_dir); +#if 1 + + + bool success=(mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)==0); + int err = errno; + +#else char real_current_dir_name[2048]; getcwd(real_current_dir_name,2048); chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants @@ -211,7 +218,7 @@ Error DirAccessUnix::make_dir(String p_dir) { int err = errno; chdir(real_current_dir_name); - +#endif if (success) { return OK; }; diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 9cba1ed3e0..b2f1aed10f 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -51,7 +51,10 @@ class DirAccessUnix : public DirAccess { String current_dir; bool _cisdir; bool _cishidden; - +protected: + + virtual String fix_unicode_name(const char* p_name) const { return String::utf8(p_name); } + public: virtual bool list_dir_begin(); ///< This starts dir listing diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 913ba1eb2b..f64eb036c3 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -191,23 +191,21 @@ Error DirAccessWindows::make_dir(String p_dir) { #else - p_dir=fix_path(p_dir); - + if (p_dir.is_rel_path()) + p_dir=get_current_dir().plus_file(p_dir); + else + p_dir=fix_path(p_dir); //p_dir.replace("/","\\"); bool success; int err; - wchar_t real_current_dir_name[2048]; - GetCurrentDirectoryW(2048,real_current_dir_name); - - SetCurrentDirectoryW(current_dir.c_str()); + p_dir="\\\\?\\"+p_dir; //done according to +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx success=CreateDirectoryW(p_dir.c_str(), NULL); err = GetLastError(); - SetCurrentDirectoryW(real_current_dir_name); - if (success) { return OK; }; @@ -315,6 +313,7 @@ Error DirAccessWindows::remove(String p_path) { else p_path=fix_path(p_path); + printf("erasing %s\n",p_path.utf8().get_data()); //WIN32_FILE_ATTRIBUTE_DATA fileInfo; //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); |