diff --git a/src/Common/FSMacros.hpp b/src/Common/FSMacros.hpp index 7a1eb6b0bb3..a560ced7e37 100644 --- a/src/Common/FSMacros.hpp +++ b/src/Common/FSMacros.hpp @@ -1,12 +1,12 @@ #pragma once -#if defined(LINUX) -#define _DELIMITER '/' //for looking -#define DELIMITER "/" // for insert -#elif defined(WINDOWS) +//#if defined(LINUX) +//#define _DELIMITER '/' //for looking +//#define DELIMITER "/" // for insert +//#elif defined(WINDOWS) #define _DELIMITER '\\' //for looking #define DELIMITER "\\" // for insert -#endif +//#endif // game path definition #define _game_data_ "$game_data$" diff --git a/src/Common/PlatformLinux.inl b/src/Common/PlatformLinux.inl index 6dba9c0cace..df93646acb9 100644 --- a/src/Common/PlatformLinux.inl +++ b/src/Common/PlatformLinux.inl @@ -89,47 +89,48 @@ inline void Sleep(int ms) usleep(ms * 1000); } -#include -inline void _splitpath ( - const char* path, // Path Input - char* drive, // Drive : Output - char* dir, // Directory : Output - char* fname, // Filename : Output - char* ext // Extension : Output -){ - char tmp[PATH_MAX] = {0}; - if(!realpath(path, tmp)) - strcpy(tmp, path); +inline void _splitpath(const char* path, // Path Input + char* drive, // Drive : Output + char* dir, // Directory : Output + char* fname, // Filename : Output + char* ext // Extension : Output + ) +{ + const char *p, *end; if(drive) strcpy(drive, ""); - if(dir) { - char tmp_dir[PATH_MAX] = {0}; - strcpy(tmp_dir, tmp); // W/A for fname broking - strcpy(dir, dirname(tmp_dir)); // This eval modify dirname argument!!! - if (dir[0] && dir[strlen(dir) - 1] != '/') - strcat(dir, "/"); + end = NULL; + for(p = path; *p; p++) + if(*p == '/' || *p == '\\') + end = p + 1; + + if(end) + { + if(dir) + { + memcpy(dir, path, end - path); + dir[end - path] = 0; + } + path = end; } + else if(dir) + dir[0] = 0; + + end = strchr(path, '.'); + + if(!end) + end = p; if(fname) { - strcpy(fname, basename(tmp)); - char *pos = strrchr(fname, '.'); - if(pos != NULL) - *pos = 0; + memcpy(fname, path, end - path); + fname[end - path] = 0; } if(ext) - { - char tmp_ext[NAME_MAX] = { 0 }; - strcpy(tmp_ext, basename(tmp)); - char *pos = strrchr(tmp_ext, '.'); - if(pos != NULL) - strcpy(ext, pos); - else - strcpy(ext, ""); - } + strcpy(ext, end); } #include @@ -350,7 +351,12 @@ inline int _filelength(int fd) #define _read read #define _set_new_handler std::set_new_handler #define _finite isfinite -#define _mkdir(dir) mkdir(dir, S_IRWXU) +inline int _mkdir(const char *dir) +{ + while (char* sep = strchr((char *)dir, '\\')) *sep = '/'; + return mkdir(dir, S_IRWXU); +} + #define _wtoi(arg) wcstol(arg, NULL, 10) #define _wtoi64(arg) wcstoll(arg, NULL, 10) #undef min diff --git a/src/Layers/xrRender/FBasicVisual.cpp b/src/Layers/xrRender/FBasicVisual.cpp index 92ede8783a4..75b58d5f9e3 100644 --- a/src/Layers/xrRender/FBasicVisual.cpp +++ b/src/Layers/xrRender/FBasicVisual.cpp @@ -68,10 +68,6 @@ void dxRender_Visual::Load(const char* N, IReader* data, u32) string256 fnT, fnS; data->r_stringZ(fnT, sizeof(fnT)); data->r_stringZ(fnS, sizeof(fnS)); -#ifdef LINUX - while (char* sep = strchr(fnT, '\\')) *sep = '/'; - while (char* sep = strchr(fnS, '\\')) *sep = '/'; -#endif shader.create(fnS, fnT); } diff --git a/src/Layers/xrRender/ModelPool.cpp b/src/Layers/xrRender/ModelPool.cpp index 9bb7d8a84ae..4c52bd0a304 100644 --- a/src/Layers/xrRender/ModelPool.cpp +++ b/src/Layers/xrRender/ModelPool.cpp @@ -219,9 +219,6 @@ dxRender_Visual* CModelPool::Create(const char* name, IReader* data) string_path low_name; VERIFY(xr_strlen(name) < sizeof(low_name)); xr_strcpy(low_name, name); -#ifdef LINUX - while (char* sep = strchr(low_name, '\\')) *sep = '/'; -#endif xr_strlwr(low_name); if (strext(low_name)) *strext(low_name) = 0; diff --git a/src/Layers/xrRender/ParticleEffectDef.cpp b/src/Layers/xrRender/ParticleEffectDef.cpp index 9949a4c88ff..4c2a4ea2a28 100644 --- a/src/Layers/xrRender/ParticleEffectDef.cpp +++ b/src/Layers/xrRender/ParticleEffectDef.cpp @@ -46,11 +46,6 @@ void CPEDef::CreateShader() { if (*m_ShaderName && *m_TextureName) { -#ifdef LINUX - while (char* sep = strchr(*m_ShaderName, '\\')) *sep = '/'; - while (char* sep = strchr(*m_TextureName, '\\')) *sep = '/'; -#endif - m_CachedShader.create(*m_ShaderName, *m_TextureName); } } diff --git a/src/Layers/xrRender/ResourceManager.cpp b/src/Layers/xrRender/ResourceManager.cpp index 11d6a539156..30f4074e5f4 100644 --- a/src/Layers/xrRender/ResourceManager.cpp +++ b/src/Layers/xrRender/ResourceManager.cpp @@ -190,7 +190,6 @@ Shader* CResourceManager::_cpp_Create( C.bEditor = FALSE; C.bDetail = FALSE; #ifdef _EDITOR -<<<<<<< HEAD if (!C.BT) { ELog.Msg(mtError, "Can't find shader '%s'", s_shader); diff --git a/src/Layers/xrRender/ResourceManager_Loader.cpp b/src/Layers/xrRender/ResourceManager_Loader.cpp index b9ada583a5b..d20f2fab20b 100644 --- a/src/Layers/xrRender/ResourceManager_Loader.cpp +++ b/src/Layers/xrRender/ResourceManager_Loader.cpp @@ -96,9 +96,6 @@ void CResourceManager::OnDeviceCreate(IReader* F) { CBlender_DESC desc; chunk->r(&desc, sizeof(desc)); -#ifdef LINUX - while (char* sep = strchr(desc.cName, '\\')) *sep = '/'; -#endif IBlender* B = IBlender::Create(desc.CLS); if (nullptr == B) { diff --git a/src/Layers/xrRender/SkeletonAnimated.cpp b/src/Layers/xrRender/SkeletonAnimated.cpp index a940da88422..af7b2962ef0 100644 --- a/src/Layers/xrRender/SkeletonAnimated.cpp +++ b/src/Layers/xrRender/SkeletonAnimated.cpp @@ -771,9 +771,6 @@ void CKinematicsAnimated::Load(const char* N, IReader* data, u32 dwFlags) for (u32 k = 0; k < set_cnt; ++k) { data->r_stringZ(nm, sizeof(nm)); -#ifdef LINUX - while (char* sep = strchr(nm, '\\')) *sep = '/'; -#endif xr_strcat(nm, ".omf"); string_path fn; if (!FS.exist(fn, "$level$", nm)) diff --git a/src/Layers/xrRender/SkeletonCustom.cpp b/src/Layers/xrRender/SkeletonCustom.cpp index a93a261acd7..e70849823b3 100644 --- a/src/Layers/xrRender/SkeletonCustom.cpp +++ b/src/Layers/xrRender/SkeletonCustom.cpp @@ -184,9 +184,6 @@ void CKinematics::Load(const char* N, IReader* data, u32 dwFlags) { string_path lod_name; LD->r_string(lod_name, sizeof(lod_name)); -#ifdef LINUX - while (char* sep = strchr(lod_name, '\\')) *sep = '/'; -#endif //. strconcat (sizeof(name_load),name_load, short_name, ":lod:", lod_name.c_str()); m_lod = (dxRender_Visual*)GEnv.Render->model_CreateChild(lod_name, nullptr); diff --git a/src/Layers/xrRender/uber_deffer.cpp b/src/Layers/xrRender/uber_deffer.cpp index e5425868b39..63f7d77608a 100644 --- a/src/Layers/xrRender/uber_deffer.cpp +++ b/src/Layers/xrRender/uber_deffer.cpp @@ -30,9 +30,6 @@ void uber_deffer(CBlender_Compile& C, bool hq, LPCSTR _vspec, LPCSTR _pspec, BOO strconcat(sizeof(vs), vs, "deffer_", _vspec, lmap ? "_lmh" : ""); strconcat(sizeof(ps), ps, "deffer_", _pspec, lmap ? "_lmh" : ""); xr_strcpy(dt, sizeof(dt), _detail_replace ? _detail_replace : (C.detail_texture ? C.detail_texture : "")); -#ifdef LINUX - while (char* sep = strchr(dt, '\\')) *sep = '/'; -#endif // detect detail bump string256 texDetailBump = {'\0'}; diff --git a/src/Layers/xrRenderGL/glSH_Texture.cpp b/src/Layers/xrRenderGL/glSH_Texture.cpp index 73d79117802..2e0e034361d 100644 --- a/src/Layers/xrRenderGL/glSH_Texture.cpp +++ b/src/Layers/xrRenderGL/glSH_Texture.cpp @@ -175,9 +175,6 @@ void CTexture::Load() // Check for OGM string_path fn; -#ifdef LINUX - while (char* sep = strchr(*cName, '\\')) *sep = '/'; -#endif if (FS.exist(fn, "$game_textures$", *cName, ".ogm")) { // AVI @@ -280,9 +277,6 @@ void CTexture::Load() { // Load another texture u32 mem = 0; -#ifdef LINUX - while (char* sep = strchr(buffer, '\\')) *sep = '/'; -#endif pSurface = RImplementation.texture_load(buffer, mem, desc); if (pSurface) { diff --git a/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp b/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp index 6cdc8fb9a2c..a30a6b475bd 100644 --- a/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp +++ b/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp @@ -512,9 +512,6 @@ CTexture* CResourceManager::_CreateTexture(LPCSTR _Name) R_ASSERT (_Name && _Name[0]); string_path Name; strcpy_s(Name, _Name); //. andy if (strext(Name)) *strext(Name)=0; -#ifdef LINUX - while (char* sep = strchr(Name, '\\')) *sep = '/'; -#endif fix_texture_name(Name); diff --git a/src/Layers/xrRenderPC_GL/rgl_shaders.cpp b/src/Layers/xrRenderPC_GL/rgl_shaders.cpp index c29049fab24..95542773968 100644 --- a/src/Layers/xrRenderPC_GL/rgl_shaders.cpp +++ b/src/Layers/xrRenderPC_GL/rgl_shaders.cpp @@ -42,9 +42,6 @@ static inline void load_includes(LPCSTR pSrcData, UINT SrcDataLen, xr_vectorclose(); @@ -458,6 +459,7 @@ void CLocatorAPI::archive::open() if (hSrcFile) return; + while (char* sep = strchr((char *)*path, '\\')) *sep = '/'; hSrcFile = ::open(*path, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); R_ASSERT(hSrcFile != -1); struct stat file_info; @@ -571,7 +573,8 @@ void CLocatorAPI::ProcessOne(pcstr path, const _finddata_t& entry) return; if (0 == xr_strcmp(entry.name, "..")) return; - xr_strcat(N, DELIMITER); + if(path[xr_strlen(path) - 1] != _DELIMITER || path[xr_strlen(path) - 1] != '/') + xr_strcat(N, DELIMITER); Register(N, 0xffffffff, 0, 0, entry.size, entry.size, (u32)entry.time_write); Recurse(N); } @@ -628,6 +631,7 @@ bool ignore_path(const char* _path) else return true; #elif defined(LINUX) + while (char* sep = strchr((char *)_path, '\\')) *sep = '/'; int h = ::open(_path, O_RDONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (h != -1) { @@ -657,6 +661,9 @@ bool CLocatorAPI::Recurse(pcstr path) #elif defined(LINUX) glob_t globbuf; + while (char* sep = strchr(scanPath, '\\')) + *sep = '/'; + globbuf.gl_offs = 256; int result = glob(scanPath, GLOB_NOSORT, NULL, &globbuf); @@ -682,6 +689,7 @@ bool CLocatorAPI::Recurse(pcstr path) case S_IFREG: findData.attrib = 0; break; // File default: findData.attrib = _A_HIDDEN; break; // Skip } + while (char* sep = strchr(findData.name, '/')) *sep = '\\'; #endif string1024 fullPath; bool ignore = false; @@ -712,6 +720,7 @@ bool CLocatorAPI::Recurse(pcstr path) _findclose(handle); #elif defined(LINUX) globfree(&globbuf); + while (char* sep = strchr((char *)path, '/')) *sep = '\\'; #endif size_t newSize = rec_files.size(); if (newSize > oldSize) diff --git a/src/xrCore/LocatorAPI_defs.cpp b/src/xrCore/LocatorAPI_defs.cpp index 8cd1e15e9ec..e44abe2d85f 100644 --- a/src/xrCore/LocatorAPI_defs.cpp +++ b/src/xrCore/LocatorAPI_defs.cpp @@ -47,10 +47,7 @@ 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 defined(LINUX) - while (char* sep = strchr(temp, '\\')) *sep = '/'; -#endif - if (temp[0] && temp[xr_strlen(temp) - 1] != _DELIMITER) + if (temp[0] && temp[xr_strlen(temp) - 1] != _DELIMITER && temp[xr_strlen(temp) - 1] != '/') xr_strcat(temp, DELIMITER); m_Path = xr_strdup(temp); m_DefExt = _DefExt ? xr_strdup(_DefExt) : 0; diff --git a/src/xrCore/XML/XMLDocument.cpp b/src/xrCore/XML/XMLDocument.cpp index de5c1da4ed6..aa5efe5cfd4 100644 --- a/src/xrCore/XML/XMLDocument.cpp +++ b/src/xrCore/XML/XMLDocument.cpp @@ -24,9 +24,6 @@ void ParseFile(pcstr path, CMemoryWriter& W, IReader* F, XMLDocument* xml) string256 inc_name; if (_GetItem(str, 1, inc_name, '"')) { -#if defined(LINUX) - while (char* sep = strchr(inc_name, '\\')) *sep = '/'; -#endif IReader* I = nullptr; if (inc_name == strstr(inc_name, UI_PATH_DEFAULT_WITH_DELIMITER)) { diff --git a/src/xrCore/file_stream_reader.cpp b/src/xrCore/file_stream_reader.cpp index 221d99235aa..8bcef4c8b48 100644 --- a/src/xrCore/file_stream_reader.cpp +++ b/src/xrCore/file_stream_reader.cpp @@ -17,7 +17,10 @@ void CFileStreamReader::construct(LPCSTR file_name, const u32& window_size) inherited::construct(file_mapping_handle, 0, file_size, file_size, window_size); #elif defined(LINUX) - m_file_handle = ::open(file_name, O_RDONLY); + char path[PATH_MAX] = { 0 }; + strcpy(path, file_name); + while (char* sep = strchr(path, '\\')) *sep = '/'; + m_file_handle = ::open(path, O_RDONLY); VERIFY(m_file_handle != -1); struct stat file_info; ::fstat(m_file_handle, &file_info); diff --git a/src/xrCore/xr_ini.cpp b/src/xrCore/xr_ini.cpp index a356bb33c03..1f780542c47 100644 --- a/src/xrCore/xr_ini.cpp +++ b/src/xrCore/xr_ini.cpp @@ -340,11 +340,6 @@ CInifile::CInifile(pcstr fileName, bool readOnly, bool loadAtStart, bool saveAtE if (fileName && strstr(fileName, "system")) Msg("-----loading %s", fileName); -#ifdef LINUX - if (fileName) - while (char* sep = strchr((char *)fileName, '\\')) *sep = '/'; -#endif - m_file_name[0] = 0; m_flags.zero(); if (fileName) @@ -455,9 +450,6 @@ void CInifile::Load(IReader* F, pcstr path, allow_include_func_t allow_include_f R_ASSERT(path && path[0]); if (_GetItem(str, 1, inc_name, '"')) { -#ifdef LINUX - while (char* sep = strchr(inc_name, '\\')) *sep = '/'; -#endif xr_strlwr(inc_name); // compensate removed xr_strlwr on path string_path fn; diff --git a/src/xrEngine/GameFont.cpp b/src/xrEngine/GameFont.cpp index 9a67af479c2..b5ffd22a503 100644 --- a/src/xrEngine/GameFont.cpp +++ b/src/xrEngine/GameFont.cpp @@ -59,10 +59,6 @@ void CGameFont::Initialize(pcstr cShader, pcstr cTextureName) else xr_strcpy(cTexture, sizeof(cTexture), cTextureName); -#if defined(LINUX) - while (char* sep = strchr(cTexture, '\\')) *sep = '/'; -#endif - uFlags &= ~fsValid; vTS.set(1.f, 1.f); // обязательно !!! diff --git a/src/xrEngine/thunderbolt.cpp b/src/xrEngine/thunderbolt.cpp index 2eda41889b5..e669fdabbda 100644 --- a/src/xrEngine/thunderbolt.cpp +++ b/src/xrEngine/thunderbolt.cpp @@ -64,9 +64,6 @@ void SThunderboltDesc::load(CInifile& pIni, shared_str const& sect) LPCSTR m_name = pIni.r_string(sect, "lightning_model"); string_path tmp; xr_strcpy(tmp, m_name); -#if defined(LINUX) - while (char* sep = strchr(tmp, '\\')) *sep = '/'; -#endif m_pRender->CreateModel(tmp); /* @@ -79,9 +76,6 @@ void SThunderboltDesc::load(CInifile& pIni, shared_str const& sect) // sound m_name = pIni.r_string(sect, "sound"); xr_strcpy(tmp, m_name); -#if defined(LINUX) - while (char* sep = strchr(tmp, '\\')) *sep = '/'; -#endif if (m_name && m_name[0]) snd.create(tmp, st_Effect, sg_Undefined); } diff --git a/src/xrGame/script_sound.cpp b/src/xrGame/script_sound.cpp index 093926726af..e221e4be82f 100644 --- a/src/xrGame/script_sound.cpp +++ b/src/xrGame/script_sound.cpp @@ -16,9 +16,6 @@ CScriptSound::CScriptSound(LPCSTR caSoundName, ESoundTypes sound_type) { -#ifdef LINUX - while (char* sep = strchr((char *)caSoundName, '\\')) *sep = '/'; -#endif m_bIsNoSound = strstr(Core.Params, "-nosound"); m_caSoundToPlay = caSoundName; string_path l_caFileName; diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index 424d7e6b7ce..487644bdf4b 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -108,9 +108,6 @@ CSE_Abstract::CSE_Abstract(LPCSTR caSection) if (pSettings->line_exist(caSection, "custom_data")) { pcstr const raw_file_name = pSettings->r_string(caSection, "custom_data"); -#ifdef LINUX - while (char* sep = strchr((char *)raw_file_name, '\\')) *sep = '/'; -#endif IReader const* config = nullptr; #ifdef XRGAME_EXPORTS if (ai().get_alife()) diff --git a/src/xrSound/SoundRender_Source_loader.cpp b/src/xrSound/SoundRender_Source_loader.cpp index 70bc19b31c5..60b5cdeab40 100644 --- a/src/xrSound/SoundRender_Source_loader.cpp +++ b/src/xrSound/SoundRender_Source_loader.cpp @@ -128,8 +128,6 @@ void CSoundRender_Source::load(pcstr name) xr_strcpy(N, name); #ifdef WINDOWS xr_strlwr(N); -#elif defined(LINUX) - while (char* sep = strchr(N, '\\')) *sep = '/'; #endif if (strext(N))