SophiaFramework UNIVERSE 5.3 |
The SFXDirectory class is used to perform the directory operations such as creating a directory, moving a directory, deleting a directory, retrieving directory attribute information, traversing files and subdirectories in a directory, making a temporary directory etc.
Public Functions | |
---|---|
static SFCError |
Create(
SFXPathConstRef path
, Bool force = false
) Create the specified directory.
|
static SFCError |
DeviceFreeSpace(
UInt32Ptr result
) Get the number of free bytes currently available on file system.
|
static SFCError |
DeviceTotalSpace(
UInt32Ptr result
) Get the total room in the file system.
|
static SFCError |
Exists(
SFXPathConstRef path
, BoolPtr result
) Check whether or not the specified directory exists.
|
static SFCError |
GetCreateDate(
SFXPathConstRef path
, SFXDatePtr result
) Get the creation date of the specified directory.
|
static SFCError |
GetDirectoryEnumerator(
SFXPathConstRef path
, EnumeratorPtr result
) Get the directory enumerator within the specified directory
|
static SFCError |
GetFileEnumerator(
SFXPathConstRef path
, EnumeratorPtr result
) Get the file enumerator within the specified directory
|
static SFCError |
GetTemporaryPath(
SFXPathConstRef path
, SFXPathPtr result
) Get the temporary directory path.
|
static SFCError |
GetUniquePath(
SFXPathConstRef path
, SFXAnsiStringConstRef prefix
, SFXAnsiStringConstRef suffix
, SFXPathPtr result
) Get the unique directory path name that does not duplicate the existing ones
|
static SFCError |
IsReadOnly(
SFXPathConstRef path
, BoolPtr result
) Check whether or not the specified directory is read only.
|
static SFCError |
IsSystem(
SFXPathConstRef path
, BoolPtr result
) Check whether the directory is system directory or not.
|
static SFCError |
Remove(
SFXPathConstRef path
, Bool force = false
) Remove the specified directory.
|
Types |
---|
Enumerator
Class that represents an enumerator.
|
[ public, static ] SFCError Create( SFXPathConstRef path // directory path to create Bool force = false // whether or not to create forcedly );
This function creates the directory specified in the path argument.
If the force argument is set to true, the directories which do not exist in the specified path will be created automatically.
Note | |
---|---|
This function calls the SFBFileMgr::MkDir function internally. |
// create directory forcedly // if dir1 does not exist, dir1 will be created automatically SFXDirectory::Create(SFXPath("/dir1/dir2/"), true);
SFBFileMgr::MkDir | SFXDirectory::Remove | BREW API IFILEMGR_MkDir | BREW API IFILEMGR_GetLastError
This function gets the number of free bytes currently available on file system
Note | |
---|---|
This function internally calls the SFBFileMgr::GetFreeSpace function. |
Caution | |
---|---|
In case of the Simulator, if the space available is larger than the maximum 32-bit integer value, the maximum value of a 32-bit integer is returned(0xFFFFFFFF). |
UInt32 space;
// get the number of free bytes currently available on file system
SFXDirectory::DeviceFreeSpace(&space);
SFBFileMgr::GetFreeSpace | SFXDirectory::DeviceTotalSpace | BREW API IFILE_IFILEMGR_GetFreeSpace | BREW API IFILEMGR_GetLastError
This function gets the total room in the file system.
Note | |
---|---|
This function internally calls the SFBFileMgr::GetFreeSpace function. |
Caution | |
---|---|
In case of the Simulator, if the total room is larger than the maximum 32-bit integer value, the maximum value of a 32-bit integer is returned(0xFFFFFFFF). |
UInt32 space;
// get the total room in the file system
SFXDirectory::DeviceTotalSpace(&space);
SFBFileMgr::GetFreeSpace | SFXDirectory::DeviceFreeSpace | BREW API IFILE_IFILEMGR_GetFreeSpace | BREW API IFILEMGR_GetLastError
[ public, static ] SFCError Exists( SFXPathConstRef path // directory path to check BoolPtr result // pointer to the result );
The function checks whether or not the directory specified in the path argument exists. The result will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::Test function. |
Bool b; // return value of Exists function is of SFCError type // b : set by Exists function whether specifiled directory exists or not SFXDirectory::Exists(SFXPath("/dir1/"), &b); if (b) { // when directory exists }
SFBFileMgr::Test | SFXDirectory::IsReadOnly | SFXDirectory::IsSystem | BREW API IFILEMGR_Test
[ public, static ] SFCError GetCreateDate( SFXPathConstRef path // directory path SFXDatePtr result // pointer to get the date and time created );
The function gets creation date of the directory specified in the path argument, which will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::GetInfo function. |
SFXDate date; // date // get date and time when directory was created SFXDirectory::GetCreateDate(SFXPath("/dir1/"), &date);
[ public, static ] SFCError GetDirectoryEnumerator( SFXPathConstRef path // directory path EnumeratorPtr result // pointer to the directory enumerator );
This function gets the directory enumerator within the directory specified in the path argument. The directory enumerator will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::EnumInit function. |
Get each directory within the directory.
SFXPath path; SFXDirectory::Enumerator etor; // get the directory enumerator SFXDirectory::GetDirectoryEnumerator(SFXPath("/dir1/"), &etor); // enumerate each directory while (etor.HasNext()) { // get the directory path within the "/dir1" directory in order path = etor.GetNext(); // display path name on BREW Output Window TRACE("dir = %s", path.Get().GetCString()); }
[ public, static ] SFCError GetFileEnumerator( SFXPathConstRef path // directory path EnumeratorPtr result // pointer the file enumerator );
This function gets the file enumerator within the directory specified in the path argument. The file enumerator will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::EnumInit function. |
Get each file within the directory.
SFXPath path; SFXDirectory::Enumerator etor; // get file enumerator SFXDirectory::GetFileEnumerator(SFXPath("/dir1/"), &etor); // enumerate each file while (etor.HasNext()) { // get file path within the "/dir1" directory in order path = etor.GetNext(); // display path name on BREW Output Window TRACE("file = %s", path.Get().GetCString()); }
SFXDirectory::GetDirectoryEnumerator | SFXDirectory::Enumerator | BREW API IFILEMGR_EnumInit
[ public, static ] SFCError GetTemporaryPath( SFXPathConstRef path // directory path to create the temporary directory SFXPathPtr result // pointer to the temporary directory path );
This function gets the temporary directory path that does not duplicate existing ones.
Note | |
---|---|
To get the permanent directory path which is not temporary one, use the SFXDirectory::GetUniquePath function. |
Note | |
---|---|
This function internally calls the SFXDirectory::GetUniquePath function by specifying "sfx" as the prefix argument and "dir" as the suffix argument. |
SFXPath path;
path.Set(SFXAnsiString("/"));
if (SFXDirectory::GetTemporaryPath(path, &path) == SFERR_NO_ERROR) {
// directory path like "/8A2949E2/" will be created
TRACE("%s", path.Get().GetCString());
}
[ public, static ] SFCError GetUniquePath( SFXPathConstRef path // path of parent directory to create the directory SFXAnsiStringConstRef prefix // prefix of directory name SFXAnsiStringConstRef suffix // suffix of directory name SFXPathPtr result // pointer to the directory path );
This function gets the unique directory path that does not duplicate existing ones.
Note | |
---|---|
Since the directory name is generated using a random number, this function might fail in case many directorys have already existed. If the directory name generated using a random number has already existed, repeat to retry this operation up to 64 times. Nevertheless, in case the directory path that does not duplicate existing ones can not be generated, this function will fail and return SFERR_FAILED. |
Tip | |
---|---|
To get the temporary directory path which will be deleted soon, use the SFXDirectory::GetTemporaryPath function. |
SFXPath dir("/");
SFXPath path;
if (SFXFile::GetUniquePath(dir, "sfx", "dat", &path) == SFERR_NO_ERROR) {
// directory path like "/sfx7182CBD4dat/" will be created
TRACE("%s", path.Get().GetCString());
}
[ public, static ] SFCError IsReadOnly( SFXPathConstRef path // directory path BoolPtr result // pointer to receive the result );
The functionc checks whether or not the directory specified in the path argument is read only. The result will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::GetInfo function. |
Bool b; // return value of isReadOnly function is of SFCError type // b : set by isReadOnly function whether specifiled directory is read only or not SFXDirectory::IsReadOnly(SFXPath("/dir1/data.txt"), &b); if (b) { // when directory is read only ... }
SFBFileMgr::GetInfo | SFXDirectory::Exists | SFXDirectory::IsSystem | BREW API IFILEMGR_GetInfo | BREW API IFILEMGR_GetLastError
[ public, static ] SFCError IsSystem( SFXPathConstRef path // directory path BoolPtr result // pointer to receive the result );
The functionc checks whether or not the directory specified in the path argument is a system directory. The result will be returned to the result argument.
Note | |
---|---|
This function internally calls the SFBFileMgr::GetInfo function. |
SFBFileMgr::GetInfo | SFXFile::Exists | SFXFile::IsReadOnly | BREW API IFILEMGR_GetInfo | BREW API IFILEMGR_GetLastError
[ public, static ] SFCError Remove( SFXPathConstRef path // directory path to remove Bool force = false // whether or not to remove a directory recursively );
This function deletes the directory specified in the path argument.
Note | |
---|---|
This function calls the SFBFileMgr::RmDir / SFBFileMgr::Remove function internally. |
If there is no file nor directory in the "dir1" directory, remove the "dir1" directory.
if (SFXDirectory::Remove(SFXPath("/dir1/")) == SFERR_NO_ERROR) { ... }
Remove the "dir1" directory recursively.
if (SFXDirectory::Remove(SFXPath("/dir1/"), false) == SFERR_NO_ERROR) { .... }
SFBFileMgr::RmDir | SFBFileMgr::Remove | SFXDirectory::Create | SFXFile::Remove | BREW API IFILEMGR_RmDir | BREW API IFILE_Remove | BREW API IFILEMGR_GetLastError
[ public ] SFMTYPEDEFCLASS(Enumerator) class Enumerator { public: explicit Enumerator (Void); SFXPath GetNext (Void); Bool HasNext (Void) const; Bool IsValid (Void) const; };
This class represents an enumerator.
The member functions of the SFXDirectory::Enumerator class are as follows:
GetNext | Get the next element. If the next element does not exist, null will be returned. |
HasNext | Check whether or not the next element exists. |
IsValid | Check whether or not the enumerator is valid. |
Get each file within the directory.
SFXPath path; SFXDirectory::Enumerator etor; // get file enumerator SFXDirectory::GetFileEnumerator(SFXPath("/dir1/"), &etor); // enumerate each file while (etor.HasNext()) { // get file path within "/dir1" directory in order path = etor.GetNext(); // display path name on BREW Output Window TRACE("file = %s", path.Get().GetCString()); }
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |