SophiaFramework UNIVERSE 5.3 |
The SFXPath class is used to get a parent directory, convert a relative path into a absolute one, or set a file name or suffix.
The distinction between file and directory can be made by checking whether or not the last character of the path is '/'.
Constructor/Destructor |
---|
SFXPath( Void ) Constructor of the SFXPath class.
|
SFXPath(
SFXPathConstRef param
) Constructor of the SFXPath class.
|
SFXPath(
SFXAnsiStringConstRef param
) Constructor of the SFXPath class.
|
Public Functions | |
---|---|
SFXAnsiString |
AsDirectory( Void ) Get this path as the directory path of the SFXAnsiString type.
|
SFXPath |
AsDirectoryPath( Void ) Get this path as the directory path of the SFXPath type.
|
SFXAnsiString |
AsFile( Void ) Get this path as the file path of the SFXAnsiString type.
|
SFXPath |
AsFilePath( Void ) Get this path as the file path of the SFXPath type.
|
Void |
Clear( Void ) Clear this path.
|
static SFXPathConstRef |
EmptyInstance( Void ) Get the empty path.
|
Bool |
Equals(
SFXPathConstRef param
) Check whether or not this path equals the specified one.
|
SFXAnsiStringConstRef |
Get( Void ) Get this path of the SFXAnsiString type.
|
SFXAnsiString |
GetAbsolute( Void ) Get the absolute path of this path of the SFXAnsiString type.
|
SFXPath |
GetAbsolutePath( Void ) Get the absolute path of this path of the SFXPath type.
|
SFXAnsiString |
GetExtension( Void ) Get the file extention of this path.
|
SFXAnsiString |
GetName(
Bool extension = false
) Get the file or directory name of this path.
|
SFXAnsiString |
GetParent( Void ) Get the parent directory path of this path of the SFXAnsiString type.
|
SFXPath |
GetParentPath( Void ) Get the parent directory path of this path of the SFXPath type.
|
static SFXPath |
HomeDirectoryPath( Void ) Get the home directory path.
|
Bool |
IsAbsolute( Void ) Check whether or not this path is an absolute one.
|
Bool |
IsDirectory( Void ) Check whether or not this path is a directory one.
|
Bool |
IsHomeDirectory( Void ) Check whether or not this path is a home directory one.
|
Bool |
IsRootDirectory( Void ) Check whether or not this path is a root directory one.
|
SFXAnsiString |
Normalize( Void ) Get the path of the SFXAnsiString type into which this path is normalized.
|
SFXPath |
NormalizePath( Void ) Get the path of the SFXPath type into which this path is normalized.
|
static SFXPath |
RootDirectoryPath( Void ) Get the root directory path.
|
SFCError |
Set(
SFXPathConstRef param
) Set the path.
|
SFCError |
Set(
SFXAnsiStringConstRef param
) Set the path.
|
SFCError |
SetExtension(
SFXAnsiStringConstRef extension
) Set the file extention of this path.
|
SFCError |
SetName(
SFXAnsiStringConstRef name
, Bool extension = false
) Set the file or directory name of this path.
|
Void |
ToDirectory( Void ) Convert this path into the directory one.
|
Void |
ToFile( Void ) Convert this path into the file one.
|
Bool |
operator!=(
SFXPathConstRef left
, SFXPathConstRef right
) Check the relation of "!=".
|
SFXPathRef |
operator=(
SFXPathConstRef param
) Substitute the path.
|
Bool |
operator==(
SFXPathConstRef left
, SFXPathConstRef right
) Check the relation of "==".
|
[ public, explicit ] SFXPath(Void);
[ public ] SFXPath( SFXPathConstRef param // path to set );
[ public, explicit ] SFXPath( SFXAnsiStringConstRef param // path to set );
In this constructor, this path can be set to the value specified in the path argument.
[ public, const ] SFXAnsiString AsDirectory(Void);
Directory path of the SFXAnsiString type.
This function gets this path as the directory path of the SFXAnsiString type.
The directory path of the SFXAnsiString type will be generated internally as follows:
Directory path | |
---|---|
The directory path is the one that has the '/' character at the end. |
SFXPath path("/user/admin/brew/a/b/c"); SFXAnsiString str; // get this path as the directory path of the SFXAnsiString type str = path.AsDirectory(); TRACE("%s", str.GetCString()); // /user/admin/brew/a/b/c/
SFXPath::AsDirectoryPath | SFXPath::ToDirectory | SFXPath::AsFile | SFXAnsiString
[ public, const ] SFXPath AsDirectoryPath(Void);
Directory path of the SFXPath type.
This function gets this path as the directory path of the SFXPath type.
The directory path of the SFXPath type will be generated internally as follows:
Directory path | |
---|---|
The directory path is the one that has the '/' character at the end. |
SFXPath path1("/user/admin/brew/a/b/c"); SFXPath path2; // get this path as the directory path path2 = path.AsDirectoryPath(); TRACE("%s", path2.Get().GetCString()); // /user/admin/brew/a/b/c/
SFXPath::AsFilePath | SFXPath::ToDirectory | SFXPath::AsDirectory | SFXPath
[ public, const ] SFXAnsiString AsFile(Void);
File path of the SFXAnsiString type.
This function gets this path as the file path of the SFXAnsiString type.
The file path of the SFXAnsiString type will be generated internally as follows:
File path | |
---|---|
The file path is the one that has any character except '/' at the end. |
SFXPath path("/user/admin/log/./../brew/log.txt"); SFXAnsiString str; // get this path as the file path of the SFXAnsiString type str = path.AsFile(); TRACE("%s", str.GetCString()); // /user/admin/log/./../brew/log.txt
SFXPath::AsFilePath | SFXPath::ToFile | SFXPath::AsDirectory | SFXAnsiString
[ public, const ] SFXPath AsFilePath(Void);
File path of the SFXPath type.
This function gets this path as the file path of the SFXPath type.
The file path of the SFXPath type will be generated internally as follows:
File path | |
---|---|
The file path is the one that has any character except '/' at the end. |
SFXPath path1("dir1/dir2/data.txt"); SFXPath path2; // get this path as the file path of the SFXPath type path2 = path.AsFilePath(); TRACE("%s", path2.Get().GetCString()); // dir1/dir2/data.txt
SFXPath::AsFile | SFXPath::ToFile | SFXPath::AsDirectoryPath | SFXPath
[ public ] Void Clear(Void);
This function clears this path.
Note | |
---|---|
After cleared, this path is same as the return value of the SFXPath::EmptyInstance function. |
SFXPath path("/user/admin/brew/a/b/c");
...
// clear the path
path.Clear();
[ public, static ] SFXPathConstRef EmptyInstance(Void);
This function gets the instance that represents an empty path.
[ public, const ] Bool Equals( SFXPathConstRef param // path to compare with );
This function checks whether or not this path equals the specified one, i.e., this path refers to the same object as the specified one.
Note | |
---|---|
This function internally executes the SFXPath::Normalize function to compare both of the result strings. |
SFXPath::Normalize | SFXPath::operator== | SFXPath::operator!=
[ public, const ] SFXAnsiStringConstRef Get(Void);
This path of the SFXAnsiString type.
This function gets this path of the SFXAnsiString type.
SFXPath path1("/dir1/data.txt");
TRACE("path = %s", path.Get().GetCString()); // /dir1/data.txt
SFXPath::Set | SFXPath::GetAbsolute | SFXPath::GetAbsolutePath | SFXPath::GetExtension | SFXPath::GetName | SFXPath::GetParent | SFXPath::GetParentPath SFXAnsiString
[ public, const ] SFXAnsiString GetAbsolute(Void);
Absolute path of this path of the SFXAnsiString type.
This function gets the absolute path of this path of the SFXAnsiString type.
Note | |
---|---|
If the relative path is set, it will be converted into the absolute path. |
SFXPath path("/user/admin/log/./../brew/log.txt");
TRACE("absolute = %s", path.GetAbsolute().GetCString()); // absolute = fs:/~/user/admin/log/./../brew/log.txt
SFXPath::IsAbsolute | SFXPath::Get | SFXPath::GetAbsolutePath | SFXAnsiString
[ public, const ] SFXPath GetAbsolutePath(Void);
Absolute path of this path of the SFXPath type.
This function gets the absolute path of this path of the SFXPath type.
Note | |
---|---|
If the relative path is set, it will be converted into the absolute path. |
SFXPath path1("dir1/dir2/data.txt"); SFXPath path2; // path2 = "/dir1/dir2/data.txt" // path1 is the same path2 = path1.GetAbsolutePath();
SFXPath::IsAbsolute | SFXPath::Get | SFXPath::GetAbsolute | SFXPath
[ public, const ] SFXAnsiString GetExtension(Void);
File extention of this path
If this path is a directory or does not have any extention, the null string will be returned.
This function gets the file extention of this path.
Note | |
---|---|
If this path is a directory or does not have any extention, the null string will be returned. |
SFXPath path("/dir1/dir2/data.txt"); SFXAnsiString extension; // get file extention extension = path.GetExtension(); TRACE("extension = %s", extension.GetCString()); // extension = txt
[ public, const ] SFXAnsiString GetName( Bool extension = false // whether or not to get the name including its extention );
File or directory name of this path.
This function gets the file or directory name of this path.
SFXPath path("/user/admin/log/./../brew/log.txt");
TRACE("name = %s", path.GetName().GetCString()); // name = log
[ public, const ] SFXAnsiString GetParent(Void);
Parent directory path of this path of the SFXAnsiString type.
This function gets the parent directory path of this path of the SFXAnsiString type.
If the current path is of a file, the directory path including the file will be returned. Otherwise, i.e., it is of a directory, the one more upper directory path including the directory will be returned.
In case the current path is of file:
SFXPath path("/user/admin/log/./../brew/log.txt");
TRACE("parent = %s", path.GetParent().GetCString()); // parent = /user/admin/log/./../brew/
In case the current path is of directory:
SFXPath path("/user/admin/log/./../brew");
TRACE("parent = %s", path.GetParent().GetCString()); // parent = /user/admin/log/./../
[ public, const ] SFXPath GetParentPath(Void);
Parent directory path of this path of the SFXPath type.
This function gets the parent directory path of this path of the SFXPath type.
If the current path is of a file, the directory path including the file will be returned. Otherwise, i.e., it is of a directory, the one more upper directory path including the directory will be returned.
SFXPath path1("/dir1/dir2/data.txt"); SFXPath path2; SFXAnsiString string; // path2 is "/dir1/dir2/" // path1 is the same path2 = path1.GetParentPath();
[ public, static ] SFXPath HomeDirectoryPath(Void);
This function gets the home directory path.
Home directory path | |
---|---|
In BREW 3.1 or above, the home directory path is "fs:/~/". In BREW 2.1 or below, it is "/". |
[ public, const ] Bool IsAbsolute(Void);
This function checks whether or not this path is an absolute one.
[ public, const ] Bool IsDirectory(Void);
This function checks whether or not this path is a directory one.
Directory path | |
---|---|
The directory path is the one that has the '/' character at the end. |
[ public, const ] Bool IsHomeDirectory(Void);
This function checks whether or not this path is a home directory one.
Home directory path | |
---|---|
In BREW 3.1 or above, the home directory path is "fs:/~/". In BREW 2.1 or below, it is "/". |
[ public, const ] Bool IsRootDirectory(Void);
This function checks whether or not this path is a root directory one.
Root directory path | |
---|---|
In BREW 3.1 or above, the root directory path is "fs:/". In BREW 2.1 or below, it is "/". |
[ public, const ] SFXAnsiString Normalize(Void);
Path of the SFXAnsiString type into which this path is normalized.
This function gets the path of the SFXAnsiString type into which this path is normalized.
Normalization | |
---|---|
Normalization is to convert the relative path into the absolute one. For instance, ".///a/b//c/./../a///../" is normalized into "fs:/~/a/b/" in the BREW 3.1. |
SFXPath path("/user/admin/log/./../brew");
TRACE("normalize = %s", path.Normalize().GetCString()); // normalize = fs:/user/admin/brew
[ public, const ] SFXPath NormalizePath(Void);
Path of the SFXPath type into which this path is normalized.
This function gets the path of the SFXPath type into which this path is normalized.
Normalization | |
---|---|
Normalization is to convert the relative path into the absolute one. For instance, ".///a/b//c/./../a///../" is normalized into "fs:/~/a/b/" in the BREW 3.1. |
SFXPath path1(.///a/b//c/./../a///../ );
SFXPath path2;
path2 = path1.NormalizePath(); // path2 = fs:/~/a/b/
[ public, static ] SFXPath RootDirectoryPath(Void);
This function gets the root directory path.
Root directory path | |
---|---|
In BREW 3.1 or above, the root directory path is "fs:/". In BREW 2.1 or below, it is "/". |
[ public ] SFCError Set( SFXPathConstRef param // path to set );
[ public ] SFCError Set( SFXAnsiStringConstRef param // path to set );
This function sets the path.
SFXPath::Get | SFXPath::SetExtension | SFXPath::SetName | SFXPath::operator=
[ public ] SFCError SetExtension( SFXAnsiStringConstRef extension // file extention to set );
This function sets the file extention of this path.
Note | |
---|---|
This function cannot change the directory or file name of this path nor remove the extention from this path. |
SFXPath path("/dir1/dir2/data.txt");
path.SetExtension("dat");
TRACE("path = %s", path.Get().GetCString()); // path = /dir1/dir2/data.dat
[ public ] SFCError SetName( SFXAnsiStringConstRef name // name to set Bool extension = false // whether or not to set the name including an extention );
This function sets the file or directory name of this path.
Note | |
---|---|
Since the directory has no extention, the extension augument is invalid in case of setting the directory name. |
SFXPath path("dir1/dir2/");
path.SetName("user");
TRACE("%s", path.Get().GetCString()); // dir1/user/
[ public ] Void ToDirectory(Void);
This function converts this path into the directory one.
This path will be converted into the directory one as follows:
Directory path | |
---|---|
The directory path is the one that has the '/' character at the end. |
SFXPath::ToFile | SFXPath::AsDirectory | SFXPath::AsDirectoryPath
[ public ] Void ToFile(Void);
This function converts this path into the file one.
This path will be converted into the file one as follows:
File path | |
---|---|
The file path is the one that has any character except '/' at the end. |
SFXPath::ToDirectory | SFXPath::AsFile | SFXPath::AsFilePath
[ public ] SFXPathRef operator=( SFXPathConstRef param // path to copy );
[ public, friend ] Bool operator==( SFXPathConstRef left // path to compare SFXPathConstRef right // path to compare );
This operator checks whether or not the path of the left side equals that of the right side, i.e., both refer to the same file or directory.
For the paths of the both sides, if the return values of the SFXPath::Normalize function are the same, true will be returned. Otherwise, false will be returned.
[ public, friend ] Bool operator!=( SFXPathConstRef left // path to compare SFXPathConstRef right // path to compare );
This operator checks whether or not the path of the left side equals that of the right side, i.e., both refer to the differnt file or directory.
For the paths of the both sides, if the return values of the SFXPath::Normalize function are not the same, true will be returned. Otherwise, false will be returned.
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |