Skip to content

Commit 8f0a17d

Browse files
committed
xrCore: fix locating fs patches
1 parent ac669b5 commit 8f0a17d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/xrCore/FS.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ bool file_handle_internal(LPCSTR file_name, u32& size, int& hFile)
108108
#else // EDITOR
109109
static int open_internal(LPCSTR fn, int& handle)
110110
{
111+
#if defined(WINDOWS)
111112
return (_sopen_s(&handle, fn, _O_RDONLY | _O_BINARY, _SH_DENYNO, _S_IREAD));
113+
#elif defined(LINUX)
114+
handle = open(fn, _O_RDONLY);
115+
116+
return (handle == -1);
117+
#endif
112118
}
113119

114120
bool file_handle_internal(LPCSTR file_name, u32& size, int& file_handle)

src/xrCore/LocatorAPI.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,14 @@ void CLocatorAPI::setup_fs_path(pcstr fs_name)
701701
#if defined(WINDOWS)
702702
_fullpath(full_current_directory, fs_path, sizeof full_current_directory);
703703
#elif defined(LINUX)
704-
realpath(fs_path, full_current_directory);
704+
if (SDL_strlen(fs_path) != 0)
705+
{
706+
char *tmp_path = realpath(fs_path, NULL);
707+
SDL_strlcpy(full_current_directory, tmp_path, sizeof full_current_directory);
708+
free(tmp_path);
709+
}
710+
else
711+
SDL_strlcpy(full_current_directory, SDL_GetBasePath(), sizeof full_current_directory);
705712
#endif
706713

707714
FS_Path* path = new FS_Path(full_current_directory, "", "", "", 0);

src/xrCore/xrCore.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pc
5757
}
5858
#endif
5959

60-
#if defined(WINDOWS)
61-
GetCurrentDirectory(sizeof(WorkingPath), WorkingPath);
62-
#endif
60+
SDL_strlcpy(WorkingPath, SDL_GetBasePath(), sizeof(WorkingPath));
6361

6462
#if defined(WINDOWS)
6563
// User/Comp Name

0 commit comments

Comments
 (0)