@@ -114,11 +114,14 @@ static bool IsFileExcluded(const char* filename)
114
114
return false ;
115
115
}
116
116
117
- static bool ScanDirectory (const char *dir, bool recurse = true )
117
+ static bool ScanDirectory (const char *dir, bool recurse = true , int baseDirLen = - 1 )
118
118
{
119
119
char Path[1024 ];
120
120
bool res = true ;
121
121
// printf("Scan %s\n", dir);
122
+ if (baseDirLen < 0 )
123
+ baseDirLen = strlen (dir) + 1 ;
124
+
122
125
#if _WIN32
123
126
sprintf (Path, " %s/*.*" , dir);
124
127
_finddatai64_t found;
@@ -128,12 +131,12 @@ static bool ScanDirectory(const char *dir, bool recurse = true)
128
131
{
129
132
if (found.name [0 ] == ' .' ) continue ; // "." or ".."
130
133
sprintf (Path, " %s/%s" , dir, found.name );
131
- if (IsFileExcluded (Path)) continue ;
134
+ if (IsFileExcluded (Path + baseDirLen )) continue ;
132
135
// directory -> recurse
133
136
if (found.attrib & _A_SUBDIR)
134
137
{
135
138
if (recurse)
136
- res = ScanDirectory (Path, recurse);
139
+ res = ScanDirectory (Path, recurse, baseDirLen );
137
140
else
138
141
res = true ;
139
142
}
@@ -152,15 +155,15 @@ static bool ScanDirectory(const char *dir, bool recurse = true)
152
155
{
153
156
if (ent->d_name [0 ] == ' .' ) continue ; // "." or ".."
154
157
sprintf (Path, " %s/%s" , dir, ent->d_name );
155
- if (IsFileExcluded (Path)) continue ;
158
+ if (IsFileExcluded (Path + baseDirLen )) continue ;
156
159
// directory -> recurse
157
160
// note: using 'stat64' here because 'stat' ignores large files
158
161
struct stat64 buf;
159
162
if (stat64 (Path, &buf) < 0 ) continue ; // or break?
160
163
if (S_ISDIR (buf.st_mode ))
161
164
{
162
165
if (recurse)
163
- res = ScanDirectory (Path, recurse);
166
+ res = ScanDirectory (Path, recurse, baseDirLen );
164
167
else
165
168
res = true ;
166
169
}
0 commit comments