Skip to content

Commit c6e57d2

Browse files
fixed the resource embedding bug
1 parent 5f97eda commit c6e57d2

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

include/nbl/builtin/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace nbl::builtin
1919

2020
constexpr std::string_view PathPrefix = "nbl/builtin/";
2121
constexpr bool hasPathPrefix(std::string_view str) { return str.find(PathPrefix) == 0ull; }
22-
22+
2323
// if you attempt to use this without `NBL_EMBED_BUILTIN_RESOURCES_` CMake option, this will always return `{nullptr,0ull}`
2424
std::pair<const uint8_t*,size_t> get_resource_runtime(const std::string&);
2525

@@ -28,7 +28,7 @@ std::pair<const uint8_t*,size_t> get_resource_runtime(const std::string&);
2828
constexpr std::string_view getBuiltinResourcesDirectoryPath()
2929
{
3030
std::string_view retval = __FILE__;
31-
retval.remove_suffix(std::string_view("common.h").size());
31+
retval.remove_suffix(PathPrefix.size()+std::string_view("common.h").size());
3232
return retval;
3333
}
3434
#endif

include/nbl/system/ISystem.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ class NBL_API2 ISystem : public core::IReferenceCounted
113113

114114
//! Compile time resource ID
115115
template<nbl::core::StringLiteral Path>
116-
inline core::smart_refctd_ptr<const IFile> loadBuiltinData() const
116+
inline core::smart_refctd_ptr<const IFile> loadBuiltinData()
117117
{
118118
#ifdef _NBL_EMBED_BUILTIN_RESOURCES_
119-
120119
return impl_loadEmbeddedBuiltinData(Path.value, nbl::builtin::get_resource<Path>());
121120
#else
122121
future_t<core::smart_refctd_ptr<IFile>> future;
123-
createFile(future, STRING_LITERAL::value,core::bitflag(IFileBase::ECF_READ)|IFileBase::ECF_MAPPABLE);
122+
createFile(future,system::path(Path.value),core::bitflag(IFileBase::ECF_READ)|IFileBase::ECF_MAPPABLE);
124123
return future.get();
125124
#endif
126125
}

src/nbl/system/ISystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool ISystem::exists(const system::path& filename, const core::bitflag<IFile::E_
4343
if (found.first && found.second)
4444
return true;
4545
#else
46-
if (exists(builtinResourceDirectory/filename))
46+
if (exists(builtin::getBuiltinResourcesDirectoryPath()/filename,flags))
4747
return true;
4848
#endif
4949
}
@@ -112,9 +112,9 @@ core::vector<system::path> ISystem::listItemsInDirectory(const system::path& p)
112112
#else
113113
err.clear();
114114
// check root path is prefixed with "nbl/builtin/"
115-
if (p.string().find(builtinPathPrefix) == 0)
115+
if (builtin::hasPathPrefix(p.string()))
116116
{
117-
const auto subdirs = std::filesystem::recursive_directory_iterator(builtinResourceDirectory/p,err);
117+
const auto subdirs = std::filesystem::recursive_directory_iterator(builtin::getBuiltinResourcesDirectoryPath()/p,err);
118118
if (!err)
119119
for (auto entry : subdirs) // there are never any archives inside builtins
120120
res.push_back(entry.path());
@@ -221,7 +221,7 @@ void ISystem::createFile(future_t<core::smart_refctd_ptr<IFile>>& future, std::f
221221
return;
222222
}
223223
#else
224-
createFile(future,builtinResourceDirectory/filename,flags);
224+
createFile(future,builtin::getBuiltinResourcesDirectoryPath()/filename,flags);
225225
return;
226226
#endif
227227
}

0 commit comments

Comments
 (0)