29 using namespace pwiz::util;
30 using boost::system::error_code;
31 using boost::system::system_category;
32 using boost::system::system_error;
34 #if (BOOST_VERSION/100) >= 1044
35 # define SYSTEMCATEGORY system_category()
36 #else // exported library symbol used to be a global variable, now its a function. Okeedokee, then.
37 # define SYSTEMCATEGORY system_category
43 # define ABS "%SD%\\" // test at %SystemDrive% because FindFile behaves a little tricky there
44 # define REL ".\\relative"
45 # define A "\\" // both slash types should work
46 # define D ";" // path separator
48 # define ABS "./" // POSIX filesystems don't have the same problem,
49 # define REL "./relative" // so all tests are relative (avoids permission issues)
57 return bal::replace_all_copy(path,
"%SD%",
systemDrive);
63 ABS"pwiz_foofoo_test",
"root file",
64 ABS"pwiz_foo_test",
"",
65 ABS
"pwiz_foo_test"A"this file",
"has content",
66 ABS
"pwiz_foo_test"A
"this dir has",
"",
67 ABS
"pwiz_foo_test"A
"this dir has"A
"a test file",
"with content",
68 ABS
"pwiz_bar_test",
"",
69 ABS
"pwiz_bar_test"A
"some file",
"12345",
70 ABS
"pwiz_bar_test"A
"some dir",
"",
72 REL"pwiz_foofoo_test",
"root file",
73 REL
"pwiz_foo_test",
"",
74 REL
"pwiz_foo_test"A
"this file",
"has content",
75 REL
"pwiz_foo_test"A
"this dir has",
"",
76 REL
"pwiz_foo_test"A
"this dir has"A
"a test file",
"with content",
77 REL
"pwiz_bar_test",
"",
78 REL
"pwiz_bar_test"A
"some file",
"12345",
79 REL
"pwiz_bar_test"A
"some dir",
""
95 {
ABS"pwiz_f??f??_test",
ABS"pwiz_foofoo_test" },
96 {
ABS"pwiz_???_test",
ABS"pwiz_foo_test"D ABS"pwiz_bar_test" },
97 {
ABS"pwiz_f*o_test",
ABS"pwiz_foo_test"D ABS"pwiz_foofoo_test" },
98 {
ABS"pwiz_foobar_test",
"" },
99 {
ABS"pwiz_foo_test"A"no*hit",
"" },
100 {
ABS"pwiz_foo_test"A"*",
ABS"pwiz_foo_test"A
"this file"D ABS"pwiz_foo_test"A
"this dir has" },
101 {
ABS"pwiz_foo_test"A"this *",
ABS"pwiz_foo_test"A
"this file"D ABS"pwiz_foo_test"A
"this dir has" },
103 {
REL"pwiz_f??f??_test",
REL"pwiz_foofoo_test" },
104 {
REL"pwiz_???_test",
REL"pwiz_foo_test"D REL"pwiz_bar_test" },
105 {
REL"pwiz_f*o_test",
REL"pwiz_foo_test"D REL"pwiz_foofoo_test" },
106 {
REL"pwiz_foobar_test",
"" },
107 {
REL"pwiz_foo_test"A"no*hit",
"" },
108 {
REL"pwiz_foo_test"A"*",
REL"pwiz_foo_test"A
"this file"D REL"pwiz_foo_test"A
"this dir has" },
109 {
REL"pwiz_foo_test"A"this *",
REL"pwiz_foo_test"A
"this file"D REL"pwiz_foo_test"A
"this dir has" }
118 ofstream f(ph.string().c_str());
120 throw bfs::filesystem_error(
"create_file", ph, error_code(errno,
SYSTEMCATEGORY));
121 if (!contents.empty()) f << contents;
151 set<bfs::path> pathSet;
152 vector<string> tokens;
153 bal::split(tokens, pathArray, bal::is_any_of(
D));
154 if (!tokens.empty() && !tokens[0].empty())
155 for (
size_t i=0; i < tokens.size(); ++i)
163 char* systemDriveEnv = ::getenv(
"SystemDrive");
174 vector<bfs::path> matchingPaths;
178 unit_assert(matchingPaths.size() == targetPathSet.size());
180 set<bfs::path> matchingPathSet(matchingPaths.begin(), matchingPaths.end());
181 vector<bfs::path> xorSet;
182 std::set_symmetric_difference(targetPathSet.begin(), targetPathSet.end(),
183 matchingPathSet.begin(), matchingPathSet.end(),
195 vector<bfs::path> matchingPaths;
234 int main(
int argc,
const char* argv[])