OpenTTD Source 20241224-master-gee860a5c8e
FileScanner Class Referenceabstract

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

#include <fileio_func.h>

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

Public Member Functions

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

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 37 of file fileio_func.h.

Member Function Documentation

◆ AddFile()

virtual bool FileScanner::AddFile ( const std::string &  filename,
size_t  basepath_length,
const std::string &  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 SocialIntegrationFileScanner, BaseMedia< Tbase_set >, BaseMedia< GraphicsSet >, BaseMedia< MusicSet >, BaseMedia< SoundsSet >, FiosFileScanner, GRFFileScanner, ScriptScanner, TarScanner, ScenarioScanner, LanguageScanner, and ScriptFileChecksumCreator.

Referenced by ScanPath(), and ScanTar().

◆ Scan() [1/2]

uint FileScanner::Scan ( std::string_view  extension,
const std::string &  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 1156 of file fileio.cpp.

References AppendPathSeparator(), OTTD2FS(), and ScanPath().

◆ Scan() [2/2]

uint FileScanner::Scan ( std::string_view  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 1114 of file fileio.cpp.

References _do_scan_working_directory, BASESET_DIR, NEWGRF_DIR, NO_DIRECTORY, OLD_DATA_DIR, OLD_GM_DIR, OTTD2FS(), Scan(), ScanPath(), ScanTar(), and SP_WORKING_DIR.

Referenced by GRFFileScanner::DoScan(), TarScanner::DoScan(), BaseMedia< Tbase_set >::FindSets(), FiosGetFileList(), FiosNumberedSaveName::FiosNumberedSaveName(), IsSameScript(), ScriptScanner::RescanDir(), ScenarioScanner::Scan(), LanguageScanner::Scan(), and Scan().

Field Documentation

◆ subdir

Subdirectory FileScanner::subdir
protected

The current sub directory we are searching through.

Definition at line 39 of file fileio_func.h.

Referenced by ScriptScanner::AddFile(), and TarScanner::AddFile().


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