OpenTTD Source: TarScanner Class Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
TarScanner Class Reference

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

`#include <fileio_func.h>`

Inheritance diagram for TarScanner:

## Public Types
enum class | Mode : uint8_t { Baseset , NewGRF , AI , Scenario , Game }
| The mode of tar scanning. More...
using | Modes = EnumBitSet< Mode, uint8_t >

## 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.
bool | AddFile (Subdirectory sd, const std::string &filename)
| Add a single file to the scanned files of a tar, circumventing the scanning code.

## Static Public Member Functions
static uint | DoScan (TarScanner::Modes modes)
| Do the scan for Tars.

## Static Public Attributes
static constexpr Modes | MODES_ALL = {Mode::Baseset, Mode::NewGRF, Mode::AI, Mode::Scenario, Mode::Game}
| Scan for everything.

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

## 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 Typedef Documentation

## ◆ Modes

using TarScanner::Modes = EnumBitSet<Mode, uint8_t>

Definition at line 70 of file fileio_func.h.

## Member Enumeration Documentation

## ◆ Mode

enum class TarScanner::Mode : uint8_t
| strong

The mode of tar scanning.

Enumerator
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.

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

  filename | the full path to the file to read
  basepath_length | amount of characters to chop of before to get a filename relative to the search path.
  tar_filename | the name of the tar file the file is read from.

Returns
  true if the file is added.

< Name of the file

< Size of the file, in ASCII octals

< Path of the file

Implements FileScanner.

Definition at line 440 of file fileio.cpp.

References Align(), Debug, ExtractString(), FS2OTTD(), FileHandle::Open(), OTTD2FS(), SimplifyFileName(), and FileScanner::subdir.

Referenced by AddFile(), and ClientNetworkContentSocketHandler::AfterDownload().

## ◆ 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

  sd | The sub directory the file is in.
  filename | The name of the file to add.

Returns
  True if the additions went correctly.

Definition at line 419 of file fileio.cpp.

References AddFile().

## ◆ DoScan() [1/2]

uint TarScanner::DoScan | ( | Subdirectory | sd | ) |
| private

Perform the scanning of a particular subdirectory.

Parameters

  sd | The subdirectory to scan.

Returns
  The number of found tar files.

Definition at line 377 of file fileio.cpp.

References BASESET_DIR, NEWGRF_DIR, OLD_DATA_DIR, and FileScanner::Scan().

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

## ◆ DoScan() [2/2]

uint TarScanner::DoScan | ( | TarScanner::Modes | modes | ) |
| static

Do the scan for Tars.

Definition at line 386 of file fileio.cpp.

References AI, AI_DIR, AI_LIBRARY_DIR, Baseset, BASESET_DIR, Debug, DoScan(), Game, GAME_DIR, GAME_LIBRARY_DIR, HEIGHTMAP_DIR, NewGRF, NEWGRF_DIR, Scenario, SCENARIO_DIR, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## Field Documentation

## ◆ MODES_ALL

constexpr Modes TarScanner::MODES_ALL = {Mode::Baseset, Mode::NewGRF, Mode::AI, Mode::Scenario, Mode::Game}
| staticconstexpr

Scan for everything.

Definition at line 72 of file fileio_func.h.

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

- src/fileio_func.h
- src/fileio.cpp