Panda3D
|
The abstract base class for a file or directory within the VirtualFileSystem. More...
Public Member Functions | |
closeReadFile (istream stream) | |
Closes a file opened by a previous call to open_read_file(). | |
Filename | getFilename () |
int | getFileSize () |
Returns the current size on disk (or wherever it is) of the file before it has been opened. | |
int | getFileSize (istream stream) |
Returns the current size on disk (or wherever it is) of the already-open file. | |
VirtualFileSystem | getFileSystem () |
Filename const | getOriginalFilename () |
Returns the original filename as it was used to locate this VirtualFile. | |
int | getRefCount () |
Returns the current reference count. | |
unsigned int | getTimestamp () |
Returns a time_t value that represents the time the file was last modified, to within whatever precision the operating system records this information (on a Windows95 system, for instance, this may only be accurate to within 2 seconds). | |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | hasFile () |
Returns true if this file exists, false otherwise. | |
bool | isDirectory () |
Returns true if this file represents a directory (and scan_directory() may be called), false otherwise. | |
bool | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. | |
bool | isRegularFile () |
Returns true if this file represents a regular file (and read_file() may be called), false otherwise. | |
ls (ostream out) | |
If the file represents a directory, lists its contents. | |
ls () | |
If the file represents a directory, lists its contents. | |
lsAll (ostream out) | |
If the file represents a directory, recursively lists its contents and those of all subdirectories. | |
lsAll () | |
If the file represents a directory, recursively lists its contents and those of all subdirectories. | |
istream | openReadFile (bool auto_unwrap) |
Opens the file for reading. | |
output (ostream out) | |
string | readFile (bool auto_unwrap) |
Returns the entire contents of the file as a string. | |
ref () | |
Explicitly increments the reference count. | |
VirtualFileList | scanDirectory () |
If the file represents a directory (that is, is_directory() returns true), this returns the list of files within the directory at the current time. | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
bool | unref () |
Explicitly decrements the reference count. | |
bool | wasReadSuccessful () |
Call this method after a reading the istream returned by open_read_file() to completion. | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
The abstract base class for a file or directory within the VirtualFileSystem.
closeReadFile | ( | istream | stream | ) |
Closes a file opened by a previous call to open_read_file().
This really just deletes the istream pointer, but it is recommended to use this interface instead of deleting it explicitly, to help work around compiler issues.
static TypeHandle getClassType | ( | ) | [static] |
Reimplemented from TypedReferenceCount.
Reimplemented in VirtualFileComposite, VirtualFileSimple, and VirtualFileHTTP.
Filename getFilename | ( | ) |
Returns the current size on disk (or wherever it is) of the already-open file.
Pass in the stream that was returned by open_read_file(); some implementations may require this stream to determine the size.
int getFileSize | ( | ) |
Returns the current size on disk (or wherever it is) of the file before it has been opened.
VirtualFileSystem getFileSystem | ( | ) |
Filename const getOriginalFilename | ( | ) |
Returns the original filename as it was used to locate this VirtualFile.
This is usually, but not always, the same string returned by get_filename().
int getRefCount | ( | ) | [inherited] |
Returns the current reference count.
unsigned int getTimestamp | ( | ) |
Returns a time_t value that represents the time the file was last modified, to within whatever precision the operating system records this information (on a Windows95 system, for instance, this may only be accurate to within 2 seconds).
If the timestamp cannot be determined, either because it is not supported by the operating system or because there is some error (such as file not found), returns 0.
TypeHandle getType | ( | ) | [inherited] |
Reimplemented in AnimChannelBase.
int getTypeIndex | ( | ) | [inherited] |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
This is equivalent to get_type().get_index().
bool hasFile | ( | ) |
Returns true if this file exists, false otherwise.
bool isDirectory | ( | ) |
Returns true if this file represents a directory (and scan_directory() may be called), false otherwise.
bool isExactType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is the indicated type exactly.
bool isOfType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is or derives from the indicated type.
bool isRegularFile | ( | ) |
Returns true if this file represents a regular file (and read_file() may be called), false otherwise.
ls | ( | ostream | out | ) |
If the file represents a directory, lists its contents.
ls | ( | ) |
If the file represents a directory, lists its contents.
lsAll | ( | ostream | out | ) |
If the file represents a directory, recursively lists its contents and those of all subdirectories.
lsAll | ( | ) |
If the file represents a directory, recursively lists its contents and those of all subdirectories.
istream openReadFile | ( | bool | auto_unwrap | ) |
Opens the file for reading.
Returns a newly allocated istream on success (which you should eventually delete when you are done reading). Returns NULL on failure.
output | ( | ostream | out | ) |
string readFile | ( | bool | auto_unwrap | ) |
Returns the entire contents of the file as a string.
ref | ( | ) | [inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
VirtualFileList scanDirectory | ( | ) |
If the file represents a directory (that is, is_directory() returns true), this returns the list of files within the directory at the current time.
Returns NULL if the file is not a directory or if the directory cannot be read.
bool testRefCountIntegrity | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
bool testRefCountNonzero | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
bool unref | ( | ) | [inherited] |
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.
bool wasReadSuccessful | ( | ) |
Call this method after a reading the istream returned by open_read_file() to completion.
If it returns true, the file was read completely and without error; if it returns false, there may have been some errors or a truncated file read. This is particularly likely if the stream is a VirtualFileHTTP.