A class representing a file system path. More...
Inherits BFlattenable.
Public Member Functions | |
BPath () | |
Creates an uninitialized BPath object. | |
BPath (const BDirectory *dir, const char *leaf=NULL, bool normalize=false) | |
Creates a BPath object and initializes it to the specified directory and filename combination. | |
BPath (const BEntry *entry) | |
Creates a BPath object and initializes it to the filesystem entry specified by the passed in BEntry object. | |
BPath (const BPath &path) | |
Creates a copy of the given BPath object. | |
BPath (const char *dir, const char *leaf=NULL, bool normalize=false) | |
Creates a BPath object and initializes it to the specified path or path and filename combination. | |
BPath (const entry_ref *ref) | |
Creates a BPath object and initializes it to the filesystem entry specified by the passed in entry_ref struct. | |
virtual | ~BPath () |
Destroys the BPath object and frees any associated resources. | |
Constructor Helpers | |
status_t | InitCheck () const |
Checks whether or not the object was properly initialized. | |
status_t | SetTo (const entry_ref *ref) |
Reinitializes the object to the filesystem entry specified by the passed in entry_ref struct. | |
status_t | SetTo (const BEntry *entry) |
Reinitializes the object to the specified filesystem entry. | |
status_t | SetTo (const char *path, const char *leaf=NULL, bool normalize=false) |
Reinitializes the object to the passed in path or path and leaf combination. | |
status_t | SetTo (const BDirectory *dir, const char *leaf=NULL, bool normalize=false) |
Reinitializes the object to the passed in dir and relative path combination. | |
void | Unset () |
Returns the object to an uninitialized state. | |
Path Manipulation | |
status_t | Append (const char *path, bool normalize=false) |
Appends the passed in relative path to the end of the current path. | |
Path Information | |
const char * | Path () const |
Gets the entire path of the object. | |
const char * | Leaf () const |
Gets the leaf portion of the path. | |
status_t | GetParent (BPath *path) const |
Initializes path with the parent directory of the BPath object. | |
bool | IsAbsolute () const |
Gets whether or not the path is absolute or relative. | |
Operators | |
bool | operator== (const BPath &item) const |
Performs a simple (string-wise) comparison of paths for equality. | |
bool | operator== (const char *path) const |
Performs a simple (string-wise) comparison of paths for equality. | |
bool | operator!= (const BPath &item) const |
Performs a simple (string-wise) comparison of paths for inequality. | |
bool | operator!= (const char *path) const |
Performs a simple (string-wise) comparison of paths for inequality. | |
BPath & | operator= (const BPath &item) |
Initializes the object as a copy of item. | |
BPath & | operator= (const char *path) |
Initializes the object with the passed in path. | |
BFlattenable Method Implementations | |
virtual bool | IsFixedSize () const |
Implements BFlattenable::IsFixedSize(). Always returns false . | |
virtual type_code | TypeCode () const |
Implements BFlattenable::TypeCode(). Always returns B_REF_TYPE . | |
virtual ssize_t | FlattenedSize () const |
Implements BFlattenable::FlattenedSize(). Gets the size of the flattened entry_ref struct that represents the path in bytes. | |
virtual status_t | Flatten (void *buffer, ssize_t size) const |
Implements BFlattenable::Flatten(). Converts the path of the object to an entry_ref and writes it into buffer. | |
virtual bool | AllowsTypeCode (type_code code) const |
Implements BFlattenable::AllowsTypeCode(). Checks if type code is equal to B_REF_TYPE . | |
virtual status_t | Unflatten (type_code code, const void *buffer, ssize_t size) |
Implements BFlattenable::Unflatten(). Initializes the object with the flattened entry_ref data from the passed in buffer. | |
Public Member Functions inherited from BFlattenable | |
virtual | ~BFlattenable () |
Destructor. Does nothing. | |
virtual bool | AllowsTypeCode (type_code code) const |
Get whether or not the supplied type_code is supported. | |
virtual status_t | Flatten (void *buffer, ssize_t size) const =0 |
Pure virtual that should flatten the object into the supplied buffer. | |
virtual ssize_t | FlattenedSize () const =0 |
Pure virtual that should return the size of the flattened object in bytes. | |
virtual bool | IsFixedSize () const =0 |
Pure virtual that should return whether or not flattened objects of this type always have a fixed size. | |
virtual type_code | TypeCode () const =0 |
Pure virtual that returns the type_code this class flattens to. | |
virtual status_t | Unflatten (type_code code, const void *buffer, ssize_t size)=0 |
Pure virtual that should unflatten the buffer and put the contents into the current object. | |
A class representing a file system path.
BPath::BPath | ( | const BPath & | path | ) |
BPath::BPath | ( | const entry_ref * | ref | ) |
BPath::BPath | ( | const BEntry * | entry | ) |
BPath::BPath | ( | const char * | dir, |
const char * | leaf = NULL , |
||
bool | normalize = false |
||
) |
Creates a BPath object and initializes it to the specified path or path and filename combination.
dir | The base component of the pathname. May be absolute or relative. If relative, it is based off the current working directory. |
leaf | The (optional) leaf component of the pathname. Must be relative. The value of leaf is concatenated to the end of dir (a "/" will be added as a separator, if necessary). |
normalize | boolean flag used to force normalization; normalization may sometimes occur even if false . The following items require normalization:
|
BPath::BPath | ( | const BDirectory * | dir, |
const char * | leaf = NULL , |
||
bool | normalize = false |
||
) |
Creates a BPath object and initializes it to the specified directory and filename combination.
dir | The directory that provides the base component of the pathname. |
leaf | The (optional) leaf component of the pathname. Must be relative. The value of leaf is concatenated to the end of dir (a "/" will be added as a separator, if necessary). |
normalize | boolean flag used to force normalization; normalization may sometimes occur even if false . The following items require normalization:
|
|
virtual |
Destroys the BPath object and frees any associated resources.
|
virtual |
Implements BFlattenable::AllowsTypeCode(). Checks if type code is equal to B_REF_TYPE
.
code | The type code to test. |
true
if code is B_REF_TYPE
, false
otherwise.Reimplemented from BFlattenable.
status_t BPath::Append | ( | const char * | path, |
bool | normalize = false |
||
) |
Appends the passed in relative path to the end of the current path.
This method fails if the path is absolute or the BPath object is uninitialized.
path | Relative pathname to append to current path (may be NULL ). |
normalize | Boolean flag used to force normalization; normalization may sometimes occur even if false . The following items require normalization:
|
B_OK | Initialization was successful. |
B_BAD_VALUE | ref was NULL . |
B_NAME_TOO_LONG | The pathname was longer than B_PATH_NAME_LENGTH . |
|
virtual |
Implements BFlattenable::Flatten(). Converts the path of the object to an entry_ref and writes it into buffer.
buffer | The buffer that the data is to be stored in. |
size | Size of buffer. |
B_OK | Everything went fine. |
B_BAD_VALUE | buffer was NULL or of insufficient size. |
Implements BFlattenable.
|
virtual |
Implements BFlattenable::FlattenedSize(). Gets the size of the flattened entry_ref struct that represents the path in bytes.
Implements BFlattenable.
Initializes path with the parent directory of the BPath object.
No normalization is performed on the path.
path | The BPath object to be initialized to the parent directory. |
B_OK | Everything went fine. |
B_BAD_VALUE | path was NULL . |
B_ENTRY_NOT_FOUND | The BPath object represents the root path and thus has no parent. |
status_t BPath::InitCheck | ( | ) | const |
Checks whether or not the object was properly initialized.
B_OK
, if the BPath object was properly initialized, an error code otherwise.bool BPath::IsAbsolute | ( | ) | const |
Gets whether or not the path is absolute or relative.
false
if the object is initialized.true
if the path is absolute, false
if relative or if the object is uninitialized.
|
virtual |
Implements BFlattenable::IsFixedSize(). Always returns false
.
false
Implements BFlattenable.
const char * BPath::Leaf | ( | ) | const |
Gets the leaf portion of the path.
The leaf portion of the path is defined to be the string after the last '/'
. For the root path ("/"
) it is an empty string (""
).
NULL
if it is not properly initialized.bool BPath::operator!= | ( | const BPath & | item | ) | const |
bool BPath::operator!= | ( | const char * | path | ) | const |
Performs a simple (string-wise) comparison of paths for inequality.
path | The path to compare. |
true
, if the path names are not equal, false
otherwise.BPath & BPath::operator= | ( | const char * | path | ) |
Initializes the object with the passed in path.
Has the same effect as
path | the path to be assign to this object. |
bool BPath::operator== | ( | const BPath & | item | ) | const |
bool BPath::operator== | ( | const char * | path | ) | const |
Performs a simple (string-wise) comparison of paths for equality.
path | The path to compare. |
true
, if the path names are equal, false
otherwise.const char * BPath::Path | ( | ) | const |
Gets the entire path of the object.
NULL
if it is not properly initialized.status_t BPath::SetTo | ( | const BDirectory * | dir, |
const char * | path = NULL , |
||
bool | normalize = false |
||
) |
Reinitializes the object to the passed in dir and relative path combination.
dir | The directory that provides the base component of the pathname. |
path | the relative path name (may be NULL ). |
normalize | boolean flag used to force normalization; normalization may sometimes occur even if false . The following items require normalization:
|
B_OK | Initialization was successful. |
B_BAD_VALUE | ref was NULL . |
B_NAME_TOO_LONG | The pathname was longer than B_PATH_NAME_LENGTH . |
Reinitializes the object to the specified filesystem entry.
entry | The BEntry to reinitialize the entry from. |
B_OK | Initialization was successful. |
B_BAD_VALUE | ref was NULL . |
B_NAME_TOO_LONG | The pathname was longer than B_PATH_NAME_LENGTH . |
Reinitializes the object to the passed in path or path and leaf combination.
path | The path name to use. |
leaf | The leaf name to use (may be NULL ). |
normalize | Boolean flag used to force normalization; normalization may sometimes occur even if false . The following items require normalization:
|
B_OK | Initialization was successful. |
B_BAD_VALUE | ref was NULL . |
B_NAME_TOO_LONG | The pathname was longer than B_PATH_NAME_LENGTH . |
Reinitializes the object to the filesystem entry specified by the passed in entry_ref struct.
ref | The entry_ref to reinitialize the entry from. |
B_OK | Initialization was successful. |
B_BAD_VALUE | ref was NULL . |
B_NAME_TOO_LONG | The pathname was longer than B_PATH_NAME_LENGTH . |
|
virtual |
Implements BFlattenable::TypeCode(). Always returns B_REF_TYPE
.
B_REF_TYPE
Implements BFlattenable.
Implements BFlattenable::Unflatten(). Initializes the object with the flattened entry_ref data from the passed in buffer.
The type code must be set to B_REF_TYPE
.
code | The type code of the flattened data, must be B_REF_TYPE . |
buffer | A pointer to a buffer containing the flattened data. |
size | The size of buffer in bytes. |
B_OK | Everything went fine. |
B_BAD_VALUE | buffer was NULL or didn't contain an entry_ref. |
Implements BFlattenable.
void BPath::Unset | ( | ) |
Returns the object to an uninitialized state.
Frees any resources it allocated and marks the object as uninitialized.