![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |

SFXPath is a class that gets a parent directory, converts a relative path into a absolute path, and set a file name or suffix.
The distinction between file and directory can be made by checking whether the last character of path is " / " or not.
| Constructor/Destructor |
|---|
|
SFXPath( Void ) Constructor of SFXPath class.
|
|
SFXPath(
SFXPathConstRef param
) Constructor of SFXPath class.
|
|
SFXPath(
SFXAnsiStringConstRef param
) Constructor of SFXPath class.
|
| Public Functions | |
|---|---|
| SFXAnsiString |
AsDirectory( Void ) Convert a directory path into a string.
|
| SFXPath |
AsDirectoryPath( Void ) Convert a path name into a directory path.
|
| SFXAnsiString |
AsFile( Void ) Convert a file path into a string.
|
| SFXPath |
AsFilePath( Void ) Convert a path name into a file path.
|
| Void |
Clear( Void ) Clear the path.
|
| static SFXPathConstRef |
EmptyInstance( Void ) Get the empty path.
|
| Bool |
Equals(
SFXPathConstRef param
) Check whether two paths equal or not.
|
| SFXAnsiStringConstRef |
Get( Void ) Get the path in a string.
|
| SFXAnsiString |
GetAbsolute( Void ) Get the absolute path in a string.
|
| SFXPath |
GetAbsolutePath( Void ) Get the absolute path.
|
| SFXAnsiString |
GetExtension( Void ) Get the file extention.
|
| SFXAnsiString |
GetName(
Bool extension = false
) Get the file or directory name.
|
| SFXAnsiString |
GetParent( Void ) Get the parent directory path in a string.
|
| SFXPath |
GetParentPath( Void ) Get the parent directory path.
|
| static SFXPath |
HomeDirectoryPath( Void ) Get the home directory path.
|
| Bool |
IsAbsolute( Void ) Check whether the path is an absolute path or not.
|
| Bool |
IsDirectory( Void ) Check whether the path is a directory or not.
|
| Bool |
IsHomeDirectory( Void ) Check whether the path is a home directory or not.
|
| Bool |
IsRootDirectory( Void ) Check whether the path is a root directory or not.
|
| SFXAnsiString |
Normalize( Void ) Normalize the path.
|
| SFXPath |
NormalizePath( Void ) Get the normalized path.
|
| static SFXPath |
RootDirectoryPath( Void ) Get the path of root directory.
|
| SFCError |
Set(
SFXPathConstRef param
) Set( SFXAnsiStringConstRef param ) Set the path.
|
| SFCError |
SetExtension(
SFXAnsiStringConstRef extension
) Set the file extention.
|
| SFCError |
SetName(
SFXAnsiStringConstRef name
, Bool extension = false
) Set the file or directory name.
|
| Void |
ToDirectory( Void ) Interpret the current path as directory.
|
| Void |
ToFile( Void ) Interpret the current path as file.
|
| 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
);
Create a path by copying the object specified as an argument of the constructor.
[ public, const ] SFXAnsiString AsDirectory(Void);
If the path is of file, it will be converted into the path string with " / " appended at the end.
SFXPath path("/user/admin/brew/a/b/c");
SFXAnsiString str;
// convert a directory path into a string
str = path.AsDirectory();
// /user/admin/brew/a/b/c/
TRACE("%s", str.GetCString());
SFXPath::AsDirectoryPath | SFXPath::ToDirectory | SFXPath::AsFile
[ public, const ] SFXPath AsDirectoryPath(Void);
If the path is of file, it will be converted into the path string with " / " appended at the end.
SFXPath path1("/user/admin/brew/a/b/c");
SFXPath path2;
// convert path name into directory path
path2 = path.AsDirectoryPath();
// /user/admin/brew/a/b/c/
TRACE("%s", path2.Get().GetCString());
SFXPath::AsFilePath | SFXPath::ToDirectory | SFXPath::AsDirectory
[ public, const ] SFXAnsiString AsFile(Void);
If the path is of directory, it will be converted into the path string without " / " at the end.
SFXPath path("/user/admin/log/./../brew/log.txt");
SFXAnsiString str;
// convert file path into string
str = path.AsFile();
// /user/admin/log/./../brew/log.txt
TRACE("%s", str.GetCString());
SFXPath::AsFilePath | SFXPath::ToFile | SFXPath::AsDirectory
[ public, const ] SFXPath AsFilePath(Void);
If the path is of directory, it will be converted into the path string without " / " at the end.
SFXPath path1("dir1/dir2/data.txt");
SFXPath path2;
// convert path name into file path
path2 = path.AsFilePath();
// dir1/dir2/data.txt
TRACE("%s", path2.Get().GetCString());
SFXPath::AsFile | SFXPath::ToFile | SFXPath::AsDirectoryPath
[ public ] Void Clear(Void);
SFXPath path("/user/admin/brew/a/b/c");
...
// clear the path
path.Clear();
[ public, static ] SFXPathConstRef EmptyInstance(Void);
Get the instance that represents a empty path.
[ public, const ] Bool Equals( SFXPathConstRef param // path to compare with );
What two paths equal means that the object referenced by each path is the same file or directory.
SFXPath::Normalize | SFXPath::operator== | SFXPath::operator!=
[ public, const ] SFXAnsiStringConstRef Get(Void);
SFXPath path1("/dir1/data.txt");
TRACE("path = %s", path.Get().GetCString()); // /dir1/data.txt
SFXPath::GetAbsolute | SFXPath::GetAbsolutePath | SFXPath::GetExtension | SFXPath::GetName | SFXPath::GetParent | SFXPath::GetParentPath | SFXPath::Set
[ public, const ] SFXAnsiString GetAbsolute(Void);
Return the absolute path string.
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
[ public, const ] SFXPath GetAbsolutePath(Void);
Return the instance of SFXPath class set with the absolute path.
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();
[ public, const ] SFXAnsiString GetExtension(Void);
Return the file extention.
If it is a directory or does not have a extention, return the null string.
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 to get the name including an extention );
SFXPath path("/user/admin/log/./../brew/log.txt");
TRACE("name = %s", path.GetName().GetCString()); // name = log
[ public, const ] SFXAnsiString GetParent(Void);
If the current path is of file, return the directory path including the file. If the current path is of directory, return the one more upper directory path including the directory.
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);
If the current path is of file, return the directory path including the file. If the current path is of directory, return the one more upper directory path including the directory.
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);
In the BREW 3.0 / 3.1, return " fs:/~/ ". In the BREW earlier than 3.0, return " / ".
[ public, const ] Bool IsAbsolute(Void);
[ public, const ] Bool IsDirectory(Void);
[ public, const ] Bool IsHomeDirectory(Void);
A home directory is " fs:/~/ " in the BREW 3.0 / 3.1, or " / " in the BREW earlier than 3.0.
The IsHomeDirectory function checks whether the path is " fs:/~/ " or " / " in the BREW 3.0 / 3.1, or is " / " in the BREW earlier than 3.0.
[ public, const ] Bool IsRootDirectory(Void);
A root directory is " fs:/ " in the BREW 3.0 / 3.1, or " / " in the BREW earlier than 3.0.
The IsRootDirectory function checks whether the path is " fs:/ " or " / " in the BREW 3.0 / 3.1, or is " / " in the BREW earlier than 3.0.
[ public, const ] SFXAnsiString Normalize(Void);
Return the normalized path as a string.
Normalization is to convert the relative path into the absolute path. For example, " .///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, const ] SFXPath NormalizePath(Void);
Return the normalized path.
Normalization is to convert the relative path into the absolute path. For example, " .///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, static ] SFXPath RootDirectoryPath(Void);
Return the path of root directory.
A root directory is " fs:/ " in the BREW 3.0 / 3.1, or " / " in the BREW earlier than 3.0.
[ public ] SFCError Set( SFXPathConstRef param // path to set );
[ public ] SFCError Set( SFXAnsiStringConstRef param // path to set );
SFXPath::Get | SFXPath::SetExtension | SFXPath::SetName | SFXPath::operator=
[ public ] SFCError SetExtension( SFXAnsiStringConstRef extension // file extention to set );
The SetExtension function cannot change the directory name, and remove the extention.
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 to set the name including an extention or not );
Since the directory has no extention, the extension augument is invalid in case of directory.
SFXPath path("dir1/dir2/");
path.SetName("user");
TRACE("%s", path.Get().GetCString()); // dir1/user/
[ public ] Void ToDirectory(Void);
If the path is of file, it can be precessed as directory by appending " / " at the end.
SFXPath::ToFile | SFXPath::AsDirectory | SFXPath::AsDirectoryPath
[ public ] Void ToFile(Void);
If the path is of directory, it can be precessed as file by removing " / " 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 );
What two paths equal means that the object referenced by each path is the same file or directory. Inside this function, the path strings normalized by using the SFXPath::Normalize function are compared.
[ public, friend ] Bool operator!=( SFXPathConstRef left // path to compare SFXPathConstRef right // path to compare );
What two paths equal means that the object referenced by each path is the same file or directory. Inside this function, the path strings normalized by using the SFXPath::Normalize function are compared.
|
Copyright (C) 2002 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|