OpenTTD
Public Member Functions | Protected Attributes
FileScanner Class Referenceabstract

Helper for scanning for files with a given name. More...

#include <fileio_func.h>

Inheritance diagram for FileScanner:
BaseMedia< Tbase_set > BaseMedia< GraphicsSet > BaseMedia< MusicSet > BaseMedia< SoundsSet > FiosFileScanner GRFFileScanner LanguageScanner ScenarioScanner ScriptFileChecksumCreator ScriptScanner TarScanner

Public Member Functions

virtual ~FileScanner ()
 Destruct the proper one... More...
 
uint Scan (const char *extension, Subdirectory sd, bool tars=true, bool recursive=true)
 Scan for files with the given extension in the given search path. More...
 
uint Scan (const char *extension, const char *directory, bool recursive=true)
 Scan for files with the given extension in the given search path. More...
 
virtual bool AddFile (const char *filename, size_t basepath_length, const char *tar_filename)=0
 Add a file with the given filename. More...
 

Protected Attributes

Subdirectory subdir
 The current sub directory we are searching through.
 

Detailed Description

Helper for scanning for files with a given name.

Definition at line 73 of file fileio_func.h.

Constructor & Destructor Documentation

◆ ~FileScanner()

virtual FileScanner::~FileScanner ( )
inlinevirtual

Destruct the proper one...

Definition at line 78 of file fileio_func.h.

References AddFile(), and Scan().

Member Function Documentation

◆ AddFile()

virtual bool FileScanner::AddFile ( const char *  filename,
size_t  basepath_length,
const char *  tar_filename 
)
pure virtual

Add a file with the given filename.

Parameters
filenamethe full path to the file to read
basepath_lengthamount of characters to chop of before to get a filename relative to the search path.
tar_filenamethe name of the tar file the file is read from.
Returns
true if the file is added.

Implemented in ScenarioScanner, GRFFileScanner, FiosFileScanner, LanguageScanner, ScriptFileChecksumCreator, BaseMedia< Tbase_set >, BaseMedia< SoundsSet >, BaseMedia< MusicSet >, BaseMedia< GraphicsSet >, TarScanner, and ScriptScanner.

Referenced by ScanTar(), and ~FileScanner().

◆ Scan() [1/2]

uint FileScanner::Scan ( const char *  extension,
Subdirectory  sd,
bool  tars = true,
bool  recursive = true 
)

Scan for files with the given extension in the given search path.

Parameters
extensionthe extension of files to search for.
sdthe sub directory to search in.
tarswhether to search in the tars too.
recursivewhether to search recursively
Returns
the number of found files, i.e. the number of times that AddFile returned true.

Definition at line 1428 of file fileio.cpp.

Referenced by GRFFileScanner::DoScan(), BaseMedia< GraphicsSet >::FindSets(), ScriptScanner::RescanDir(), LanguageScanner::Scan(), ScenarioScanner::Scan(), and ~FileScanner().

◆ Scan() [2/2]

uint FileScanner::Scan ( const char *  extension,
const char *  directory,
bool  recursive = true 
)

Scan for files with the given extension in the given search path.

Parameters
extensionthe extension of files to search for.
directorythe sub directory to search in.
recursivewhether to search recursively
Returns
the number of found files, i.e. the number of times that AddFile returned true.

Definition at line 1473 of file fileio.cpp.


The documentation for this class was generated from the following files: