Skip to content

Commit

Permalink
IO: fixed fs_hidden for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Jan 13, 2025
1 parent 6c72aaa commit 61770af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/modules/io/system/Unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ bool fs_hidden(const char *path) {
const char *p = strrchr(path, '/');
if (p == nullptr) {
p = path;
} else {
++p;
}
return path[0] == '.';
return p[0] == '.';
}

} // namespace io
Expand Down
8 changes: 8 additions & 0 deletions src/modules/io/tests/FilesystemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ TEST_F(FilesystemTest, testListDirectory) {
fs.shutdown();
}

#ifndef _WIN32
TEST_F(FilesystemTest, testSysIsHidden) {
EXPECT_TRUE(io::Filesystem::sysIsHidden("/foo/.bar"));
EXPECT_TRUE(io::Filesystem::sysIsHidden("foo/.bar"));
EXPECT_TRUE(io::Filesystem::sysIsHidden(".bar"));
}
#endif

TEST_F(FilesystemTest, testDirectoryExists) {
io::Filesystem fs;
EXPECT_TRUE(fs.init("test", "test")) << "Failed to initialize the filesystem";
Expand Down

0 comments on commit 61770af

Please sign in to comment.