Skip to content

Commit 3af0ecf

Browse files
committed
BUG: Ensure copyDirRecursively considers hidden directories and files
1 parent 8254339 commit 3af0ecf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Libs/Core/Testing/Cpp/ctkUtilsCopyDirRecursivelyTest1.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ int ctkUtilsCopyDirRecursivelyTest1(int argc, char * argv [] )
112112
{
113113
return EXIT_FAILURE;
114114
}
115+
if (!createFile(__LINE__, tmp, "foo/zoo", ".hidden.txt"))
116+
{
117+
return EXIT_FAILURE;
118+
}
119+
if (!createFile(__LINE__, tmp, "foo/.hidden", "c.txt"))
120+
{
121+
return EXIT_FAILURE;
122+
}
123+
if (!createFile(__LINE__, tmp, "foo/.hidden", ".hidden.txt"))
124+
{
125+
return EXIT_FAILURE;
126+
}
115127

116128
{
117129
QString srcPath(tmp.path() + "/foo");
@@ -128,6 +140,9 @@ int ctkUtilsCopyDirRecursivelyTest1(int argc, char * argv [] )
128140
CHECK_BOOL(QDir(destPath).exists("a.txt"), true);
129141
CHECK_BOOL(QDir(destPath).exists("bar/b.txt"), true);
130142
CHECK_BOOL(QDir(destPath).exists("zoo/c.txt"), true);
143+
CHECK_BOOL(QDir(destPath).exists("zoo/.hidden.txt"), true);
144+
CHECK_BOOL(QDir(destPath).exists(".hidden/c.txt"), true);
145+
CHECK_BOOL(QDir(destPath).exists(".hidden/.hidden.txt"), true);
131146
}
132147

133148
{

Libs/Core/ctkUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ bool ctk::copyDirRecursively(const QString &srcPath, const QString &dstPath)
362362
return false;
363363
}
364364

365-
foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
365+
foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot))
366366
{
367367
QString srcItemPath = srcPath + "/" + info.fileName();
368368
QString dstItemPath = dstPath + "/" + info.fileName();

0 commit comments

Comments
 (0)