Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# Filename Class Reference

The name of a file, such as a texture file or an Egg file. More...

List of all members.

## Public Types
enum | Type { TGeneral = 0, TDso = 1, TExecutable = 2 }
## Public Member Functions
| Filename (Filename const copy)
| Filename (Filename const dirname, Filename const basename)
| Filename ()
| Filename (string filename)
| Filename (string filename)
| Filename (string filename)
bool | chdir ()
int | compareTimestamps (Filename const other, bool this_missing_is_old, bool other_missing_is_old)
int | compareTimestamps (Filename const other, bool this_missing_is_old)
int | compareTimestamps (Filename const other)
int | compareTo (Filename const other)
bool | copyTo (Filename const other)
string | cStr ()
bool | empty ()
bool | exists ()
| extractComponents (vectorbasic_stringchar components)
int | findOnSearchpath (DSearchPath const searchpath)
unsigned int | getAccessTimestamp ()
string | getBasename ()
| Returns the basename part of the filename.
string | getBasenameWoExtension ()
| Returns the basename part of the filename, without the file extension.
string | getDirname ()
| Returns the directory part of the filename.
string | getExtension ()
| Returns the file extension.
Filename | getFilenameIndex (int index)
int | getFileSize ()
string | getFullpath ()
| Returns the entire filename: directory, basename, extension.
string | getFullpathW ()
| Returns the entire filename as a wide-character string.
string | getFullpathWoExtension ()
| Returns the full filename--directory and basename parts--except for the extension.
int | getHash ()
string | getHashToEnd ()
| Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end of the filename.
bool | getPattern ()
| Returns the flag indicating whether this is a filename pattern.
unsigned int | getTimestamp ()
Type | getType ()
| Returns the type of the file represented by the filename, as previously set by set_type().
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.
bool | isBinary ()
| Returns true if the Filename has been indicated to represent a binary file via a previous call to set_binary().
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.
bool | isDirectory ()
bool | isExecutable ()
bool | isFullyQualified ()
| Returns true if the filename is fully qualified, e.g.
bool | isLocal ()
| Returns true if the filename is local, e.g.
bool | isRegularFile ()
bool | isText ()
| Returns true if the Filename has been indicated to represent a text file via a previous call to set_text().
bool | isWritable ()
unsigned int | length ()
| makeAbsolute ()
| makeAbsolute (Filename const start_directory)
bool | makeCanonical ()
bool | makeDir ()
bool | makeRelativeTo (Filename directory, bool allow_backups)
bool | makeRelativeTo (Filename directory)
bool | makeTrueCase ()
bool | mkdir ()
bool | nonzero ()
| Returns true if the Filename is valid (not empty), or false if it is an empty string.
bool | openAppend (OFileStream stream)
bool | openAppend (ofstream stream)
bool | openRead (IFileStream stream)
bool | openRead (ifstream stream)
bool | openReadAppend (fstream stream)
bool | openReadAppend (FileStream stream)
bool | openReadWrite (FileStream stream)
bool | openReadWrite (fstream stream)
bool | openReadWrite (fstream stream, bool truncate)
bool | openReadWrite (FileStream stream, bool truncate)
bool | openWrite (OFileStream stream)
bool | openWrite (ofstream stream)
bool | openWrite (ofstream stream, bool truncate)
bool | openWrite (OFileStream stream, bool truncate)
bool | operator!= (string other)
Filename | operator+ (string other)
| Returns a new Filename representing the concatenation of the two filenames.
Filename | operator+= (string other)
| Appends the other filename onto the end of this one.
bool | operator< (string other)
Filename | operator= (string filename)
Filename | operator= (Filename const copy)
Filename | operator= (string filename)
Filename | operator= (string filename)
bool | operator== (string other)
char | operator[] (int n)
| output (ostream out)
PyObject | reduce (PyObject self)
bool | renameTo (Filename const other)
bool | resolveFilename (DSearchPath const searchpath, string default_extension)
bool | resolveFilename (DSearchPath const searchpath)
bool | rmdir ()
bool | scanDirectory (vectorbasic_stringchar contents)
PyObject | scanDirectory ()
| setBasename (string s)
| setBasenameWoExtension (string s)
| setBinary ()
| Indicates that the filename represents a binary file.
| setDirname (string s)
| setExtension (string s)
| setFullpath (string s)
| setFullpathWoExtension (string s)
| setHashToEnd (string s)
| setPattern (bool pattern)
| Sets the flag indicating whether this is a filename pattern.
| setText ()
| Indicates that the filename represents a text file.
| setType (Type type)
| Sets the type of the file represented by the filename.
| standardize ()
string | substr (unsigned int begin, unsigned int end)
string | substr (unsigned int begin)
string | toOsGeneric ()
string | toOsLongName ()
string | toOsShortName ()
string | toOsSpecific ()
string | toOsSpecificW ()
bool | touch ()
bool | unlink ()
## Static Public Member Functions
static Filename | binaryFilename (Filename const filename)
static Filename | binaryFilename (string filename)
static Filename | dsoFilename (string filename)
static Filename | executableFilename (string filename)
static Filename | expandFrom (string user_string, Type type)
static Filename | expandFrom (string user_string)
static Filename | fromOsSpecific (string os_specific, Type type)
static Filename | fromOsSpecific (string os_specific)
static Filename | fromOsSpecificW (string os_specific, Type type)
static Filename | fromOsSpecificW (string os_specific)
static TypeHandle | getClassType ()
static Filename const | getCommonAppdataDirectory ()
static Encoding | getFilesystemEncoding ()
| Specifies the default encoding to be used for all subsequent Filenames objects.
static Filename const | getHomeDirectory ()
static Filename const | getTempDirectory ()
static Filename const | getUserAppdataDirectory ()
static Filename | patternFilename (string filename)
| Constructs a filename that represents a sequence of numbered files.
static | setFilesystemEncoding (Encoding encoding)
| Specifies the default encoding to be used for all subsequent Filenames.
static Filename | temporary (string dirname, string prefix)
static Filename | temporary (string dirname, string prefix, string suffix)
static Filename | temporary (string dirname, string prefix, string suffix, Type type)
static Filename | textFilename (Filename const filename)
static Filename | textFilename (string filename)

## Detailed 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.

## Member Enumeration Documentation

enum Type

Enumerator:

  TGeneral |
  TDso |
  TExecutable |

## Constructor & Destructor Documentation

Filename | ( | Filename const | copy | ) |

Filename | ( | Filename const | dirname,
|  | Filename const | basename
| ) |  |

Filename | ( | string | filename | ) |

Filename | ( |  | ) |

Filename | ( | string | filename | ) |

Filename | ( | string | filename | ) |

## Member Function Documentation

static Filename binaryFilename | ( | Filename const | filename | ) | `[static]`

static Filename binaryFilename | ( | string | filename | ) | `[static]`

bool chdir | ( |  | ) |

int compareTimestamps | ( | Filename const | other,
|  | bool | this_missing_is_old,
|  | bool | other_missing_is_old
| ) |  |

int compareTimestamps | ( | Filename const | other,
|  | bool | this_missing_is_old
| ) |  |

int compareTimestamps | ( | Filename const | other | ) |

int compareTo | ( | Filename const | other | ) |

bool copyTo | ( | Filename const | other | ) |

string cStr | ( |  | ) |

static Filename dsoFilename | ( | string | filename | ) | `[static]`

bool empty | ( |  | ) |

static Filename executableFilename | ( | string | filename | ) | `[static]`

bool exists | ( |  | ) |

static Filename expandFrom | ( | string | user_string,
|  | Type | type
| ) |  | `[static]`

static Filename expandFrom | ( | string | user_string | ) | `[static]`

extractComponents | ( | vectorbasic_stringchar | components | ) |

int findOnSearchpath | ( | DSearchPath const | searchpath | ) |

static Filename fromOsSpecific | ( | string | os_specific,
|  | Type | type
| ) |  | `[static]`

static Filename fromOsSpecific | ( | string | os_specific | ) | `[static]`

static Filename fromOsSpecificW | ( | string | os_specific,
|  | Type | type
| ) |  | `[static]`

static Filename fromOsSpecificW | ( | string | os_specific | ) | `[static]`

unsigned int getAccessTimestamp | ( |  | ) |

string getBasename | ( |  | ) |

Returns the basename part of the filename.

This is everything in the filename after the rightmost slash, including any extensions.

string getBasenameWoExtension | ( |  | ) |

Returns the basename part of the filename, without the file extension.

static TypeHandle getClassType | ( |  | ) | `[static]`

static Filename const getCommonAppdataDirectory | ( |  | ) | `[static]`

string getDirname | ( |  | ) |

Returns the directory part of the filename.

This is everything in the filename up to, but not including the rightmost slash.

string 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 | ) |

int getFileSize | ( |  | ) |

static Encoding getFilesystemEncoding | ( |  | ) | `[static]`

Specifies the default encoding to be used for all subsequent Filenames objects.

See set_filesystem_encoding().

string getFullpath | ( |  | ) |

Returns the entire filename: directory, basename, extension.

This is the same thing returned by the string typecast operator.

string getFullpathW | ( |  | ) |

Returns the entire filename as a wide-character string.

string getFullpathWoExtension | ( |  | ) |

Returns the full filename--directory and basename parts--except for the extension.

int getHash | ( |  | ) |

string getHashToEnd | ( |  | ) |

Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end of the filename.

static Filename const getHomeDirectory | ( |  | ) | `[static]`

bool getPattern | ( |  | ) |

Returns the flag indicating whether this is a filename pattern.

See set_pattern().

static Filename const getTempDirectory | ( |  | ) | `[static]`

unsigned int getTimestamp | ( |  | ) |

Type getType | ( |  | ) |

Returns the type of the file represented by the filename, as previously set by set_type().

static Filename const getUserAppdataDirectory | ( |  | ) | `[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 | ( |  | ) |

unsigned int length | ( |  | ) |

makeAbsolute | ( |  | ) |

makeAbsolute | ( | Filename const | start_directory | ) |

bool makeCanonical | ( |  | ) |

bool makeDir | ( |  | ) |

bool makeRelativeTo | ( | Filename | directory,
|  | bool | allow_backups
| ) |  |

bool makeRelativeTo | ( | Filename | directory | ) |

bool makeTrueCase | ( |  | ) |

bool mkdir | ( |  | ) |

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.

bool openAppend | ( | OFileStream | stream | ) |

bool openAppend | ( | ofstream | stream | ) |

bool openRead | ( | IFileStream | stream | ) |

bool openRead | ( | ifstream | stream | ) |

bool openReadAppend | ( | fstream | stream | ) |

bool openReadAppend | ( | FileStream | stream | ) |

bool openReadWrite | ( | fstream | stream | ) |

bool openReadWrite | ( | fstream | stream,
|  | bool | truncate
| ) |  |

bool openReadWrite | ( | FileStream | stream | ) |

bool openReadWrite | ( | FileStream | stream,
|  | bool | truncate
| ) |  |

bool openWrite | ( | OFileStream | stream,
|  | bool | truncate
| ) |  |

bool openWrite | ( | OFileStream | stream | ) |

bool openWrite | ( | ofstream | stream | ) |

bool openWrite | ( | ofstream | stream,
|  | bool | truncate
| ) |  |

bool operator!= | ( | string | other | ) |

Filename operator+ | ( | string | other | ) |

Returns a new Filename representing the concatenation of the two filenames.

Filename operator+= | ( | string | other | ) |

Appends the other filename onto the end of this one.

This does not introduce an intervening slash, but see the Filename constructor that takes two parameters.

bool operator< | ( | string | other | ) |

Filename operator= | ( | string | filename | ) |

Filename operator= | ( | string | filename | ) |

Filename operator= | ( | Filename const | copy | ) |

Filename operator= | ( | string | filename | ) |

bool operator== | ( | string | other | ) |

char operator[] | ( | int | n | ) |

output | ( | ostream | out | ) |

static Filename patternFilename | ( | string | filename | ) | `[static]`

Constructs a filename that represents a sequence of numbered files.

See set_pattern().

PyObject reduce | ( | PyObject | self | ) |

bool renameTo | ( | Filename const | other | ) |

bool resolveFilename | ( | DSearchPath const | searchpath,
|  | string | default_extension
| ) |  |

bool resolveFilename | ( | DSearchPath const | searchpath | ) |

bool rmdir | ( |  | ) |

bool scanDirectory | ( | vectorbasic_stringchar | contents | ) |

PyObject scanDirectory | ( |  | ) |

setBasename | ( | string | s | ) |

setBasenameWoExtension | ( | string | 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 | ( | string | s | ) |

setExtension | ( | string | s | ) |

static setFilesystemEncoding | ( | Encoding | encoding | ) | `[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 | ( | string | s | ) |

setFullpathWoExtension | ( | string | s | ) |

setHashToEnd | ( | string | 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 | ( | 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 | ( |  | ) |

string substr | ( | unsigned int | begin,
|  | unsigned int | end
| ) |  |

string substr | ( | unsigned int | begin | ) |

static Filename temporary | ( | string | dirname,
|  | string | prefix,
|  | string | suffix
| ) |  | `[static]`

static Filename temporary | ( | string | dirname,
|  | string | prefix
| ) |  | `[static]`

static Filename temporary | ( | string | dirname,
|  | string | prefix,
|  | string | suffix,
|  | Type | type
| ) |  | `[static]`

static Filename textFilename | ( | Filename const | filename | ) | `[static]`

static Filename textFilename | ( | string | filename | ) | `[static]`

string toOsGeneric | ( |  | ) |

string toOsLongName | ( |  | ) |

string toOsShortName | ( |  | ) |

string toOsSpecific | ( |  | ) |

string toOsSpecificW | ( |  | ) |

bool touch | ( |  | ) |

bool unlink | ( |  | ) |

All Classes Namespaces Functions Variables Enumerations Enumerator Properties