Fixed a bug that would prevent single files from showing up in wildcard resolutions

This commit is contained in:
Mitchell Grenier 2015-04-06 15:21:17 -07:00
parent a94bff9ebf
commit a6a8cc596b
2 changed files with 13 additions and 1 deletions

View File

@ -281,7 +281,8 @@ Status resolveLastPathComponent(const fs::path& fs_path,
try {
// Is the path a file
if (setting == REC_LIST_FILES && fs::is_regular_file(fs_path)) {
if ((setting & (REC_EVENT_OPT | REC_LIST_FILES)) > 0 &&
fs::is_regular_file(fs_path)) {
results.push_back(fs_path.string());
return Status(0, "OK");
}

View File

@ -232,6 +232,17 @@ TEST_F(FilesystemTests, test_dotdot_relative) {
EXPECT_TRUE(found);
}
TEST_F(FilesystemTests, test_no_wild) {
std::vector<std::string> all;
auto status = resolveFilePattern(kFakeDirectory + "/roto.txt",
all, REC_LIST_FILES);
EXPECT_TRUE(status.ok());
EXPECT_EQ(all.size(), 1);
EXPECT_NE(std::find(all.begin(), all.end(),
kFakeDirectory + "/roto.txt"),
all.end());
}
TEST_F(FilesystemTests, test_safe_permissions) {
// For testing we can request a different directory path.
EXPECT_TRUE(safePermissions("/", kFakeDirectory + "/door.txt"));