Skip to content

Commit fdb1db0

Browse files
committed
use noexcept std::filesystem overloads
1 parent 8df7c42 commit fdb1db0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

library/Core.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,14 @@ std::filesystem::path Core::findScript(std::string name)
535535
getScriptPaths(&paths);
536536
for (auto it = paths.begin(); it != paths.end(); ++it)
537537
{
538-
std::filesystem::path path = std::filesystem::weakly_canonical(*it / name);
538+
std::error_code ec;
539+
std::filesystem::path path = std::filesystem::weakly_canonical(*it / name, ec);
540+
if (ec)
541+
{
542+
con.printerr("Error loading ''%s' (%s)\n", (*it / name).string().c_str(), ec.message().c_str());
543+
continue;
544+
}
545+
539546
if (Filesystem::isfile(path))
540547
return path;
541548
}

library/modules/Filesystem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,20 @@ bool Filesystem::stat (std::filesystem::path path, std::filesystem::file_status
154154

155155
bool Filesystem::exists (std::filesystem::path path) noexcept
156156
{
157-
return std::filesystem::exists(path);
157+
std::error_code ec;
158+
return std::filesystem::exists(path, ec);
158159
}
159160

160161
bool Filesystem::isfile(std::filesystem::path path) noexcept
161162
{
162-
return std::filesystem::exists(path) && std::filesystem::is_regular_file(path);
163+
std::error_code ec;
164+
return std::filesystem::exists(path, ec) && std::filesystem::is_regular_file(path, ec);
163165
}
164166

165167
bool Filesystem::isdir (std::filesystem::path path) noexcept
166168
{
167-
return std::filesystem::exists(path) && std::filesystem::is_directory(path);
169+
std::error_code ec;
170+
return std::filesystem::exists(path, ec) && std::filesystem::is_directory(path, ec);
168171
}
169172

170173
std::time_t Filesystem::mtime (std::filesystem::path path) noexcept

0 commit comments

Comments
 (0)