- use ScanDirectory in all places where the findfile API was used.
This allows to completely hide its implementation details from the rest of the code which only gets a list of file names now.
This commit is contained in:
parent
566a8f58a7
commit
5f3d25ef44
15 changed files with 262 additions and 675 deletions
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
#include "cmdlib.h"
|
||||
#include "findfile.h"
|
||||
#include "fs_findfile.h"
|
||||
#include "files.h"
|
||||
#include "md5.h"
|
||||
|
||||
|
|
@ -894,68 +894,6 @@ FString NicePath(const char *path)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ScanDirectory
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool ScanDirectory(TArray<FFileList> &list, const char *dirpath)
|
||||
{
|
||||
findstate_t find;
|
||||
FString dirmatch;
|
||||
|
||||
dirmatch << dirpath << "*";
|
||||
|
||||
auto handle = I_FindFirst(dirmatch.GetChars(), &find);
|
||||
if (handle == ((void*)(-1)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
auto attr = I_FindAttr(&find);
|
||||
if (attr & FA_HIDDEN)
|
||||
{
|
||||
// Skip hidden files and directories. (Prevents SVN bookkeeping
|
||||
// info from being included.)
|
||||
continue;
|
||||
}
|
||||
auto fn = I_FindName(&find);
|
||||
|
||||
if (attr & FA_DIREC)
|
||||
{
|
||||
if (fn[0] == '.' &&
|
||||
(fn[1] == '\0' ||
|
||||
(fn[1] == '.' && fn[2] == '\0')))
|
||||
{
|
||||
// Do not record . and .. directories.
|
||||
continue;
|
||||
}
|
||||
|
||||
FFileList* fl = &list[list.Reserve(1)];
|
||||
fl->Filename << dirpath << fn;
|
||||
fl->isDirectory = true;
|
||||
FString newdir = fl->Filename;
|
||||
newdir << "/";
|
||||
ScanDirectory(list, newdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
FFileList* fl = &list[list.Reserve(1)];
|
||||
fl->Filename << dirpath << fn;
|
||||
fl->isDirectory = false;
|
||||
}
|
||||
}
|
||||
while (I_FindNext(handle, &find) == 0);
|
||||
I_FindClose(handle);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue