mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +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 "tarray.h"
|
||||
#include "zstring.h"
|
||||
|
|
|
@ -13,6 +13,7 @@ FString M_GetSavegamesPath();
|
|||
FString M_GetDocumentsPath();
|
||||
FString M_GetDemoPath();
|
||||
|
||||
FString M_GetNormalizedPath(const char* path);
|
||||
|
||||
#ifdef __APPLE__
|
||||
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 "m_crc32.h"
|
||||
#include "i_specialpaths.h"
|
||||
#include "i_system.h"
|
||||
#include "compat.h"
|
||||
#include "gameconfigfile.h"
|
||||
#include "cmdlib.h"
|
||||
|
@ -451,28 +452,26 @@ void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
|
|||
|
||||
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
|
||||
dirpath.Truncate(dirpath.Len() - 2); // remove the '/*'
|
||||
fs::path path = AbsolutePath(dirpath.GetChars());
|
||||
if (fs::exists(path) && fs::is_directory(path))
|
||||
findstate_t findstate;
|
||||
void* handle;
|
||||
if ((handle = I_FindFirst(AbsPath + "/*.*", &findstate)) != (void*)-1)
|
||||
{
|
||||
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();
|
||||
if (searchpath.Find(newdir) == searchpath.Size())
|
||||
searchpath.Push(newdir);
|
||||
FStringf fullpath("%s/%s", AbsPath.GetChars(), I_FindName(&findstate));
|
||||
searchpath.Push(fullpath);
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// 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);
|
||||
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