mirror of https://github.com/axmolengine/axmol.git
Particle3D: add wasm support for load materials
This commit is contained in:
parent
9251d8beff
commit
139181bb53
|
@ -42,7 +42,12 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
|
#else
|
||||||
|
# include "base/filesystem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "yasio/string_view.hpp"
|
||||||
|
|
||||||
NS_AX_BEGIN
|
NS_AX_BEGIN
|
||||||
|
|
||||||
PUMaterial::PUMaterial()
|
PUMaterial::PUMaterial()
|
||||||
|
@ -132,13 +137,12 @@ bool PUMaterialCache::loadMaterialsFromSearchPaths(std::string_view fileFolder)
|
||||||
{
|
{
|
||||||
bool state = false;
|
bool state = false;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
std::string seg("/");
|
std::string_view seg("/");
|
||||||
std::string fullPath{fileFolder};
|
std::string fullPath{fileFolder};
|
||||||
fullPath += seg;
|
fullPath += seg;
|
||||||
fullPath += std::string("*.material");
|
fullPath += "*.material"sv;
|
||||||
WIN32_FIND_DATAA data;
|
WIN32_FIND_DATAA data;
|
||||||
HANDLE handle =
|
HANDLE handle = FindFirstFileExA(fullPath.c_str(), FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
|
||||||
FindFirstFileExA(fullPath.c_str(), FindExInfoStandard, &data, FindExSearchNameMatch, NULL, 0);
|
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
state = true;
|
state = true;
|
||||||
|
@ -148,7 +152,7 @@ bool PUMaterialCache::loadMaterialsFromSearchPaths(std::string_view fileFolder)
|
||||||
fullPath += seg;
|
fullPath += seg;
|
||||||
fullPath += data.cFileName;
|
fullPath += data.cFileName;
|
||||||
loadMaterials(fullPath);
|
loadMaterials(fullPath);
|
||||||
|
|
||||||
} while (FindNextFileA(handle, &data));
|
} while (FindNextFileA(handle, &data));
|
||||||
FindClose(handle);
|
FindClose(handle);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +208,20 @@ bool PUMaterialCache::loadMaterialsFromSearchPaths(std::string_view fileFolder)
|
||||||
}
|
}
|
||||||
closedir(d);
|
closedir(d);
|
||||||
#else
|
#else
|
||||||
AXASSERT(0, "no implement for this platform");
|
// use c++17 filesystem
|
||||||
|
for (const auto& entry : stdfs::recursive_directory_iterator(fileFolder))
|
||||||
|
{
|
||||||
|
# if !defined(_WIN32)
|
||||||
|
if (entry.is_regular_file() && cxx20::ends_with(entry.path().native(), ".material"sv))
|
||||||
|
# else
|
||||||
|
if (entry.is_regular_file() && cxx20::ends_with(entry.path().native(), L".material"sv))
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
auto pathU8Str = entry.path().generic_u8string();
|
||||||
|
auto& pathStr = *reinterpret_cast<std::string*>(&pathU8Str);
|
||||||
|
loadMaterials(pathStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in New Issue