OpenTTD Source  20241108-master-g80f628063a
TarScanner Class Reference

Helper for scanning for files with tar as extension. More...

#include <fileio_func.h>

Inheritance diagram for TarScanner:
FileScanner

Public Types

enum  Mode {
  NONE = 0 , BASESET = 1 << 0 , NEWGRF = 1 << 1 , AI = 1 << 2 ,
  SCENARIO = 1 << 3 , GAME = 1 << 4 , ALL = BASESET | NEWGRF | AI | SCENARIO | GAME
}
 The mode of tar scanning. More...
 

Public Member Functions

bool AddFile (const std::string &filename, size_t basepath_length, const std::string &tar_filename={}) override
 Add a file with the given filename. More...
 
bool AddFile (Subdirectory sd, const std::string &filename)
 Add a single file to the scanned files of a tar, circumventing the scanning code. More...
 

Static Public Member Functions

static uint DoScan (TarScanner::Mode mode)
 Do the scan for Tars.
 

Private Member Functions

uint DoScan (Subdirectory sd)
 Perform the scanning of a particular subdirectory. More...
 
- Private Member Functions inherited from FileScanner
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. More...
 
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. More...
 

Additional Inherited Members

- Private Attributes inherited from FileScanner
Subdirectory subdir
 The current sub directory we are searching through.
 

Detailed Description

Helper for scanning for files with tar as extension.

Definition at line 59 of file fileio_func.h.

Member Enumeration Documentation

◆ Mode

The mode of tar scanning.

Enumerator
NONE 

Scan nothing.

BASESET 

Scan for base sets.

NEWGRF 

Scan for non-base sets.

AI 

Scan for AIs and its libraries.

SCENARIO 

Scan for scenarios and heightmaps.

GAME 

Scan for game scripts.

ALL 

Scan for everything.

Definition at line 63 of file fileio_func.h.

Member Function Documentation

◆ AddFile() [1/2]

bool TarScanner::AddFile ( const std::string &  filename,
size_t  basepath_length,
const std::string &  tar_filename = {} 
)
overridevirtual

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.

Implements FileScanner.

Referenced by AddFile().

◆ AddFile() [2/2]

bool TarScanner::AddFile ( Subdirectory  sd,
const std::string &  filename 
)

Add a single file to the scanned files of a tar, circumventing the scanning code.

Parameters
sdThe sub directory the file is in.
filenameThe name of the file to add.
Returns
True if the additions went correctly.

Definition at line 417 of file fileio.cpp.

References AddFile().

◆ DoScan()

uint TarScanner::DoScan ( Subdirectory  sd)
private

Perform the scanning of a particular subdirectory.

Parameters
sdThe subdirectory to scan.
Returns
The number of found tar files.

Definition at line 375 of file fileio.cpp.

Referenced by DoScan(), DoScanNewGRFFiles(), AI::Initialize(), Game::Initialize(), AfterNewGRFScan::OnNewGRFsScanned(), and AI::Rescan().


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