Skip to content

Commit 8dea7d2

Browse files
committed
Linux, xrCore: now directory creates without change of (const char *) arg
1 parent af2dab6 commit 8dea7d2

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

src/Common/PlatformLinux.inl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,7 @@ inline int _filelength(int fd)
438438
#define _read read
439439
#define _set_new_handler std::set_new_handler
440440
#define _finite isfinite
441-
inline int _mkdir(const char *dir)
442-
{
443-
while (char* sep = strchr((char *)dir, '\\')) *sep = '/';
444-
return mkdir(dir, S_IRWXU);
445-
}
441+
inline int _mkdir(const char *dir) { return mkdir(dir, S_IRWXU); }
446442

447443
#define _wtoi(arg) wcstol(arg, NULL, 10)
448444
#define _wtoi64(arg) wcstoll(arg, NULL, 10)

src/xrCore/FS.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void VerifyPath(pcstr path)
8686
continue;
8787
CopyMemory(tmp, path, i);
8888
tmp[i] = 0;
89+
convert_path_separators(tmp);
8990
_mkdir(tmp);
9091
}
9192
}

src/xrCore/FS_internal.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@ class CFileWriter : public IWriter
2727
R_ASSERT(name && name[0]);
2828
fName = name;
2929
VerifyPath(fName.c_str());
30+
pstr conv_fn = xr_strdup(name);
31+
convert_path_separators(conv_fn);
3032
if (exclusive)
3133
{
32-
int handle = _sopen(fName.c_str(), _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR);
34+
int handle = _sopen(conv_fn, _O_WRONLY | _O_TRUNC | _O_CREAT | _O_BINARY, SH_DENYWR);
3335
#ifdef _EDITOR
3436
if (handle == -1)
35-
Msg("!Can't create file: '%s'. Error: '%s'.", *fName, _sys_errlist[errno]);
37+
Msg("!Can't create file: '%s'. Error: '%s'.", conv_fn, _sys_errlist[errno]);
3638
#endif
3739
hf = _fdopen(handle, "wb");
3840
}
3941
else
4042
{
41-
hf = fopen(fName.c_str(), "wb");
43+
hf = fopen(conv_fn, "wb");
4244
if (hf == 0)
43-
Msg("!Can't write file: '%s'. Error: '%s'.", fName.c_str(), _sys_errlist[errno]);
45+
Msg("!Can't write file: '%s'. Error: '%s'.", conv_fn, _sys_errlist[errno]);
4446
}
47+
xr_free(conv_fn);
4548
}
4649

4750
virtual ~CFileWriter()

src/xrCore/LocatorAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,9 +1696,9 @@ void CLocatorAPI::file_rename(pcstr src, pcstr dest, bool overwrite)
16961696
m_files.insert(new_desc);
16971697

16981698
// physically rename file
1699+
VerifyPath(dest);
16991700
pstr conv_dest = xr_strdup(dest);
17001701
convert_path_separators(conv_dest);
1701-
VerifyPath(conv_dest);
17021702
rename(src, conv_dest);
17031703
xr_free(conv_dest);
17041704
}

src/xrCore/LocatorAPI_defs.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ FS_Path::FS_Path(LPCSTR _Root, LPCSTR _Add, LPCSTR _DefExt, LPCSTR _FilterCaptio
5252
m_Flags.assign(flags);
5353
#ifdef _EDITOR
5454
// Editor(s)/User(s) wants pathes already created in "real" file system :)
55-
convert_path_separators(m_Path);
5655
VerifyPath(m_Path);
5756
#endif
5857
}

0 commit comments

Comments
 (0)