Made the lib work with -fno-exceptions (at least for now).

This commit is contained in:
2025-03-02 14:35:37 +01:00
parent 21b3b2c03a
commit ba23cb0c70
5 changed files with 50 additions and 12 deletions

View File

@@ -57,18 +57,22 @@ std::vector<FileInfo> OSFileSystemAdapter::listFiles(const fs::path& folder)
info.isSymlink = entry.is_symlink(err);
info.isSpecial = !info.isFolder && !entry.is_regular_file(err);
info.isHidden = info.path.filename().string().starts_with('.'); // at least for Linux
if (info.isFolder) {
try {
if (info.isFolder)
{
MIJIN_TRY
{
info.size = std::distance(fs::directory_iterator(info.path), fs::directory_iterator());
}
catch(std::runtime_error&) {
MIJIN_CATCH(std::runtime_error&)
{
info.size = 0;
}
}
else if (!info.isSpecial)
{
info.size = entry.file_size(err);
if (err) {
if (err)
{
info.size = 0;
}
}
@@ -89,10 +93,12 @@ FileInfo OSFileSystemAdapter::getFileInfo(const fs::path& file)
info.isSpecial = !info.isFolder && !fs::is_regular_file(file, err);
info.isHidden = info.path.filename().string().starts_with('.'); // at least for Linux
if (info.isFolder) {
try {
MIJIN_TRY
{
info.size = std::distance(fs::directory_iterator(info.path), fs::directory_iterator());
}
catch(std::runtime_error&) {
MIJIN_CATCH(std::runtime_error&)
{
info.size = 0;
}
}