mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
- getting rid of std::filesystem, part one.
Since it's not usable on macOS it needs to go.
This commit is contained in:
parent
6a4870e7fb
commit
78e7b2dd8c
5 changed files with 53 additions and 16 deletions
|
@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "zstring.h"
|
#include "zstring.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@ FString M_GetSavegamesPath();
|
||||||
FString M_GetDocumentsPath();
|
FString M_GetDocumentsPath();
|
||||||
FString M_GetDemoPath();
|
FString M_GetDemoPath();
|
||||||
|
|
||||||
|
FString M_GetNormalizedPath(const char* path);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
FString M_GetMacAppSupportPath(const bool create = true);
|
FString M_GetMacAppSupportPath(const bool create = true);
|
||||||
|
|
|
@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include "m_crc32.h"
|
#include "m_crc32.h"
|
||||||
#include "i_specialpaths.h"
|
#include "i_specialpaths.h"
|
||||||
|
#include "i_system.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "gameconfigfile.h"
|
#include "gameconfigfile.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
|
@ -451,28 +452,26 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
|
||||||
|
|
||||||
void CollectSubdirectories(TArray<FString> &searchpath, const char *dirmatch)
|
void CollectSubdirectories(TArray<FString> &searchpath, const char *dirmatch)
|
||||||
{
|
{
|
||||||
try
|
FString dirpath = MakeUTF8(dirmatch); // convert into clean UTF-8
|
||||||
|
dirpath.Truncate(dirpath.Len() - 2); // remove the '/*'
|
||||||
|
FString AbsPath = M_GetNormalizedPath(dirpath);
|
||||||
|
if (DirExists(AbsPath))
|
||||||
{
|
{
|
||||||
FString dirpath = MakeUTF8(dirmatch); // convert into clean UTF-8
|
findstate_t findstate;
|
||||||
dirpath.Truncate(dirpath.Len() - 2); // remove the '/*'
|
void* handle;
|
||||||
fs::path path = AbsolutePath(dirpath.GetChars());
|
if ((handle = I_FindFirst(AbsPath + "/*.*", &findstate)) != (void*)-1)
|
||||||
if (fs::exists(path) && fs::is_directory(path))
|
|
||||||
{
|
{
|
||||||
for (const auto& entry : fs::directory_iterator(path))
|
do
|
||||||
{
|
{
|
||||||
if (fs::is_directory(entry.status()))
|
if (!(I_FindAttr(&findstate) & FA_DIREC))
|
||||||
{
|
{
|
||||||
FString newdir = absolute(entry.path()).u8string().c_str();
|
FStringf fullpath("%s/%s", AbsPath.GetChars(), I_FindName(&findstate));
|
||||||
if (searchpath.Find(newdir) == searchpath.Size())
|
searchpath.Push(fullpath);
|
||||||
searchpath.Push(newdir);
|
|
||||||
}
|
}
|
||||||
}
|
} while (I_FindNext(handle, &findstate) == 0);
|
||||||
|
I_FindClose(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (fs::filesystem_error &)
|
|
||||||
{
|
|
||||||
// Just ignore this path if it caused an error.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -220,3 +220,23 @@ FString M_GetDocumentsPath()
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_NormalizedPath
|
||||||
|
//
|
||||||
|
// Normalizes the given path and returns the result.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetNormalizedPath(const char* path)
|
||||||
|
{
|
||||||
|
NSString *str = [NSString stringWithUTF8String:path];
|
||||||
|
NSString *out;
|
||||||
|
if ([str completePathIntoString:&out caseSensitive:NO matchesIntoArray:nil filterTypes:nil])
|
||||||
|
{
|
||||||
|
return out.UTF8String;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
|
@ -382,3 +382,21 @@ FString M_GetDemoPath()
|
||||||
CreatePath(path);
|
CreatePath(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// M_NormalizedPath
|
||||||
|
//
|
||||||
|
// Normalizes the given path and returns the result.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
FString M_GetNormalizedPath(const char* path)
|
||||||
|
{
|
||||||
|
std::wstring wpath = WideString(path);
|
||||||
|
wchar_t buffer[MAX_PATH];
|
||||||
|
GetFullPathNameW(wpath.c_str(), MAX_PATH, buffer, nullptr);
|
||||||
|
FString result(buffer);
|
||||||
|
FixPathSeperator(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue