|
|
return result; | return result; |
} | } |
| |
|
bool is_regular_file(const string &p) |
|
{ |
|
struct stat st; |
|
return (stat(p.c_str(), &st) == 0 && S_ISREG(st.st_mode)); |
|
} |
|
|
list<string>* DiskFile::FindFiles(string path, string wildcard) | list<string>* DiskFile::FindFiles(string path, string wildcard) |
{ | { |
list<string> *matches = new list<string>; | list<string> *matches = new list<string>; |
|
|
name.substr(0, where) == front && | name.substr(0, where) == front && |
name.substr(name.size()-back.size()) == back) | name.substr(name.size()-back.size()) == back) |
{ | { |
matches->push_back(path + name); |
if (is_regular_file(path + name)) |
|
{ |
|
matches->push_back(path + name); |
|
} |
|
else |
|
{ |
|
cerr << "Warning: '" << (path + name) |
|
<< "' ignored; not a regular file" << endl; |
|
} |
} | } |
} | } |
else | else |
|
|
| |
if (pw == wildcard.end()) | if (pw == wildcard.end()) |
{ | { |
matches->push_back(path + name); |
if (is_regular_file(path + name)) |
|
{ |
|
matches->push_back(path + name); |
|
} |
|
else |
|
{ |
|
cerr << "Warning: '" << (path + name) |
|
<< "' ignored; not a regular file" << endl; |
|
} |
} | } |
} | } |
} | } |
|
|
} | } |
else | else |
{ | { |
struct stat st; |
if (is_regular_file(path + wildcard)) |
string fn = path + wildcard; |
|
if (stat(fn.c_str(), &st) == 0) |
|
{ | { |
matches->push_back(path + wildcard); | matches->push_back(path + wildcard); |
} | } |
|
else |
|
{ |
|
cerr << "Warning: '" << (path + wildcard) |
|
<< "' ignored; not a regular file" << endl; |
|
} |
} | } |
| |
return matches; | return matches; |