Skip to content

Commit 2152c23

Browse files
committed
xrCore: add run-time replacement for linux-specific path separator
1 parent 773622a commit 2152c23

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

src/Common/FSMacros.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#pragma once
22

3+
#if defined(LINUX)
4+
#define _DELIMITER '/' //for looking
5+
#define DELIMITER "/" // for insert
6+
#elif defined(WINDOWS)
7+
#define _DELIMITER '\\' //for looking
8+
#define DELIMITER "\\" // for insert
9+
#endif
10+
311
// game path definition
412
#define _game_data_ "$game_data$"
513
#define _game_textures_ "$game_textures$"

src/Common/PlatformLinux.inl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,29 @@ inline void Sleep(int ms)
8787
usleep(ms * 1000);
8888
}
8989

90+
#include <libgen.h>
9091
inline void _splitpath (
9192
const char* path, // Path Input
9293
char* drive, // Drive : Output
9394
char* dir, // Directory : Output
9495
char* fname, // Filename : Output
9596
char* ext // Extension : Output
96-
){}
97+
){
98+
if(drive)
99+
strcpy(drive, "");
100+
101+
if(dir)
102+
strcpy(dir, dirname(path));
103+
104+
if(fname)
105+
strcpy(fname, basename(path));
106+
}
107+
108+
#include <iostream>
109+
inline void OutputDebugString(char *str) // for linux debugger
110+
{
111+
std::cerr << str;
112+
}
97113

98114
inline unsigned long GetLastError()
99115
{

src/xrCore/LocatorAPI_defs.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ FS_Path::FS_Path(LPCSTR _Root, LPCSTR _Add, LPCSTR _DefExt, LPCSTR _FilterCaptio
4848
xr_strcpy(temp, sizeof(temp), _Root);
4949
if (_Add)
5050
xr_strcat(temp, _Add);
51-
if (temp[0] && temp[xr_strlen(temp) - 1] != '\\')
52-
xr_strcat(temp, "\\");
51+
#if defined(LINUX)
52+
char *ptr = strchr(temp, '\\');
53+
while (ptr) {
54+
*ptr = '/';
55+
ptr = strchr(ptr, '\\');
56+
}
57+
#endif
58+
if (temp[0] && temp[xr_strlen(temp) - 1] != _DELIMITER)
59+
xr_strcat(temp, DELIMITER);
5360
m_Path = xr_strlwr(xr_strdup(temp));
5461
m_DefExt = _DefExt ? xr_strlwr(xr_strdup(_DefExt)) : 0;
5562
m_FilterCaption = _FilterCaption ? xr_strlwr(xr_strdup(_FilterCaption)) : 0;

src/xrCore/_math.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,16 @@ void _initialize_cpu()
326326

327327
string256 features;
328328
xr_strcpy(features, sizeof(features), "RDTSC");
329+
if (SDL_HasAltiVec()) xr_strcat(features, ", AltiVec");
329330
if (SDL_HasMMX()) xr_strcat(features, ", MMX");
330331
if (SDL_Has3DNow()) xr_strcat(features, ", 3DNow!");
331332
if (SDL_HasSSE()) xr_strcat(features, ", SSE");
332333
if (SDL_HasSSE2()) xr_strcat(features, ", SSE2");
333334
if (SDL_HasSSE3()) xr_strcat(features, ", SSE3");
334-
if (SDL_HasRDTSC()) xr_strcat(features, ", RDTSC");
335335
if (SDL_HasSSE41()) xr_strcat(features, ", SSE4.1");
336336
if (SDL_HasSSE42()) xr_strcat(features, ", SSE4.2");
337+
if (SDL_HasAVX()) xr_strcat(features, ", AVX");
338+
if (SDL_HasAVX2()) xr_strcat(features, ", AVX2");
337339

338340
Msg("* CPU features: %s", features);
339341
Msg("* CPU cores/threads: %d/%d", std::thread::hardware_concurrency(), SDL_GetCPUCount());

src/xrCore/log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void AddOne(const char* split)
4444
{
4545
logCS.Enter();
4646

47-
#ifdef DEBUG
47+
#if defined(DEBUG) || defined(LINUX)
4848
OutputDebugString(split);
4949
OutputDebugString("\n");
5050
#endif

0 commit comments

Comments
 (0)