mirror of
https://github.com/darlinghq/xcbuild.git
synced 2025-02-22 01:10:36 +00:00
Process child directories first in Filesystem->readDirectory call
This commit is contained in:
parent
0ecebca6f4
commit
37fa106537
@ -32,8 +32,8 @@ TEST(DirectoryDependencyInfo, Deserialize)
|
|||||||
EXPECT_EQ(info->dependencyInfo().inputs(), std::vector<std::string>({
|
EXPECT_EQ(info->dependencyInfo().inputs(), std::vector<std::string>({
|
||||||
"/root/file1",
|
"/root/file1",
|
||||||
"/root/file2",
|
"/root/file2",
|
||||||
"/root/dir",
|
|
||||||
"/root/dir/file3",
|
"/root/dir/file3",
|
||||||
|
"/root/dir",
|
||||||
}));
|
}));
|
||||||
EXPECT_TRUE(info->dependencyInfo().outputs().empty());
|
EXPECT_TRUE(info->dependencyInfo().outputs().empty());
|
||||||
}
|
}
|
||||||
|
@ -494,28 +494,19 @@ readDirectory(std::string const &path, bool recursive, std::function<void(std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string path = (relative ? *relative + "/" + entry->d_name : entry->d_name);
|
std::string path = (relative ? *relative + "/" + entry->d_name : entry->d_name);
|
||||||
cb(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process subdirectories. */
|
|
||||||
if (recursive) {
|
|
||||||
::rewinddir(dp);
|
|
||||||
|
|
||||||
while (struct dirent *entry = ::readdir(dp)) {
|
|
||||||
if (::strcmp(entry->d_name, ".") == 0 || ::strcmp(entry->d_name, "..") == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Process subdirectories first. */
|
||||||
|
if (recursive) {
|
||||||
std::string full = absolute + "/" + entry->d_name;
|
std::string full = absolute + "/" + entry->d_name;
|
||||||
|
|
||||||
if (this->type(full) == Type::Directory) {
|
if (this->type(full) == Type::Directory) {
|
||||||
std::string path = (relative ? *relative + "/" + entry->d_name : entry->d_name);
|
|
||||||
if (!process(full, path)) {
|
if (!process(full, path)) {
|
||||||
::closedir(dp);
|
::closedir(dp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cb(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
::closedir(dp);
|
::closedir(dp);
|
||||||
|
@ -385,17 +385,13 @@ readDirectory(std::string const &path, bool recursive, std::function<void(std::s
|
|||||||
/* Report children. */
|
/* Report children. */
|
||||||
for (MemoryFilesystem::Entry const &child : entry->children()) {
|
for (MemoryFilesystem::Entry const &child : entry->children()) {
|
||||||
std::string path = (subpath ? *subpath + "/" + child.name() : child.name());
|
std::string path = (subpath ? *subpath + "/" + child.name() : child.name());
|
||||||
cb(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process subdirectories. */
|
/* Process subdirectories first. */
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
for (MemoryFilesystem::Entry const &child : entry->children()) {
|
process(path, &child);
|
||||||
if (child.type() == Type::Directory) {
|
|
||||||
std::string path = (subpath ? *subpath + "/" + child.name() : child.name());
|
|
||||||
process(path, &child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cb(path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ TEST(MemoryFilesystem, ReadDirectory)
|
|||||||
/* List root contents, recursive. */
|
/* List root contents, recursive. */
|
||||||
files.clear();
|
files.clear();
|
||||||
EXPECT_TRUE(filesystem.readDirectory("/", true, accumulate));
|
EXPECT_TRUE(filesystem.readDirectory("/", true, accumulate));
|
||||||
EXPECT_EQ(files, std::vector<std::string>({ "file1", "dir1", "dir2", "dir1/file2", "dir2/file2", "dir2/dir3" }));
|
EXPECT_EQ(files, std::vector<std::string>({ "file1", "dir1/file2", "dir1", "dir2/file2", "dir2/dir3", "dir2" }));
|
||||||
|
|
||||||
/* List file. */
|
/* List file. */
|
||||||
files.clear();
|
files.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user