Skip to content

Commit c2b0624

Browse files
committed
Test application: --exclude=... didn't work.
1 parent ab56f93 commit c2b0624

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Test/test.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ static bool IsFileExcluded(const char* filename)
114114
return false;
115115
}
116116

117-
static bool ScanDirectory(const char *dir, bool recurse = true)
117+
static bool ScanDirectory(const char *dir, bool recurse = true, int baseDirLen = -1)
118118
{
119119
char Path[1024];
120120
bool res = true;
121121
// printf("Scan %s\n", dir);
122+
if (baseDirLen < 0)
123+
baseDirLen = strlen(dir) + 1;
124+
122125
#if _WIN32
123126
sprintf(Path, "%s/*.*", dir);
124127
_finddatai64_t found;
@@ -128,12 +131,12 @@ static bool ScanDirectory(const char *dir, bool recurse = true)
128131
{
129132
if (found.name[0] == '.') continue; // "." or ".."
130133
sprintf(Path, "%s/%s", dir, found.name);
131-
if (IsFileExcluded(Path)) continue;
134+
if (IsFileExcluded(Path + baseDirLen)) continue;
132135
// directory -> recurse
133136
if (found.attrib & _A_SUBDIR)
134137
{
135138
if (recurse)
136-
res = ScanDirectory(Path, recurse);
139+
res = ScanDirectory(Path, recurse, baseDirLen);
137140
else
138141
res = true;
139142
}
@@ -152,15 +155,15 @@ static bool ScanDirectory(const char *dir, bool recurse = true)
152155
{
153156
if (ent->d_name[0] == '.') continue; // "." or ".."
154157
sprintf(Path, "%s/%s", dir, ent->d_name);
155-
if (IsFileExcluded(Path)) continue;
158+
if (IsFileExcluded(Path + baseDirLen)) continue;
156159
// directory -> recurse
157160
// note: using 'stat64' here because 'stat' ignores large files
158161
struct stat64 buf;
159162
if (stat64(Path, &buf) < 0) continue; // or break?
160163
if (S_ISDIR(buf.st_mode))
161164
{
162165
if (recurse)
163-
res = ScanDirectory(Path, recurse);
166+
res = ScanDirectory(Path, recurse, baseDirLen);
164167
else
165168
res = true;
166169
}

0 commit comments

Comments
 (0)