Merge pull request #949 from jedi22/file_changes_paths_single_file_fix

[Fix #948] Absolute paths in wildcard resolution
This commit is contained in:
Mitchell Grenier 2015-04-06 15:48:51 -07:00
commit 1455b66dd0
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"));