Skip to content

Commit

Permalink
Linux, xrCore: now directory creates without change of (const char *)…
Browse files Browse the repository at this point in the history
… arg
  • Loading branch information
eagleivg committed Nov 9, 2018
1 parent af2dab6 commit 8dea7d2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,7 @@ inline int _filelength(int fd)
#define _read read
#define _set_new_handler std::set_new_handler
#define _finite isfinite
inline int _mkdir(const char *dir)
{
while (char* sep = strchr((char *)dir, '\\')) *sep = '/';
return mkdir(dir, S_IRWXU);
}
inline int _mkdir(const char *dir) { return mkdir(dir, S_IRWXU); }

#define _wtoi(arg) wcstol(arg, NULL, 10)
#define _wtoi64(arg) wcstoll(arg, NULL, 10)
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void VerifyPath(pcstr path)
continue;
CopyMemory(tmp, path, i);
tmp[i] = 0;
convert_path_separators(tmp);
_mkdir(tmp);
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/xrCore/FS_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ class CFileWriter : public IWriter
R_ASSERT(name && name[0]);
fName = name;
VerifyPath(fName.c_str());
pstr conv_fn = xr_strdup(name);
convert_path_separators(conv_fn);
if (exclusive)
{
int handle = _sopen(fName.c_str(), _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR);
int handle = _sopen(conv_fn, _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR);
#ifdef _EDITOR
if (handle == -1)
Msg("!Can't create file: '%s'. Error: '%s'.", *fName, _sys_errlist[errno]);
Msg("!Can't create file: '%s'. Error: '%s'.", conv_fn, _sys_errlist[errno]);
#endif
hf = _fdopen(handle, "wb");
}
else
{
hf = fopen(fName.c_str(), "wb");
hf = fopen(conv_fn, "wb");
if (hf == 0)
Msg("!Can't write file: '%s'. Error: '%s'.", fName.c_str(), _sys_errlist[errno]);
Msg("!Can't write file: '%s'. Error: '%s'.", conv_fn, _sys_errlist[errno]);
}
xr_free(conv_fn);
}

virtual ~CFileWriter()
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,9 +1696,9 @@ void CLocatorAPI::file_rename(pcstr src, pcstr dest, bool overwrite)
m_files.insert(new_desc);

// physically rename file
VerifyPath(dest);
pstr conv_dest = xr_strdup(dest);
convert_path_separators(conv_dest);
VerifyPath(conv_dest);
rename(src, conv_dest);
xr_free(conv_dest);
}
Expand Down
1 change: 0 additions & 1 deletion src/xrCore/LocatorAPI_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ FS_Path::FS_Path(LPCSTR _Root, LPCSTR _Add, LPCSTR _DefExt, LPCSTR _FilterCaptio
m_Flags.assign(flags);
#ifdef _EDITOR
// Editor(s)/User(s) wants pathes already created in "real" file system :)
convert_path_separators(m_Path);
VerifyPath(m_Path);
#endif
}
Expand Down

0 comments on commit 8dea7d2

Please sign in to comment.