OpenTTD: FileScanner Class Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Protected Attributes
FileScanner Class Reference

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

`#include <fileio_func.h>`

Inheritance diagram for FileScanner:

## Public Member Functions
virtual | ~FileScanner ()
| 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.
uint | Scan (const char *extension, const char *directory, bool recursive=true)
| Scan for files with the given extension in the given search path.
virtual bool | AddFile (const char *filename, size_t basepath_length, const char *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 73 of file fileio_func.h.

## Constructor & Destructor Documentation

virtual FileScanner::~FileScanner | ( |  | ) |
| inlinevirtual

Destruct the proper one...

Definition at line 78 of file fileio_func.h.

## Member Function Documentation

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

  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, FiosFileScanner, LanguageScanner, ScriptFileChecksumCreator, and ScriptScanner.

Referenced by ScanPath(), and ScanTar().

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 1454 of file fileio.cpp.

References _do_scan_working_directory, BASESET_DIR, FOR_ALL_SEARCHPATHS, lastof, NEWGRF_DIR, NO_DIRECTORY, OLD_DATA_DIR, OLD_GM_DIR, ScanPath(), ScanTar(), and SP_WORKING_DIR.

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

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

  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 1499 of file fileio.cpp.

References AppendPathSeparator(), lastof, ScanPath(), and strecpy().

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

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