# Filename

from pandac.PandaModules import Filename

Class : Filename
Description : The name of a file, such as a texture file or an Egg file. Stores the full pathname, and includes functions for extracting out the directory prefix part and the file extension and stuff.
A Filename is also aware of the mapping between the Unix-like filename convention we use internally, and the local OS's specific filename convention, and it knows how to perform basic OS-specific I/O, like testing for file existence and searching a searchpath, as well as the best way to open an fstream for reading or writing.

## Inheritance:

Filename:

## Methods of Filename:

binaryFilename
chdir
compareTimestamps
cStr
dsoFilename
empty
executableFilename
exists
expandFrom
extractComponents
findOnSearchpath
fromOsSpecific
getAccessTimestamp
getBasename
getBasenameWoExtension
getDirname
getExtension
getFilenameIndex
getFileSize
getFullpath
getFullpathWoExtension
getHashToEnd
getPattern
getTimestamp
getType
hasHash
isBinary
isDirectory
isExecutable
isFullyQualified
isLocal
isRegularFile
isText
length
makeAbsolute
makeCanonical
makeDir
makeRelativeTo
makeTrueCase
openAppend
openRead
openReadWrite
openWrite
operator !=
operator <
operator =
operator ==
operator []
output
patternFilename
renameTo
resolveFilename
scanDirectory
setBasename
setBasenameWoExtension
setBinary
setDirname
setExtension
setFullpath
setFullpathWoExtension
setHashToEnd
setPattern
setText
setType
standardize
substr
temporary
textFilename
toOsGeneric
toOsSpecific
touch
unlink

## Constants in Filename:

TGeneral | (Type)
TDso | (Type)
TExecutable | (Type)

binaryFilename static Filename Filename::binary_filename(string const &filename); Static constructors to explicitly create a filename that refers to a text or binary file. This is in lieu of calling set_text() or set_binary() or set_type(). Description:

chdir bool Filename::chdir(void) const; Undocumented function.

compareTimestamps int Filename::compare_timestamps(Filename const &other, bool this_missing_is_old = (1), bool other_missing_is_old = (1)) const; Undocumented function.

cStr char const *Filename::c_str(void) const; And retrieval is by any of the classic string operations. Description:

dsoFilename static Filename Filename::dso_filename(string const &filename); Description:

empty bool Filename::empty(void) const; Description:

executableFilename static Filename Filename::executable_filename(string const &filename); Description:

exists bool Filename::exists(void) const; Undocumented function.

expandFrom static Filename Filename::expand_from(string const &user_string, Filename::Type type = (T_general)); Undocumented function.

extractComponents void Filename::extract_components(vector< string > &components) const; Undocumented function.

findOnSearchpath int Filename::find_on_searchpath(DSearchPath const &searchpath); Undocumented function.

fromOsSpecific static Filename Filename::from_os_specific(string const &os_specific, Filename::Type type = (T_general)); Undocumented function.

getAccessTimestamp unsigned int Filename::get_access_timestamp(void) const; Undocumented function.

getBasename string Filename::get_basename(void) const; Description: Returns the basename part of the filename. This is everything in the filename after the rightmost slash, including any extensions.

getBasenameWoExtension string Filename::get_basename_wo_extension(void) const; Description: Returns the basename part of the filename, without the file extension.

getDirname string Filename::get_dirname(void) const; Or, you can use any of these. Description: Returns the directory part of the filename. This is everything in the filename up to, but not including the rightmost slash.

getExtension string Filename::get_extension(void) const; Description: Returns the file extension. This is everything after the rightmost dot, if there is one, or the empty string if there is not.

getFilenameIndex Filename Filename::get_filename_index(int index) const; Undocumented function.

getFileSize int Filename::get_file_size(void) const; Undocumented function.

getFullpath string Filename::get_fullpath(void) const; Or, you can use any of these. Description: Returns the entire filename: directory, basename, extension. This is the same thing returned by the string typecast operator, so this function is a little redundant.

getFullpathWoExtension string Filename::get_fullpath_wo_extension(void) const; Description: Returns the full filename--directory and basename parts--except for the extension.

getHashToEnd string Filename::get_hash_to_end(void) const; Description: Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end of the filename.

getPattern bool Filename::get_pattern(void) const; Description: Returns the flag indicating whether this is a filename pattern. See set_pattern().

getTimestamp unsigned int Filename::get_timestamp(void) const; Undocumented function.

getType Filename::Type Filename::get_type(void) const; Description: Returns the type of the file represented by the filename, as previously set by set_type().

hasHash bool Filename::has_hash(void) const; Description: Returns true if the filename is indicated to be a filename pattern (that is, set_pattern(true) was called), and the filename pattern did include a sequence of hash marks, or false if it was not a filename pattern or did not include hash marks. If this is true, then get_filename_index() will return a different filename each time.

isBinary bool Filename::is_binary(void) const; Description: Returns true if the Filename has been indicated to represent a binary file via a previous call to set_binary(). It is possible that neither is_binary() nor is_text() will be true, if neither set_binary() nor set_text() was ever called.

isDirectory bool Filename::is_directory(void) const; Undocumented function.

isExecutable bool Filename::is_executable(void) const; Undocumented function.

isFullyQualified bool Filename::is_fully_qualified(void) const; Description: Returns true if the filename is fully qualified, e.g. begins with a slash. This is almost, but not quite, the same thing as !is_local(). It's not exactly the same because a special case is made for filenames that begin with a single dot followed by a slash--these are considered to be fully qualified (they are explicitly relative to the current directory, and do not refer to a filename on a search path somewhere).

isLocal bool Filename::is_local(void) const; The following functions deal with the outside world. Description: Returns true if the filename is local, e.g. does not begin with a slash, or false if the filename is fully specified from the root.

isRegularFile bool Filename::is_regular_file(void) const; Undocumented function.

isText bool Filename::is_text(void) const; Description: Returns true if the Filename has been indicated to represent a text file via a previous call to set_text(). It is possible that neither is_binary() nor is_text() will be true, if neither set_binary() nor set_text() was ever called.

length unsigned int Filename::length(void) const; Description:

makeAbsolute void Filename::make_absolute(void); Undocumented function.

makeCanonical bool Filename::make_canonical(void); Undocumented function.

makeDir bool Filename::make_dir(void) const; Undocumented function.

makeRelativeTo bool Filename::make_relative_to(Filename directory, bool allow_backups = (1)); Undocumented function.

makeTrueCase bool Filename::make_true_case(void); Undocumented function.

openAppend bool Filename::open_append(ofstream &stream) const; Undocumented function.

openRead bool Filename::open_read(ifstream &stream) const; Undocumented function.

openReadWrite bool Filename::open_read_write(fstream &stream) const; Undocumented function.

openWrite bool Filename::open_write(ofstream &stream, bool truncate = (1)) const; Undocumented function.

operator != bool Filename::operator !=(string const &other) const; Comparison operators are handy. Description:

operator < bool Filename::operator <(string const &other) const; Description:

operator = Filename &Filename::operator =(string const &filename); Assignment is via the = operator. Description:

operator == bool Filename::operator ==(string const &other) const; Comparison operators are handy. Description:

operator [] char Filename::operator [](int n) const; Description:

output void Filename::output(ostream &out) const; Description:

patternFilename static Filename Filename::pattern_filename(string const &filename); Description: Constructs a filename that represents a sequence of numbered files. See set_pattern().

renameTo bool Filename::rename_to(Filename const &other) const; Undocumented function.

resolveFilename bool Filename::resolve_filename(DSearchPath const &searchpath, string const &default_extension = ((string()))); Undocumented function.

scanDirectory bool Filename::scan_directory(vector< string > &contents) const; Undocumented function.

setBasename void Filename::set_basename(string const &s); Undocumented function.

setBasenameWoExtension void Filename::set_basename_wo_extension(string const &s); Undocumented function.

setBinary void Filename::set_binary(void); Setting these flags appropriately is helpful when opening or searching for a file; it helps the Filename resolve OS-specific conventions (for instance, that dynamic library names should perhaps be changed from .so to .dll). Description: Indicates that the filename represents a binary file. This is primarily relevant to the read_file() and write_file() methods, so they can set the appropriate flags to the OS.

setDirname void Filename::set_dirname(string const &s); You can also use any of these to reassign pieces of the filename.

setExtension void Filename::set_extension(string const &s); Undocumented function.

setFullpath void Filename::set_fullpath(string const &s); You can also use any of these to reassign pieces of the filename.

setFullpathWoExtension void Filename::set_fullpath_wo_extension(string const &s); Undocumented function.

setHashToEnd void Filename::set_hash_to_end(string const &s); Undocumented function.

setPattern void Filename::set_pattern(bool pattern); Description: Sets the flag indicating whether this is a filename pattern. When this is true, the filename is understood to be a placeholder for a numbered sequence of filename, such as an image sequence. In this case, a sequence of one or more hash characters ("#") should appear in the filename string; these characters will be filled in with the corresponding number (or more) of digits representing the sequence number. Sequence numbers always begin counting at 0. When this is true, methods like has_hash() and get_hash_to_end() and get_filename_index() may be called. Methods like is_exists() will implicitly test for existance of filename sequence 0.

setText void Filename::set_text(void); Setting these flags appropriately is helpful when opening or searching for a file; it helps the Filename resolve OS-specific conventions (for instance, that dynamic library names should perhaps be changed from .so to .dll). Description: Indicates that the filename represents a text file. This is primarily relevant to the read_file() and write_file() methods, so they can set the appropriate flags to the OS.

setType void Filename::set_type(Filename::Type type); Description: Sets the type of the file represented by the filename. This is useful for to_os_specific(), resolve_filename(), test_existence(), and all such real-world access functions. It helps the Filename know how to map the internal filename to the OS-specific filename (for instance, maybe executables should have an .exe extension).

standardize void Filename::standardize(void); Undocumented function.

substr string Filename::substr(unsigned int begin, unsigned int end = (string::npos)) const; Description:

temporary static Filename Filename::temporary(string const &dirname, string const &prefix, string const &suffix = ((string())), Filename::Type type = (T_general)); Undocumented function.

textFilename static Filename Filename::text_filename(string const &filename); Static constructors to explicitly create a filename that refers to a text or binary file. This is in lieu of calling set_text() or set_binary() or set_type(). Description:

toOsGeneric string Filename::to_os_generic(void) const; Undocumented function.

toOsSpecific string Filename::to_os_specific(void) const; Undocumented function.

touch bool Filename::touch(void) const; Undocumented function.

unlink bool Filename::unlink(void) const; Undocumented function.