Skip to content

Commit 06fd987

Browse files
committed
implement suggested changes
1 parent 838c378 commit 06fd987

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

library/modules/Filesystem.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,30 @@ bool Filesystem::stat (std::filesystem::path path, std::filesystem::file_status
155155
bool Filesystem::exists (std::filesystem::path path) noexcept
156156
{
157157
std::error_code ec;
158-
return std::filesystem::exists(path, ec);
158+
auto r = std::filesystem::exists(path, ec);
159+
if (ec)
160+
return false;
161+
return r;
159162
}
160163

161164
bool Filesystem::isfile(std::filesystem::path path) noexcept
162165
{
163166
std::error_code ec;
164-
return std::filesystem::exists(path, ec) && std::filesystem::is_regular_file(path, ec);
167+
// is_regular_file() also checks for existence.
168+
auto r = std::filesystem::is_regular_file(path, ec);
169+
if (ec)
170+
return false;
171+
return r;
165172
}
166173

167174
bool Filesystem::isdir (std::filesystem::path path) noexcept
168175
{
169176
std::error_code ec;
170-
return std::filesystem::exists(path, ec) && std::filesystem::is_directory(path, ec);
177+
// is_directory() also checks for existence.
178+
auto r = std::filesystem::is_directory(path, ec);
179+
if (ec)
180+
return false;
181+
return r;
171182
}
172183

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

0 commit comments

Comments
 (0)