PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBFileMgr
Wrapper Class for the IFileMgr interface.
#include <SFBFileMgr.h.hpp>
class SFBFileMgr : public SFBBase;
SFMTYPEDEFWRAPPER(SFBFileMgr)

Inheritance diagram

 Inheritance diagram of SFBFileMgrClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
O O O O

Reference

BREW API IFileMgr

Member

Public Functions
SFCError CheckPathAccess( ACharConstPtr path , UInt32 desiredRights , UInt32Ptr actualRights )
Check whether the caller has certain rights on the input path.
SFCError CheckPathAccess( SFXAnsiStringConstRef path , UInt32 desiredRights , UInt32Ptr actualRights )
Check whether the caller has certain rights on the input path.
SFCError EnumInit( ACharConstPtr dirName , Bool dir = false )
Initialize the SFBFileMgr Interface object for the enumeration of the files/directories in the specified directory.
SFCError EnumInit( SFXAnsiStringConstRef dirName , Bool dir = false )
Initialize the SFBFileMgr Interface object for the enumeration of the files/directories in the specified directory.
Bool EnumNext( AEEFileInfoPtr info )
Return file information for the next file/directory.
Bool EnumNextEx( AEEFileInfoExPtr infoEx )
Return extended file information for the next file/directory.
SFCError GetFileUseInfo( AEEFileUseInfoPtr useInfo )
Get the file usage infomation for the module.
AEEFileUseInfo GetFileUseInfo( Void )
Get the file usage infomation for the module.
UInt32 GetFreeSpace( UInt32Ptr total = null )
Get the number of free bytes currently available on file system.
SFCError GetFreeSpaceEx( ACharConstPtr path , UInt32Ptr total , UInt32Ptr free )
Get the number of free bytes currently available on file system.
SFCError GetFreeSpaceEx( SFXAnsiStringConstRef path , UInt32Ptr total , UInt32Ptr free )
Get the number of free bytes currently available on file system.
SFCError GetInfo( ACharConstPtr fileName , AEEFileInfoPtr info )
Get the information on a file identified by a file name.
SFCError GetInfo( SFXAnsiStringConstRef fileName , AEEFileInfoPtr info )
Get the information on a file identified by a file name.
AEEFileInfo GetInfo( SFXAnsiStringConstRef fileName )
Get the information on a file identified by a file name.
SFCError GetInfoEx( ACharConstPtr fileName , AEEFileInfoExPtr infoEx )
Get the extended information of a file identified by a file name.
SFCError GetInfoEx( SFXAnsiStringConstRef fileName , AEEFileInfoExPtr infoEx )
Get the extended information of a file identified by a file name.
SFCError GetLastError( Void )
Get the reason for the failure when a file operation performed by the applet has failed.
SFCError MkDir( ACharConstPtr dirName )
Create a directory, specified by a directory name.
SFCError MkDir( SFXAnsiStringConstRef dirName )
Create a directory, specified by a directory name.
static
SFBFileMgrSmp
NewInstance( SFCErrorPtr exception = null )
Create a new SFBFileMgr instance.
static
SFBFileMgrSmp
NewInstance( AEECLSID id , SFCErrorPtr exception = null )
Create a new SFBFileMgr instance.
SFBFileSmp OpenFile( ACharConstPtr fileName , AEEOpenFileMode mode )
Open a file in specified mode.
SFBFileSmp OpenFile( SFXAnsiStringConstRef fileName , AEEOpenFileMode mode )
Open a file in specified mode.
SFCError Remove( ACharConstPtr fileName )
Remove a file identified by a given filename.
SFCError Remove( SFXAnsiStringConstRef fileName )
Remove a file identified by a given filename.
SFCError Rename( ACharConstPtr srcFileName , ACharConstPtr destFileName )
Rename the file from the source name to the destination name.
SFCError Rename( SFXAnsiStringConstRef srcFileName , SFXAnsiStringConstRef destFileName )
Rename the file from the source name to the destination name.
SFCError ResolvePath( ACharConstPtr path , ACharPtr canonicalPath , UInt32Ptr canonicalPathLen )
Resolve a filesystem path to the BREW canonical form.
SFCError ResolvePath( SFXAnsiStringConstRef path , SFXAnsiStringPtr canonicalPath )
Resolve a filesystem path to the BREW canonical form.
SFCError RmDir( ACharConstPtr dirName )
Remove a directory identified by a given directory name.
SFCError RmDir( SFXAnsiStringConstRef dirName )
Remove a directory identified by a given directory name.
SFCError SetDescription( ACharConstPtr fileName , WCharPtr description )
Set the file description that is part of the extended file information.
SFCError SetDescription( SFXAnsiStringConstRef fileName , SFXWideStringPtr description )
Set the file description that is part of the extended file information.
SFCError Test( ACharConstPtr name )
Test if the specified file/directory exists.
SFCError Test( SFXAnsiStringConstRef name )
Test if the specified file/directory exists.
SFCError UnUse( ACharConstPtr fileName )
Remove the class ID of the calling app from the list of classes using the specified file.
SFCError UnUse( SFXAnsiStringConstRef fileName )
Remove the class ID of the calling app from the list of classes using the specified file.
SFCError Use( ACharConstPtr fileName )
Add class ID of the calling app to the list of classes using the specified file.
SFCError Use( SFXAnsiStringConstRef fileName )
Add class ID of the calling app to the list of classes using the specified file.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBFileMgr::CheckPathAccess
Check whether the caller has certain rights on the input path.
[ public ]
SFCError CheckPathAccess(
    ACharConstPtr path       // the path to be checked
    UInt32 desiredRights     // the desired rights
    UInt32Ptr actualRights   // filled with the actual rights, ignored if null
);
[ public ]
SFCError CheckPathAccess(
    SFXAnsiStringConstRef path   // the path to be checked
    UInt32 desiredRights         // the desired rights
    UInt32Ptr actualRights       // filled with the actual rights, ignored if null
);

Argument

desiredRights

A bitwise-or of the following.

  • AEEFP_READ : access to read-path is desired
  • AEEFP_WRITE : access to write-path is desired
  • AEEFP_CREATE : access to create-path is desired
  • AEEFP_DELETE : access to delete-path is desired

Return value

  • If successful: SFERR_NO_ERROR
  • If access is denied: EPRIVLEVEL
  • If the path cannot be resolved or checked: EBADFILENAME

Version

Introduced BREW Client 3.1

Reference

BREW API IFILEMGR_CheckPathAccess | BREW API IFILEMGR_ResolvePath | BREW API IFILEMGR_CheckPrivLevel | SFBFileMgr::ResolvePath | SFBShell::CheckPrivLevel


SFBFileMgr::EnumInit
Initialize the SFBFileMgr Interface object for the enumeration of the files/directories in the specified directory.
[ public ]
SFCError EnumInit(
    ACharConstPtr dirName   // null terminated string containing the root directory name
    Bool dir = false        // when true, enumerate directories
);
[ public ]
SFCError EnumInit(
    SFXAnsiStringConstRef dirName   // null terminated string containing the root directory name
    Bool dir = false                // when true, enumerate directories
);

BREW API IFILEMGR_EnumInit | SFBFileMgr::EnumNext | FileInfo


SFBFileMgr::EnumNext
Return file information for the next file/directory.
[ public ]
Bool EnumNext(
    AEEFileInfoPtr info   // placeholder for file information
);

Example

Get file information for the next file, show file name as logs.

SFBFileMgrSmp   fileMgr = SFBFileMgr::NewInstance();
FileInfo        info    = {0};

// initializing for the enumeration of the files.
if (fileMgr->EnumInit("new_dir", false) == SUCCESS) {

    // get the information of next file.
    fileMgr->EnumNext(&info);

    // show file name in the log.
    DBGPRINTF("file name : %s", info.szName);
}

Reference

BREW API IFILEMGR_EnumNext | SFBFileMgr::EnumInit | FileInfo


SFBFileMgr::EnumNextEx
Return extended file information for the next file/directory.
[ public ]
Bool EnumNextEx(
    AEEFileInfoExPtr infoEx   // placeholder for extended file information
);

Example

Get file extended information for the next file, show file name as logs.

SFBFileMgrSmp       fileMgr          = SFBFileMgr::NewInstance();
AEEFileInfoEx       infoEx           = {0};
AChar               fileName[128]    = {0};
WChar               description[128] = {0};
AEECLSID            cls[32]          = {0};

// initializing for the enumeration of the files.
if (fileMgr->EnumInit("new_dir", false) == SUCCESS) {

    // initializing the AEEFileInfoEx structure.
    infoEx.nStructSize      = sizeof(AEEFileInfoEx);
    infoEx.pszFile          = fileName;
    infoEx.nMaxFile         = 128;
    infoEx.pszDescription   = description;
    infoEx.nDescriptionSize = 128 * sizeof(WChar);
    infoEx.pClasses         = cls;
    infoEx.nClassesSize     = 32 * sizeof(AEECLSID);

    // get the extended information of next file.
    fileMgr->EnumNextEx(&infoEx);

    // show file name in the log.
    DBGPRINTF("file name : %s", infoEx.pszFile);
}

Reference

BREW API IFILEMGR_EnumNextEx | SFBFileMgr::EnumInit | AEEFileInfoEx


SFBFileMgr::GetFileUseInfo
Get the file usage infomation for the module.
[ public ]
SFCError GetFileUseInfo(
    AEEFileUseInfoPtr useInfo   // placeholder for file usage information
);
[ public ]
AEEFileUseInfo GetFileUseInfo(Void);

Example

Get the file usage infomation.

SFBFileMgrSmp       fileMgr = SFBFileMgr::NewInstance();
AEEFileUseInfo      info    = {0};

// get the file usage infomation.
fileMgr->GetFileUseInfo(&info);

Reference

BREW API IFILEMGR_GetFileUseInfo | AEEFileUseInfo


SFBFileMgr::GetFreeSpace
Get the number of free bytes currently available on file system.
[ public ]
UInt32 GetFreeSpace(
    UInt32Ptr total = null   // placeholder for the total room in the file system
);

Reference

BREW API IFILEMGR_GetFreeSpace


SFBFileMgr::GetFreeSpaceEx
Get the number of free bytes currently available on file system.
[ public ]
SFCError GetFreeSpaceEx(
    ACharConstPtr path   // pointer a path string that specifies the file system whose space details are required
    UInt32Ptr total      // placeholder for the total room in the file system
    UInt32Ptr free       // placeholder for the available space in the file system
);
[ public ]
SFCError GetFreeSpaceEx(
    SFXAnsiStringConstRef path   // a path string that specifies the file system whose space details are required
    UInt32Ptr total              // placeholder for the total room in the file system
    UInt32Ptr free               // placeholder for the available space in the file system
);

Version

Introduced BREW Client 3.1.3

Reference

BREW API IFileMgr_GetFreeSpaceEx


SFBFileMgr::GetInfo
Get the information on a file identified by a file name.
[ public ]
SFCError GetInfo(
    ACharConstPtr fileName   // null terminated string containing the file name
    AEEFileInfoPtr info      // placeholder for file information
);
[ public ]
SFCError GetInfo(
    SFXAnsiStringConstRef fileName   // null terminated string containing the file name
    AEEFileInfoPtr info              // placeholder for file information
);
[ public ]
AEEFileInfo GetInfo(
    SFXAnsiStringConstRef fileName   // null terminated string containing the file name
);

Example

Get the information of a file.

SFBFileMgrSmp   fileMgr = SFBFileMgr::NewInstance();
FileInfo        info    = {0};

// get the information of a file.
fileMgr->GetInfo("sample.txt", &info);

Reference

BREW API IFILEMGR_GetInfo | FileInfo | SFBFile::GetInfoEx


SFBFileMgr::GetInfoEx
Get the extended information of a file identified by a file name.
[ public ]
SFCError GetInfoEx(
    ACharConstPtr fileName    // null terminated string containing a file name
    AEEFileInfoExPtr infoEx   // placeholder for extended file information
);
[ public ]
SFCError GetInfoEx(
    SFXAnsiStringConstRef fileName   // null terminated string containing a file name
    AEEFileInfoExPtr infoEx          // placeholder for extended file information
);

Example

Get the extended information of a file.

SFBFileMgrSmp       fileMgr          = SFBFileMgr::NewInstance();
AEEFileInfoEx       infoEx           = {0};
AChar               fileName[128]    = {0};
WChar               description[128] = {0};
AEECLSID            cls[32]          = {0};

// initialize the AEEFileInfoEx structure.
infoEx.nStructSize      = sizeof(AEEFileInfoEx);
infoEx.pszFile          = fileName;
infoEx.nMaxFile         = 128;
infoEx.pszDescription   = description;
infoEx.nDescriptionSize = 128 * sizeof(WChar);
infoEx.pClasses         = cls;
infoEx.nClassesSize     = 32 * sizeof(AEECLSID);

// get the extended information of a file.
fileMgr->GetInfoEx("sample.txt", &infoEx);

Reference

BREW API IFILEMGR_GetInfoEx | AEEFileInfoEx | SFBFile::GetInfoEx


SFBFileMgr::GetLastError
Get the reason for the failure when a file operation performed by the applet has failed.
[ public ]
SFCError GetLastError(Void);

Reference

BREW API IFILEMGR_GetLastError


SFBFileMgr::MkDir
Create a directory, specified by a directory name.
[ public ]
SFCError MkDir(
    ACharConstPtr dirName   // null terminated string containing a directory name
);
[ public ]
SFCError MkDir(
    SFXAnsiStringConstRef dirName   // null terminated string containing a directory name
);

Example

Create a directory.

SFBFileMgrSmp  fileMgr = SFBFileMgr::NewInstance();

// create a directory.
fileMgr->MkDir("new_dir");

Reference

BREW API IFILEMGR_MkDir | SFBFileMgr::RmDir


SFBFileMgr::NewInstance
Create a new SFBFileMgr instance.
[ public, static ]
SFBFileMgrSmp NewInstance(
    SFCErrorPtr exception = null   // Error
);
[ public, static ]
SFBFileMgrSmp NewInstance(
    AEECLSID id                    // Class ID
    SFCErrorPtr exception = null   // Error
);

SFBFileMgr::OpenFile
Open a file in specified mode.
[ public ]
SFBFileSmp OpenFile(
    ACharConstPtr fileName   // null terminated string containing the file name
    AEEOpenFileMode mode     // file open mode
);
[ public ]
SFBFileSmp OpenFile(
    SFXAnsiStringConstRef fileName   // null terminated string containing the file name
    AEEOpenFileMode mode             // file open mode
);

Example

Create a file.

SFBFileMgrSmp  fileMgr = SFBFileMgr::NewInstance();
SFBFileSmp     file;

// create a file.
file = fileMgr->OpenFile("sample.txt",_OFM_CREATE);

if (file != null) {

    // if use SophiaFramework Smart Pointer ( SFXBrewPointer ),
	// the close of file will be automatically done.
    // if users want to close a file manually, use
    //
    // file.Release();
}

Reference

BREW API IFILEMGR_OpenFile | SFBFileMgr::MkDir


SFBFileMgr::Remove
Remove a file identified by a given filename.
[ public ]
SFCError Remove(
    ACharConstPtr fileName   // null terminated string containing the name of the file to to be removed
);
[ public ]
SFCError Remove(
    SFXAnsiStringConstRef fileName   // null terminated string containing the name of the file to to be removed
);

Example

Remove a file.

SFBFileMgrSmp  fileMgr = SFBFileMgr::NewInstance();

// remove a file.
fileMgr->Remove("sample.txt");

Reference

BREW API IFILEMGR_Remove


SFBFileMgr::Rename
Rename the file from the source name to the destination name.
[ public ]
SFCError Rename(
    ACharConstPtr srcFileName    // source file to be renamed
    ACharConstPtr destFileName   // destination file
);
[ public ]
SFCError Rename(
    SFXAnsiStringConstRef srcFileName    // source file to be renamed
    SFXAnsiStringConstRef destFileName   // destination file
);

Example

Rename a directory.

SFBFileMgrSmp  fileMgr = SFBFileMgr::NewInstance();

// rename a directory.
fileMgr->Rename("tmp_dir","new_dir");

Reference

BREW API IFILEMGR_Rename | SFBFileMgr::EnumNext


SFBFileMgr::ResolvePath
Resolve a filesystem path to the BREW canonical form.
[ public ]
SFCError ResolvePath(
    ACharConstPtr path           // the path to be resolved
    ACharPtr canonicalPath       // the output buffer, holds the canonical path, may be null
    UInt32Ptr canonicalPathLen   // On entry, this provides the maximum number of bytes to write into pszOut[]. On exit, this holds the number of bytes written to pszOut[].
);
[ public ]
SFCError ResolvePath(
    SFXAnsiStringConstRef path       // the path to be resolved
    SFXAnsiStringPtr canonicalPath   // the output buffer, holds the canonical path
);

Return value

  • If successful: SFERR_NO_ERROR
  • If the argument is invalid: SFERR_INVALID_PARAM
  • If failed: SFERR_FAILED
  • If canonicalPath is non-null, but *canonicalPathLen cannot hold the resolved path: EBUFFERTOOSMALL

Version

Introduced BREW Client 3.1

Reference

BREW API IFILEMGR_ResolvePath | BREW API IFILEMGR_CheckPathAccess


SFBFileMgr::RmDir
Remove a directory identified by a given directory name.
[ public ]
SFCError RmDir(
    ACharConstPtr dirName   // null terminated string containing a directory name
);
[ public ]
SFCError RmDir(
    SFXAnsiStringConstRef dirName   // null terminated string containing a directory name
);

Example

Remove a directory.

SFBFileMgrSmp  fileMgr = SFBFileMgr::NewInstance();

// remove a directory.
fileMgr->RmDir("tmp_dir");

Reference

BREW API IFILEMGR_RmDir | SFBFileMgr::MkDir


SFBFileMgr::SetDescription
Set the file description that is part of the extended file information.
[ public ]
SFCError SetDescription(
    ACharConstPtr fileName   // null terminated string containing a file name
    WCharPtr description     // wide character string containing the description
);
[ public ]
SFCError SetDescription(
    SFXAnsiStringConstRef fileName   // null terminated string containing a file name
    SFXWideStringPtr description     // wide character string containing the description
);

Example

Set the file description

SFBFileMgrSmp       fileMgr = SFBFileMgr::NewInstance();
SFXWideString       description("Sample File");

// set the file description
fileMgr->SetDescription("sample.txt", &description);

Refefence

BREW API IFILEMGR_SetDescription | SFBFileMgr::EnumInit


SFBFileMgr::Test
Test if the specified file/directory exists.
[ public ]
SFCError Test(
    ACharConstPtr name   // null terminated string containing file/directory name
);
[ public ]
SFCError Test(
    SFXAnsiStringConstRef name   // null terminated string containing file/directory name
);

Example

Check if a file exists.

SFBFileMgrSmp       fileMgr = SFBFileMgr::NewInstance();

// check if a file exists.
if (fileMgr->Test("sample.txt") == SUCCESS ) {
    // something to do if a file exists.
    //                 ...
    //                 ...
    //                 ...
}

Reference

BREW API IFILEMGR_Test


SFBFileMgr::UnUse
Remove the class ID of the calling app from the list of classes using the specified file.
[ public ]
SFCError UnUse(
    ACharConstPtr fileName   // null terminated string containing a file name
);
[ public ]
SFCError UnUse(
    SFXAnsiStringConstRef fileName   // null terminated string containing a file name
);

Description

The specified file will be deleted when the last app indicates that the file is no longer used or SFBFileMgr::Remove is called.

Reference

BREW API IFILEMGR_UnUse | SFBFileMgr::Use | SFBFileMgr::GetInfoEx | AEEFileInfoEx


SFBFileMgr::Use
Add class ID of the calling app to the list of classes using the specified file.
[ public ]
SFCError Use(
    ACharConstPtr fileName   // null terminated string containing a file name
);
[ public ]
SFCError Use(
    SFXAnsiStringConstRef fileName   // null terminated string containing a file name
);

Description

The specified file will not be deleted until the last app indicates that the file is no longer used or SFBFileMgr::Remove is called.

Reference

BREW API IFILEMGR_Use | SFBFileMgr::UnUse | SFBFileMgr::GetInfoEx | AEEFileInfoEx