Panda3D
|
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. More...
Public Types | |
enum | Type { T_general = 0, T_dso = 1, T_executable = 2 } |
Public Member Functions | |
__init__ (const Filename copy) | |
__init__ (const Filename dirname, const Filename basename) | |
__init__ (str filename) | |
__init__ (str filename) | |
bool | __nonzero__ () |
Returns true if the Filename is valid (not empty), or false if it is an empty string. More... | |
object | __reduce__ () |
object | __repr__ () |
bool | chdir () |
int | compareTimestamps (const Filename other, bool this_missing_is_old, bool other_missing_is_old) |
int | compareTo (const Filename other) |
bool | copyTo (const Filename other) |
str | cStr () |
bool | empty () |
bool | exists () |
extractComponents (VectorString components) | |
int | findOnSearchpath (const DSearchPath searchpath) |
time_t | getAccessTimestamp () |
str | getBasename () |
Returns the basename part of the filename. This is everything in the filename after the rightmost slash, including any extensions. More... | |
str | getBasenameWoExtension () |
Returns the basename part of the filename, without the file extension. More... | |
str | getDirname () |
Returns the directory part of the filename. This is everything in the filename up to, but not including the rightmost slash. More... | |
str | getExtension () |
Returns the file extension. This is everything after the rightmost dot, if there is one, or the empty string if there is not. More... | |
Filename | getFilenameIndex (int index) |
Streamsize | getFileSize () |
str | getFullpath () |
Returns the entire filename: directory, basename, extension. This is the same thing returned by the string typecast operator. More... | |
str | getFullpathW () |
Returns the entire filename as a wide-character string. More... | |
str | getFullpathWoExtension () |
Returns the full filename–directory and basename parts–except for the extension. More... | |
int | getHash () |
str | getHashToEnd () |
Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end of the filename. More... | |
bool | getPattern () |
Returns the flag indicating whether this is a filename pattern. See set_pattern(). More... | |
time_t | getTimestamp () |
Filename::Type | getType () |
Returns the type of the file represented by the filename, as previously set by set_type(). More... | |
bool | hasHash () |
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. More... | |
bool | isBinary () |
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. More... | |
bool | isBinaryOrText () |
Returns true either is_binary() or is_text() is true; that is, that the filename has been specified as either binary or text. If this is false, the filename has not been specified. More... | |
bool | isDirectory () |
bool | isExecutable () |
bool | isFullyQualified () |
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). More... | |
bool | isLocal () |
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. More... | |
bool | isRegularFile () |
bool | isText () |
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. More... | |
bool | isWritable () |
size_t | length () |
makeAbsolute () | |
makeAbsolute (const Filename start_directory) | |
bool | makeCanonical () |
bool | makeDir () |
bool | makeRelativeTo (Filename directory, bool allow_backups) |
bool | makeTrueCase () |
bool | mkdir () |
bool | openAppend (Ofstream stream) |
bool | openAppend (Pofstream stream) |
bool | openRead (Ifstream stream) |
bool | openRead (Pifstream stream) |
bool | openReadAppend (Fstream stream) |
bool | openReadAppend (Pfstream stream) |
bool | openReadWrite (Fstream stream, bool truncate) |
bool | openReadWrite (Pfstream stream, bool truncate) |
bool | openWrite (Ofstream stream, bool truncate) |
bool | openWrite (Pofstream stream, bool truncate) |
bool | operator!= (str other) |
Filename | operator+ (str other) |
Filename | operator+= (str other) |
Filename | operator/ (const Filename other) |
bool | operator< (str other) |
Filename | operator= (const Filename copy) |
Filename | operator= (str filename) |
Filename | operator= (str filename) |
Filename | operator= (str filename) |
bool | operator== (str other) |
Comparison operators are handy. More... | |
char | operator[] (int n) |
output (Ostream out) | |
bool | renameTo (const Filename other) |
bool | resolveFilename (const DSearchPath searchpath, str default_extension) |
bool | rmdir () |
object | scanDirectory () |
bool | scanDirectory (VectorString contents) |
setBasename (str s) | |
setBasenameWoExtension (str s) | |
setBinary () | |
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. More... | |
setDirname (str s) | |
setExtension (str s) | |
setFullpath (str s) | |
You can also use any of these to reassign pieces of the filename. More... | |
setFullpathWoExtension (str s) | |
setHashToEnd (str s) | |
setPattern (bool pattern) | |
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. More... | |
setText () | |
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. More... | |
setType (Filename::Type type) | |
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). More... | |
standardize () | |
str | substr (size_t begin, size_t end) |
str | toOsGeneric () |
str | toOsLongName () |
str | toOsShortName () |
str | toOsSpecific () |
str | toOsSpecificW () |
bool | touch () |
bool | unlink () |
Static Public Member Functions | |
static Filename | binaryFilename (const Filename filename) |
static Filename | binaryFilename (str filename) |
static Filename | dsoFilename (str filename) |
static Filename | executableFilename (str filename) |
static Filename | expandFrom (str user_string, Filename::Type type) |
static Filename | fromOsSpecific (str os_specific, Filename::Type type) |
static Filename | fromOsSpecificW (str os_specific, Filename::Type type) |
static TypeHandle | getClassType () |
static const Filename | getCommonAppdataDirectory () |
static TextEncoder::Encoding | getFilesystemEncoding () |
Specifies the default encoding to be used for all subsequent Filenames objects. See set_filesystem_encoding(). More... | |
static const Filename | getHomeDirectory () |
static const Filename | getTempDirectory () |
static const Filename | getUserAppdataDirectory () |
static Filename | patternFilename (str filename) |
Constructs a filename that represents a sequence of numbered files. See set_pattern(). More... | |
static | setFilesystemEncoding (TextEncoder::Encoding encoding) |
Specifies the default encoding to be used for all subsequent Filenames. This is used to represent wide-character (Unicode) filenames internally. On non-Windows-based systems, the encoded filename is also passed to the underlying operating system. More... | |
static Filename | temporary (str dirname, str prefix, str suffix, Filename::Type type) |
static Filename | textFilename (const Filename filename) |
static Filename | textFilename (str filename) |
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.
enum Type |
__init__ | ( | const Filename | copy | ) |
__init__ | ( | str | filename | ) |
__init__ | ( | str | filename | ) |
bool __nonzero__ | ( | ) |
Returns true if the Filename is valid (not empty), or false if it is an empty string.
This implements the Python equivalent to operator bool. Defining an actual operator bool method for C++ use would work too, but it seems to cause too many ambiguities for the C++ compiler, so we use this Python-only approach instead.
object __reduce__ | ( | ) |
object __repr__ | ( | ) |
|
static |
bool chdir | ( | ) |
int compareTimestamps | ( | const Filename | other, |
bool | this_missing_is_old, | ||
bool | other_missing_is_old | ||
) |
int compareTo | ( | const Filename | other | ) |
bool copyTo | ( | const Filename | other | ) |
str cStr | ( | ) |
|
static |
bool empty | ( | ) |
|
static |
bool exists | ( | ) |
|
static |
extractComponents | ( | VectorString | components | ) |
int findOnSearchpath | ( | const DSearchPath | searchpath | ) |
|
static |
|
static |
time_t getAccessTimestamp | ( | ) |
str getBasename | ( | ) |
Returns the basename part of the filename. This is everything in the filename after the rightmost slash, including any extensions.
str getBasenameWoExtension | ( | ) |
Returns the basename part of the filename, without the file extension.
|
static |
|
static |
str getDirname | ( | ) |
Returns the directory part of the filename. This is everything in the filename up to, but not including the rightmost slash.
str getExtension | ( | ) |
Returns the file extension. This is everything after the rightmost dot, if there is one, or the empty string if there is not.
Filename getFilenameIndex | ( | int | index | ) |
Streamsize getFileSize | ( | ) |
|
static |
Specifies the default encoding to be used for all subsequent Filenames objects. See set_filesystem_encoding().
str getFullpath | ( | ) |
Returns the entire filename: directory, basename, extension. This is the same thing returned by the string typecast operator.
str getFullpathW | ( | ) |
Returns the entire filename as a wide-character string.
str getFullpathWoExtension | ( | ) |
Returns the full filename–directory and basename parts–except for the extension.
int getHash | ( | ) |
str getHashToEnd | ( | ) |
Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end of the filename.
|
static |
bool getPattern | ( | ) |
Returns the flag indicating whether this is a filename pattern. See set_pattern().
|
static |
time_t getTimestamp | ( | ) |
Filename::Type getType | ( | ) |
Returns the type of the file represented by the filename, as previously set by set_type().
|
static |
bool hasHash | ( | ) |
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.
bool isBinary | ( | ) |
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.
bool isBinaryOrText | ( | ) |
Returns true either is_binary() or is_text() is true; that is, that the filename has been specified as either binary or text. If this is false, the filename has not been specified.
bool isDirectory | ( | ) |
bool isExecutable | ( | ) |
bool isFullyQualified | ( | ) |
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).
bool isLocal | ( | ) |
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.
bool isRegularFile | ( | ) |
bool isText | ( | ) |
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.
bool isWritable | ( | ) |
size_t length | ( | ) |
makeAbsolute | ( | ) |
makeAbsolute | ( | const Filename | start_directory | ) |
bool makeCanonical | ( | ) |
bool makeDir | ( | ) |
bool makeRelativeTo | ( | Filename | directory, |
bool | allow_backups | ||
) |
bool makeTrueCase | ( | ) |
bool mkdir | ( | ) |
bool openAppend | ( | Ofstream | stream | ) |
bool openAppend | ( | Pofstream | stream | ) |
bool openRead | ( | Ifstream | stream | ) |
bool openRead | ( | Pifstream | stream | ) |
bool openReadAppend | ( | Fstream | stream | ) |
bool openReadAppend | ( | Pfstream | stream | ) |
bool openReadWrite | ( | Fstream | stream, |
bool | truncate | ||
) |
bool openReadWrite | ( | Pfstream | stream, |
bool | truncate | ||
) |
bool openWrite | ( | Ofstream | stream, |
bool | truncate | ||
) |
bool openWrite | ( | Pofstream | stream, |
bool | truncate | ||
) |
bool operator!= | ( | str | other | ) |
Filename operator+ | ( | str | other | ) |
Filename operator+= | ( | str | other | ) |
bool operator< | ( | str | other | ) |
Filename operator= | ( | str | filename | ) |
Filename operator= | ( | str | filename | ) |
Filename operator= | ( | str | filename | ) |
bool operator== | ( | str | other | ) |
Comparison operators are handy.
char operator[] | ( | int | n | ) |
output | ( | Ostream | out | ) |
|
static |
Constructs a filename that represents a sequence of numbered files. See set_pattern().
bool renameTo | ( | const Filename | other | ) |
bool resolveFilename | ( | const DSearchPath | searchpath, |
str | default_extension | ||
) |
bool rmdir | ( | ) |
object scanDirectory | ( | ) |
bool scanDirectory | ( | VectorString | contents | ) |
setBasename | ( | str | s | ) |
setBasenameWoExtension | ( | str | s | ) |
setBinary | ( | ) |
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 | ( | str | s | ) |
setExtension | ( | str | s | ) |
|
static |
Specifies the default encoding to be used for all subsequent Filenames. This is used to represent wide-character (Unicode) filenames internally. On non-Windows-based systems, the encoded filename is also passed to the underlying operating system.
setFullpath | ( | str | s | ) |
You can also use any of these to reassign pieces of the filename.
setFullpathWoExtension | ( | str | s | ) |
setHashToEnd | ( | str | s | ) |
setPattern | ( | bool | pattern | ) |
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 | ( | ) |
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 | ( | Filename::Type | type | ) |
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 | ( | ) |
str substr | ( | size_t | begin, |
size_t | end | ||
) |
|
static |
|
static |
str toOsGeneric | ( | ) |
str toOsLongName | ( | ) |
str toOsShortName | ( | ) |
str toOsSpecific | ( | ) |
str toOsSpecificW | ( | ) |
bool touch | ( | ) |
bool unlink | ( | ) |