OpenTTD Source: FileScanner Class Reference

OpenTTD Source 14.0-beta1

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:

## Public Member Functions
virtual | ~FileScanner ()=default
| Destruct the proper one...
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 std::string &directory, bool recursive=true)
| Scan for files with the given extension in the given search path. More...
virtual bool | AddFile (const std::string &filename, size_t basepath_length, const std::string &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 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

  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.

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

Referenced by ScanTar().

## ◆ Scan() [1/2]

uint FileScanner::Scan | ( | const char * | extension,
|  | const std::string & | directory,
|  | bool | recursive = `true`
| ) |  |

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

Parameters

  extension | the extension of files to search for.
  directory | the sub directory to search in.
  recursive | whether to search recursively

Returns
  the number of found files, i.e. the number of times that AddFile returned true.

Definition at line 1252 of file fileio.cpp.

References AppendPathSeparator(), and ScanPath().

## ◆ Scan() [2/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

  extension | the extension of files to search for.
  sd | the sub directory to search in.
  tars | whether to search in the tars too.
  recursive | whether to search recursively

Returns
  the number of found files, i.e. the number of times that AddFile returned true.

Definition at line 1210 of file fileio.cpp.

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

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

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