FSErr ChangeCurDir(const char far *pathName)
unsigned short GetDirFileNumber(FileHndl dir)
void GetFileName(FileHndl dir,unsigned short fileIdx,char far *fileName)
bool IsDir(FileHndl dir,unsigned short fileIdx)
bool IsFileDir(FileHndl fileH)
FileHndl MakeDir(const char far *name)
FileHndl FileOpen(const char far *name,FileOpenMode mode)
unsigned long FileRead(FileHndl fileH,MemHndl bufH,unsigned long size)
unsigned long FileWrite(FileHndl fileH,MemHndl bufH,unsigned long size)
FSErr FileSeek(FileHndl fileH,unsigned long pos)
unsigned long FileTell(FileHndl fileH)
unsigned long GetFileSize(FileHndl fileH)
void FileClose(FileHndl fileH)
FSErr DeleteFile(const char far *pathName)
FSErr GetLastError()
const char far *GetCurrentDirectory()
void FileSysManagement()
void TrimFile(FileHndl fileH)
FSErr FileRename(const char far *srcPath,const char far *destPath)
void FileSysSetMgmtProgressCB(FileMgmtProgressCBFunc cb)
unsigned long FileSysAvailableStorage()
Mini File System is a file system for CASIO pocket viewer. It is a Unix style file system, that organize files in a tree of directories. The root of the tree is "root directory" which has a name "/". '/' also is the path seperator (e.g. "/MiniBook/Res/de.res" is the path name of the file, whose name is "de.res" and resides in the directory "Res". The directory "Res" resides in directory "MiniBook". The directory "MiniBook" resides in root directory. ).
There are already several PV applications benifits from MFS, e.g. MiniBook 2.5x, MFSTool. Mini File System Library is a library module that enables PV developers to use MFS in their application.
Since MiniFS.lib has integrated MemMgr.lib, and MemPool.lib, you need to uninstall them if previously installed.
To do so:
Remove the corresponding lines from link2p.dat file.
To install MFS Lib:
Unzip the package
Copy MiniFS.lib to your library folder
Copy all .h files to your include folder
Change your makefile to link the library
(For example of installing library, please refer to http://groups.yahoo.com/group/minibook/files/Development/DevFrameWork.zip)
Before you can use any MFS functions, please make sure that you have created memory pool.
To Create memory pool:
#include "FileSys.h"
Define a global array of byte to be used as memory pool. Call MemMgrInit() at the begining of main() function.
e.g.
static byte far _memPool[1024*20];
...
void main()
{
MemMgrInit(_memPool,sizeof(_memPool));
...
}
It is recommanded to create a memory pool as large as possible. (Normally, should not be less than 10 k). Using MemMgr to allocate memory in rest of your program is encouraged.
FSNoErr if no error, else error code
This function change current directory to specified directory. Current directory is used to interpret relative path name. There are two kinds of pathname
There are two special path name:
Number of files in the directory, including "..". If the file handle is not a directory, returns 0.
Get number of files and directories in the directory. Each directory contains at least 1 directory: "..". Therefore, a 0 return value means the file handle passed in is not a directory.
None.
Get number of files and directories in the directory. Each directory contains at least 1 directory: "..". Therefore, a 0 return value means the file handle passed in is not a directory.
TRUE if the file is directory, else FALSE
Check whether a file in the specified directory is a directory. This function is used to check a file's attribute without open that file.
TRUE if the file is directory, else FALSE
Check whether a file is a directory. This function is used to check a opened file's attribute.
If success, it opens the created directory as kFSReadOnly (directory can only be openned as kFSReadOnly), and returns the file handle of the created directory. If fail, it returns NULL.
Create directory of the specified path name.
If success, it opens the file, and returns the. If fail, it returns NULL.
Open a file in specified mode.
It is important that all opened files/directories are closed at the program exit. Otherwise, all RAM cached data will be lost, and it could cause file system corrupt.
byte buf[BUF_SIZE];
byte far *mP = buf;
FileHndl fileH;
...
FileRead(fileH,&mP,BUF_SIZE);
...
Number of bytes actually read.
Read a file from current file access point. After read, the file access point is increased by number of bytes actually read.
byte buf[BUF_SIZE];
byte far *mP = buf;
FileHndl fileH;
...
FileWrite(fileH,&mP,BUF_SIZE);
...
Number of bytes actually written.
Write a file from current file access point. If current access point is the end of the file, the file will be expanded to allow data to be written. After write, the file access point is increased by number of bytes actually written.
FSNoErr if success, else the error code.
Set the file access point of the specified file. If fail, the access point is not changed.
Value of current access point.
Get the file access point of the specified file.
Size of the file in number of bytes.
Get the file size.
None.
Close the file.
After the file is closed, the fileH is invalid, therefore it should not be used in any file functions, otherwise, it may corrupt the file system.
FSNoErr if success, else the error code.
Delete a file.
If the file is open, it must be closed before it can be deleted, otherwise, it may corrupt the file system.
None.
Error code of last file system function.
Use this function to get the error code, if the file function does not return error code (e.g. FileRead())
None.
Current directory's absolute path name.
Get the absolute path name of current directory. Since the string is dynamiclly allocated and maintained by file system, it should be used immediatly after call this function. If you store this pointer in a variable, you must make sure that between you call the function and you use the stored pointer, there is no function call that could cause memory purge. Almost all file system functions may cause memory purge. Therefore, it is recommanded that you call this function at the place you use the retruned pointer.
None.
None.
Perform file system management. This will release all unused (deleted) blocks, and do a pocket viewer memory management. It may take a long time.
None.
Remove data that after current access point from the file. This is the only function that could reduce the file's size.
FSNoErr if success, else the error code.
Rename a file or directory.
None
specify a callback function for the file system management process. The prototype of the callback is
typedef bool (*FileMgmtProgressCBFunc)(unsigned long maxVal, unsigned long curVal);
the process has two steps:
Number of bytes available in the file system.
Get the number of bytes available in the file system.