Skip to content

Commit

Permalink
xrCore: add run-time replacement for linux-specific path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Aug 18, 2018
1 parent 773622a commit 2152c23
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/Common/FSMacros.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#pragma once

#if defined(LINUX)
#define _DELIMITER '/' //for looking
#define DELIMITER "/" // for insert
#elif defined(WINDOWS)
#define _DELIMITER '\\' //for looking
#define DELIMITER "\\" // for insert
#endif

// game path definition
#define _game_data_ "$game_data$"
#define _game_textures_ "$game_textures$"
Expand Down
18 changes: 17 additions & 1 deletion src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,29 @@ inline void Sleep(int ms)
usleep(ms * 1000);
}

#include <libgen.h>
inline void _splitpath (
const char* path, // Path Input
char* drive, // Drive : Output
char* dir, // Directory : Output
char* fname, // Filename : Output
char* ext // Extension : Output
){}
){
if(drive)
strcpy(drive, "");

if(dir)
strcpy(dir, dirname(path));

if(fname)
strcpy(fname, basename(path));
}

#include <iostream>
inline void OutputDebugString(char *str) // for linux debugger
{
std::cerr << str;
}

inline unsigned long GetLastError()
{
Expand Down
11 changes: 9 additions & 2 deletions src/xrCore/LocatorAPI_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ FS_Path::FS_Path(LPCSTR _Root, LPCSTR _Add, LPCSTR _DefExt, LPCSTR _FilterCaptio
xr_strcpy(temp, sizeof(temp), _Root);
if (_Add)
xr_strcat(temp, _Add);
if (temp[0] && temp[xr_strlen(temp) - 1] != '\\')
xr_strcat(temp, "\\");
#if defined(LINUX)
char *ptr = strchr(temp, '\\');
while (ptr) {
*ptr = '/';
ptr = strchr(ptr, '\\');
}
#endif
if (temp[0] && temp[xr_strlen(temp) - 1] != _DELIMITER)
xr_strcat(temp, DELIMITER);
m_Path = xr_strlwr(xr_strdup(temp));
m_DefExt = _DefExt ? xr_strlwr(xr_strdup(_DefExt)) : 0;
m_FilterCaption = _FilterCaption ? xr_strlwr(xr_strdup(_FilterCaption)) : 0;
Expand Down
4 changes: 3 additions & 1 deletion src/xrCore/_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,16 @@ void _initialize_cpu()

string256 features;
xr_strcpy(features, sizeof(features), "RDTSC");
if (SDL_HasAltiVec()) xr_strcat(features, ", AltiVec");
if (SDL_HasMMX()) xr_strcat(features, ", MMX");
if (SDL_Has3DNow()) xr_strcat(features, ", 3DNow!");
if (SDL_HasSSE()) xr_strcat(features, ", SSE");
if (SDL_HasSSE2()) xr_strcat(features, ", SSE2");
if (SDL_HasSSE3()) xr_strcat(features, ", SSE3");
if (SDL_HasRDTSC()) xr_strcat(features, ", RDTSC");
if (SDL_HasSSE41()) xr_strcat(features, ", SSE4.1");
if (SDL_HasSSE42()) xr_strcat(features, ", SSE4.2");
if (SDL_HasAVX()) xr_strcat(features, ", AVX");
if (SDL_HasAVX2()) xr_strcat(features, ", AVX2");

Msg("* CPU features: %s", features);
Msg("* CPU cores/threads: %d/%d", std::thread::hardware_concurrency(), SDL_GetCPUCount());
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void AddOne(const char* split)
{
logCS.Enter();

#ifdef DEBUG
#if defined(DEBUG) || defined(LINUX)
OutputDebugString(split);
OutputDebugString("\n");
#endif
Expand Down

0 comments on commit 2152c23

Please sign in to comment.