SophiaFramework UNIVERSE 5.3 |
SFXPath is the class for operating a file path. The arguments of file path specified in the functions of SFXFile and SFXDirectory classes are of SFXPath type.
In the above example, the argument ending with the separator ('/') character represents a directory. A file name dose not end with the separator ('/') character.
Example 15.23. Check whether or not it is a directory
if (path.IsDirectory()) { // when path denotes a directory } if (path.IsRootDirectory()) { // when path denotes a root directory } if (path.IsHomeDirectory()) { // when path denotes a home directory }
Note | |
---|---|
The SFXPath::IsDirectory function returns false if path is "/dir1/data.txt", while it returns true if path is "/dir1/dir2/". The path string is used to check regardless of the file existence. |
Example 15.24. Get the parent directory
SFXPath path1("/dir1/dir2/data.txt"); SFXPath path2; SFXAnsiString string; // path2 is "/dir1/dir2/", path1 is not changed path2 = path1.GetParentPath(); // this function returns a string string = path1.GetParent();
There are two functions: one is a function returning the SFXPath instance, and the other is a function returning the SFXAnsiString instance.
Example 15.25. Get the absolute path
SFXPath path1("dir1/dir2/data.txt"); SFXPath path2; // path2 = "/dir1/dir2/data.txt" // path1 is not changed path2 = path1.GetAbsolutePath();
Root path | |
---|---|
The root path varies according to the BREW versions. It is "/" in BREW 2.1 or below and "fs:/" in BREW 3.1 or above. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |