blob: a3dd738e28ad4836686616db9dc6f7979e2b3fea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
Fix wildcard expansion of non-regular files.
Patch by Bardur Arantsson.
http://bugs.gentoo.org/51817
http://sourceforge.net/tracker/index.php?func=detail&aid=958902&group_id=30568&atid=399698
--- par2cmdline-0.4/diskfile.cpp
+++ par2cmdline-0.4/diskfile.cpp
@@ -618,6 +618,12 @@
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> *matches = new list<string>;
@@ -648,7 +654,15 @@
name.substr(0, where) == front &&
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
@@ -667,7 +681,15 @@
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;
+ }
}
}
}
@@ -678,12 +700,15 @@
}
else
{
- struct stat st;
- string fn = path + wildcard;
- if (stat(fn.c_str(), &st) == 0)
+ if (is_regular_file(path + wildcard))
{
matches->push_back(path + wildcard);
}
+ else
+ {
+ cerr << "Warning: '" << (path + wildcard)
+ << "' ignored; not a regular file" << endl;
+ }
}
return matches;
|