# 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)
| Scan for files with the given extention in the given search path.
uint | Scan (const char *extension, const char *directory)
| Scan for files with the given extention in the given search path.
virtual bool | AddFile (const char *filename, size_t basepath_length)=0
| Add a file with the given filename.

## Detailed Description

Helper for scanning for files with a given name.

Definition at line 70 of file fileio_func.h.

## Constructor & Destructor Documentation

virtual FileScanner::~FileScanner | ( |  | ) | `[inline, virtual]`

Destruct the proper one.

..

Definition at line 74 of file fileio_func.h.

## Member Function Documentation

uint FileScanner::Scan | ( | const char * | extension,
|  | Subdirectory | sd,
|  | bool | tars = `true` |
| ) |  |  |

Scan for files with the given extention 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.

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

Definition at line 1097 of file fileio.cpp.

References FOR_ALL_SEARCHPATHS, ScanPath(), and ScanTar().

Referenced by GRFFileScanner::DoScan(), and OBGFileScanner::DoScan().

uint FileScanner::Scan | ( | const char * | extension,
|  | const char * | directory |
| ) |  |  |

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

Parameters:

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

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

Definition at line 1125 of file fileio.cpp.

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

virtual bool FileScanner::AddFile | ( | const char * | filename,
|  | size_t | basepath_length |
| ) |  |  | `[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.

Returns:
  true if the file is added.

Implemented in OBGFileScanner, and GRFFileScanner.

Referenced by ScanPath(), and ScanTar().

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

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