Home
GPL162002 File System User Manual
Contents
1. Generalplus User Manual 3 Function Requirements We need some functions for getting system time We list the spec here 3 1 UserGetDate Function Interface void UserGetdate struct dosdate dd Structure Description struct dosdate unsigned short year unsigned char monthday month Function Definition Demo void UserGetDate struct dosdate dd function body should be adapted by user dd gt year 2004 montre de monthly 257 3 2 UserGetTime Function Interface void UserGetTime struct dostime dt Structure Description struct dostime unsigned char minute hour hundredth second Function Definition Demo void UserGetTime struct dostime dt function body should be adapted by user Cite NS 16 de ME 51 de gt second 37 gt dt gt hundredth 0 E EE O Generalplsu Technology Co Ltd PAGE 40 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 4 Limits and Suggestions Some limits exist in this embedded file system We list them as following 4 1 Maximum Open File Number There are only three file node structure variables in this file system So at the same time only three files can be opened at most 4 2 Implied Open Operations Some functions impliedly require file node structure variables to work properly With out enough file node structure they will report error These requirements for file node structure variables are
2. The function close the file specified by the file node index and flush the buffers associates to the file Required Header close int close int filedes Parameter filedes File node index maybe it s open s return value Return values The normal return value from close is 0 a value of 1 is returned in case of failure Error Code List O Generalplsu Technology Co Ltd PAGE 7 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual EBADF The filedes argument is not a valid file descriptor Example fp open oo ao e o a o le Wwe e ipe O pe os close fp system will write the data to disk 2 3 read The read function reads up to size bytes from the file with descriptor filedes storing the results in the buffer Required Header int read int filedes unsigned long buffer unsigned int size Parameter filedes File node index maybe it s open s return value buffer Buffer pointer It s data pointer given to specify an offset in the SRAM Note it must be byte address Size Reads up to size bytes from the file Note it must be byte size Return values The return value is the number of bytes actually read This might be less than size In case of an error read returns 1 Error codes list Value Description EBADF The filedes argument is not a valid file descriptor or is not open for reading ElO For many devices and for disk files this erro
3. Generalplus GPL162002 File System User Manual V1 0 Sep 22 2006 C GPL162002 File Syste A Generalplus User Manual Important Notice GENERALPLUS TECHNOLOGY CO reserves the right to change this documentation without prior notice Information provided by GENERALPLUS TECHNOLOGY CO is believed to be accurate and reliable However GENERALPLUS TECHNOLOGY CO makes no warranty for any errors which may appear in this document Contact GENERALPLUS TECHNOLOGY CO to obtain the latest version of device specifications before placing your order No responsibility is assumed by GENERALPLUS TECHNOLOGY CO for any infringement of patent or other rights of third parties which may result from its use In addition GENERALPLUS products are not authorized for use as critical components in life support systems or aviation systems where a malfunction or failure of the product may reasonably be expected to result in significant injury to the user without the express written approval of GENERALPLUS GENERALPLUS Documentation The following documents are available from GENERALPLUS These documents provide useful information regarding the software programming and application designing GPL162002 File System User Manual Instruction set user s manual This document explains the GPL162002 file system instruction sets O Generalplsu Technology Co Ltd PAGE 2 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User
4. JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 29 vfsFreeSpace Get the free space of device Required Header visFreeSpace long vfsFreeSpace short driver Parameter driver Specify the device zero based index Return values The free space of device Count in byte Error code list Description EINVAL Parameter list value error Example long freespace freespace vfsFreeSpace 0 get free space of device printf Free space d freespace 2 30 fs safexit Close all the file that opened and unregiste Required Header vis h void fs_safexit void Parameter No parameter Return values No return value Example A el ese sor rene ot me Generalplsu Technology Co Ltd PAGE 30 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 31 fs registerfd Registe the file handle that opened so when call the function fs_safexit it will not be closed Required Header fs registerfa void fs_registerfd int fd Parameter fd Index of the file node Return values No return value Example fd open LPSTR test txt7 O CREAT O RDWR eE return S registerrd fd fs safexit 0 Jj ene file fa wil mor a file chal Uneeoisrc RES ES 2 32 ChangeCodePage Change the Unicode page Required Header ChangeCodePage int ChangeCodePage unsigned int wCodePage Parameter wCodePage
5. Return values The disk no Example int dsk Fd open LEPSPR test txt7 O REWR dsk GetDiskOfFile fd get the file in witch disk close fd Generalplsu Technology Co Ltd PAGE 35 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 38 CreatFileBySize Creat a file by sppointed size Required Header CreatFileBySize int CreatFileBySize LPSTR path unsigned long size Parameter path The file will be creat Size The size of the file that would be created Return values The normal return value from open is a non negative integer file descriptor In the case of an error a value of 1 is returned instead NOTE Return value is a file node index Maybe zero NOTE If creat file success the file data is unpredictable Error Code List attrib does not exist and the directory is unwritable so it cannot be created ENFILE The entire system or perhaps the file system which contains the directory cannot support any additional open files at the moment ENOENT The named file does not exist and O_CREAT is not specified ENAMETOOLONG Filename specified too long ENAMEINVALID Invalid character detected in the filename string ENOSPC No free directory entry left in root directory on a FAT16 or FAT12 file system or the file system doesn t have enough room to extend the directory Example For many devices and for disk files this error code indica
6. A Generalplus User Manual 2 21 findnext Find next appointed name and attribute s file Required Header _findnex int findnext struct into finfo Parameter finfo File information struct Return values This function returns 0 on successful completion and 1 on error Error code list Value Description ENOENT No more file fit the specified file name pattern and the file attribute condition For many devices and for disk files this error code indicates a hardware error Example See _findfirst example 2 22 Copy The function can be used to make a copy for a file Required Header Generalplsu Technology Co Ltd PAGE 23 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual int _copy LPSTR srcfile LPSTR destfile Parameter srcfile It is a source path of file and file name destfile It is a destination path of file and file name Return values This function returns O on successful completion and 1 on error Error code list Value Description ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist Or the file named by filename doesn t exist EEXIST A file named filename already exists EMLINK The parent directory has too many links entries ENOSPC The file system doesn t have enough room to create the new directory ENFILE The entire file system cannot allocate any file node struc
7. BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 14 stat The stat function fills the specified structure with the information about the specified file Required Header int stat LPSTR filename struct stat buf Parameter filename Pointer to a pathname string buf Pointer to a stat structure Data Structure struct stat unsigned char st_mode access attribute of the file see file mode bitwise mask unsigned long st_size the size of the normal file in byte unsigned long st_mtime the last modification time File Mode Bitwise Mask Value Description S READ_ONLY Read only attribute S HIDDEN Hide attribute A hidden file has this attribute S_ SYSTEM System file attribute S DIRECTORY Directories have this attribute S ARCHIVE Normal file attribute Return values The return value is O if the operation is successful or 1 on failure Error code list EINVAL Parameter list error neither the filename nor the buf can be NULL ENOENT The file named by filename doesn t exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Generalplsu Technology Co Ltd PAGE 17 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Example Ce elo aoe mosca estee struct stat statbut time t timel int res Ees s a oe e e
8. Generalplsu Technology Co Ltd PAGE 21 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Required Header _findfist int Tindtifst LPSTR pathname Struct E into FEDIK 10t ecrio Parameter pathname Pointer to a pathname string ffblk Pointer to a f_ info structure struct f_info unsigned char f_attrib file attribute unsigned int f_time file time unsigned int f_date file date unsigned long f_fsize file size char f_name 256 file name attrib D RDONLY Read only file attribute D_HIDDEN Hidden file attribute DDR 1 Directory attribute D ARCHIVE Archive file attribute D ALL All above attribute Return values D SYSTEM System file attribute This function returns O on successful completion and 1 on error Error code list Value Description ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist or when a component is a symbolic link whose target file does not exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions For many devices and for disk files this error code indicates a hardware error Example Vers re CRE pee o Ss print Cnbist siti pattern C GPL162002 File Syste
9. for the directory from which the file is to be removed ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions For many devices and for disk files this error code indicates a hardware error Example 7 gt delec a emporary ee oe if rmdir e unae Crd oe ae aae 2 10 chdir This function is used to set the process s working directory to filename Required Header int chdir LPSTR filename Generalplsu Technology Co Ltd PAGE 13 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Parameter filename Pointer to directory string Return values The normal successful return value from chdir is 0 A value of 1 is returned to indicate an error Error code list ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist ENOTDIR A file that is referenced as a directory component in the file name exists but it isn t a directory ElO For many devices and for disk files this error code indicates a hardware error ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example Ghande Curren diese cor ic Cho hPSIR a te
10. on he S car 7 WEAS moun Oor Oo her opera ions aller Portman m7 _devicemount 0 2 24 _setfattr Change the attributes of the specified file Required Header setfattr vfs h int _setfattr LPSTR filename unsigned short attr Parameter filename Pointer to a path name string which specify the file name whose attributes will be modified Generalplsu Technology Co Ltd PAGE 25 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual attr The attributes will be applied on the specified file Parameter Values Description D The value of attr can be the bitwise OR result of the upper bit values Return values This function returns 0 on successful completion and 1 on error Error code list ENOENT The file doesn t exist EINVAL Parameter list error the filename can not be NULL and the attribute must be the bitwise or result of some of S READ ONLY S HIDDEN S SYSTEM S ARCHIVE bit values ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions For many devices and for disk files this error code indicates a hardware error Example unsigned short attr D_RDONLY D_HIDDEN se la rF LPSIP a l emp Ie eo 2 25 _deleteall Delete all files and folders in the specified directory Required Header _deleteal int _deleteall LPSTR dir Parameter dir To app
11. the file node offset The offset will be set Whence SEEK_SET Sets the file pointer to the value of the offset parameter SEEK CUR Sets the file pointer to its current location plus the value of the offset parameter SEEK _ END Sets the file pointer to the size of the file plus the value of the offset parameter Return values The return value from Iseek is normally the resulting file position measured in bytes from the beginning of the file You can use this feature together with SEEK_CUR to read the current file position If the file position cannot be changed or the operation is in some way invalid Iseek returns a value of 1 Error code list EBADF The fd parameter is not an open file descriptor EINVAL The whence argument value is not valid or seek to an invalid position NOTE Generalplsu Technology Co Ltd PAGE 11 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual When a file was Iseeked to a place where is out of the size of the file and a write operation followed file size extending operation will be performed lt means that file system will read and adapt the FAT for free cluster allocation The clusters are dirty because file system never try to clean the rubbish data on the free clusters Example int fid a a fi d cppen ie a c enp i e a Det eae H set the read write fie pointer tseek fid 100 SEEK SET 2 8 mkdir Directories are created wi
12. A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 27 deviceunmount Umount the specified device flush all cached data associates to the device Required Header int _deviceunmount char diskID Parameter diskID To appoint mounted disked Return values This function returns O on successful completion and 1 on error Error code list Value Description EINVAL Parameter list value error EBUSY The device specified by diskid is busy O Generalplsu Technology Co Ltd PAGE 28 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Example Roe _devicemount 0 e 2 28 _getdiskfree Get information about the space of the specified device Required Header _getdiskiree int _getdiskfree unsigned char driver struct _diskfree t dfreep Parameter driver Specify the device zero based index dfreep The struct of device information struct diskfree t unsigned long total_ clusters unsigned long avail_ clusters unsigned sectors per _ cluster unsigned bytes per sector y Return values This function returns O on successful completion and 1 on error Error code list Value Description EINVAL Parameter list value error Example SEC d R F space aro _ getdiskfree 0 amp space_info ee ae pere n E Eree citusters 0 space mmto aval tes Generalplsu Technology Co Ltd PAGE 29 BR200 A 00001 V1 0
13. Manual GPLI62002 FILE SYSTEM A E AEE 1 USER VIN DA EN ee O EOI ET ER RE 1 L INTRODUCTION ein manie ere tease tetas Gas tse neck eta ewn se eee tDa sea tiers ee anse ee else 6 1 1 GENERAL DESCRIPTION tan 6 2 USER INTERFACE FUCTION 00 ioatea a Eara scnmatiesd a aa A ana aaia 6 2l OTE OA 6 DR LO P A EEE 7 2 3 D e 8 OT OO an 9 2 ND a tiger 9 EEE 10 D ei E A 11 2 8 EEE 12 RRM EEE 13 DWC SC LD EE 13 MA MATTE WD PR EEE 14 A ES GE EEE EEE 15 Ms RENE a eg corsa aeeeaeu eae eace tae 16 LAA GTN EEE EEE 17 eM TOS e 18 LLO ES 19 SN a iia 20 Me OBT SERRCODES ma ee ee seen den an nr se ce ace Do ae eu dd eine 20 DS CSS ERROR lios 21 ZEN POS AR RI E a ee E E tn 21 DN SID ES E A ron A e o uo esa ceeeaatianereeuaooeace ace 23 PME x 6 Wage Po ee O OON OE a een 23 e OR e oO nn A 24 P A DUR ges cence ge PEER O RO 25 O A dido 26 220 DEVICE MOUN a nn ee a ae D mn 27 ON ECM NRC eee 28 Generalplsu Technology Co Ltd PAGE 3 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual A o E ae ace es 29 L29 NS o e EEE 30 Zi OO SMS ooo e ION Co o ssn A A o ee OO E Ron A NENG 30 Reol D a AE EE EA EA E E e EE EE E A tu 31 202 RANES CODE ACA ON AA AS 31 2132 OC D SD EEE 32 2 34 CM Me SE EIE CO O O BUGA O TE A E SE PC nena OTE E T 33 e E A O OS UR O e A es a nop E a 33 DDO o uo o RU en ana cepeantianeeeeu ies ecace ance 34 Lal OPTOBKOT EI E psa ea a oro en ta a ee 35 Zas CRE SA E E EE E A e
14. The unicode page Specify the file system Should be one of these values O Generalplsu Technology Co Ltd PAGE 31 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Description UNI_GBK Select unicode page is GBK UNI_BIG5 Select unicode page is BIG5 UNI_SJIS Select unicode page is SJIS UNI_ENGLISH Select unicode page is ENGLISH UNI_ARABIC Select unicode page is ARABIC UNI_INVALID_TAB Valid unicode page it will default change to UNI_ ENGLISH Return values The unicode page NOTE To support UNI_GBK UNI_BIG5 UNI_SJIS UNI_ARABIC it must be load corresponding Unicode lookup table into NAND FLASH reserve area or code area Example ChangeCodePage UNI_BIG5 change Unicode page to BIG5 2 33 checkfattype get the fat type of the device Required Header nep int checkfattype int drv Parameter drv Zero based driver set index For example index for SD card is 0 Return values Fat type FAT16_Type Format the disk with FAT16 storage format FAT32_Type Format the disk with FAT32 storage format Generalplsu Technology Co Ltd PAGE 32 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Example int fattype fattype checkfattype 0 2 34 GetSectorsPerCluster get the sector number of one cluster Required Header detSectorsPerCluster int GerSectorsPerCluster int drv Parameter drv
15. Zero based driver set index For example index for SD card is 0 Return values Sector number Example TAN n GetsectorsrercCiuster 0 the return value n is sector number of one cluster 2 35 GetCluster Get the cluster address of the file now seek to Required Header _GetCluster long _GetCluster int fd Parameter fd Index of the file node Return values The cluster of the file now seek to Generalplsu Technology Co Ltd PAGE 33 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Example se long buf 100 ES See ee eS eee a eS eee tor 0 ii lt 1003 iA lseek fd i 0x200 0 615256821580 osea 2 36 Clus2Phy Transfer the cluster address to sector address Required Header Cius2Phy long Clus2Phy int dsk unsigned long cl_no Parameter dsk Zero based driver set index For example index for SD card is 0 cl_no cluster address Return values The sector address O Generalplsu Technology Co Ltd PAGE 34 BR200 A 00001 V1 0 JAN 01 2002 Lef Generalplus GPL162002 File Syste User Manual Example i Fonte a I R for i 0 i lt 100 1 lseek fd i 0x200 0 A A er ee pp ee ee eee ee elose td 2 37 GetDiskOfFile Get the file in witch disk EE Required Header GetDiskOfFile vfs h int GetDiskOfFile int fd Parameter fd Index of the file node
16. _init void Parameter No parameter Return values No return value Note All the global variables of file system will be forced into the initial values Typically this function should be Generalplsu Technology Co Ltd PAGE 19 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual used only once at the initialization part of your program Example fs_init _devicemount 0 fp open a o CREAF O RDWR A e AA close fp _deviceunmount 0 2 17 fs uninit unmount all the device Required Header void fs_uninit vola Parameter No parameter Return values No return value Example fs_ init mineral all the globa variable and mount ali the device fs_uninit unmount all the device 2 18 _getfserrcode Get the last error code of the file system Required Header _gettserrcode int _getfserrcode Generalplsu Technology Co Ltd PAGE 20 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Parameter No parameter required Return values Return the last error code value lt can be one of the following values Value 2 19 _cisfserrcode Set the global error code value to zero Required Header void _clsfserrcode Parameter No parameter required Return values No reture value 2 20 _findfirst Find the first appointed name and attribute s file
17. allocate any free cluster for the new write operation Example creat a new file fo open EPoTR melo ext CREAT CRENR rite a String data LO file e Cho e Write the first 14 bytes in SRAM into the file close fp 2 5 readB The readB function reads up to size bytes from the file with descriptor filedes storing the results in the buffer Required Header int readB int filedes unsigned long buffer unsigned int size Parameter filedes File node index maybe it s open s return value O Generalplsu Technology Co Ltd PAGE 9 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual buffer Buffer pointer It s data pointer given to specify an offset in the SRAM Note it must be word address size Reads up to size bytes from the file Note it must be byte size Return values The return value is the number of bytes actually read This might be less than size In case of an error read returns 1 Error codes list The filedes argument is not a valid file descriptor or is not open for reading For many devices and for disk files this error code indicates a hardware error Example eps o ae He o o O nee te le fp INT 2 buffer eo byte form the ile in o he buffer close fp 2 6 writeB The writeB function writes up to size bytes from buffer to the file with descriptor filedes Required Header vis h int writeB
18. case of an error a value of 1 is returned instead NOTE Return value is a file node index Maybe zero Error Code List EACCES The file exists but is not readable writable as requested by the flags argument the file does not exist and the directory is unwritable so it cannot be created EEXIST Both O_CREAT and O_EXCL are set and the named file already exists EISDIR The flags argument specified write access and the file is a directory Generalplsu Technology Co Ltd PAGE 6 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual ENFILE The entire system or perhaps the file system which contains the directory cannot support any additional open files at the moment ENOENT The named file does not exist and O CREAT is not specified ENAMETOOLONG Filename specified too long For many devices and for disk files this error code indicates a hardware error ENAMEINVALID Invalid character detected in the filename string ENOSPC No free directory entry left in root directory on a FAT16 or FAT12 file system or the file system doesn t have enough room to extend the directory Example tinclude lt stdio h gt include lt string h gt nero void main void int fp err Char siring Hello wor dn open with create options i p Open hLPSTR A Ce See Eee eee et ee printf The file test txt was not created n se oone a A ee eC oO eE we e fp EN GE CES 2 2 close
19. e ee eee 36 D OR ae ol 37 A A E E a tt ee an a dt CR on aus 37 2AL EE A TUR 1 PR Ea Ea ec duo uate EE REEN EES 38 A CSST ET SA EU IEE EEE 39 SEUNCTION REQUIREMENTS ti 40 3 1 O E a E i e on 40 e URE TM e EE esee meaeeeenraxoeess 40 LIMITS ANDSUGGES TIONS cae ceca asc cae aaa 41 4 1 MAXIMUM OPEN FILE NUMBER prat on io 41 W INPI D OP OPERATIONS iodo 41 4 3 COPY OPERATION PERFORMANCE casxicsesonnorseinsorasveracyaviseea maman ana ner eat ocean en em Done CI 42 44 MAXIMUM FATHNAME TRINO LENO Westin 42 Generalplsu Technology Co Ltd PAGE 4 BR200 A 00001 V1 0 JAN 01 2002 GPL162002 File Syste AG Sr SO Manual Generalplus Revision History Revision Date By Remark 2006 09 22 Modify for GPL162002 file system N BR200 A 00001 V1 0 JAN 01 2002 O Generalplsu Technology Co Ltd PAGE 5 ej GPL162002 File Syste A Generalplus User Manual Part I Programming Development 1 Introduction 1 1 General Description This guide describes the functionality and user API of DOS FAT FAT32 File System for GPL162002 system 2 User Interface Fuction 2 1 open Open the specified file with the specified mode Required Header INT16 open LPSTR path INT16 open_flag Parameter path Pointer to a path name string flags If set the open operation will fail when trying to create an existent file Return Values The normal return value from open is a non negative integer file descriptor In the
20. e er eo if res returno i timel statbuf st_ mtime res stat file2 txt amp statbuf if res retaro L 1f timel gt statbuf st_mtime in ls o Ss oS else A mm Om Oe 2 15 fstat The fstat function fills the specified structure with the information about the specified file Required Header int fstat int handle struct stat statbuf Parameter handle Index of the file node buf Pointer to a stat structure Data Structure struct stat unsigned char st_mode access attribute of the file see file mode bitwise mask unsigned long st_size the size of the normal file in byte unsigned long st_mtime the last modification time i File Mode Bitwise Mask Generalplsu Technology Co Ltd PAGE 18 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual S READ ONLY Read only attribute Return values The return value is O if the operation is successful or 1 on failure Error code list EINVAL Parameter list error neither the filename nor the buf can be NULL ENOENT The file named by filename doesn t exist ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example ae SESE SEAEETE int res int fg fd open HLPSTR Reddit O0 RHONE res fstat fd amp statbuf if res ts CHOSE 2 16 fs init Initialize file system Required Header void fs
21. ength The length want to delete Return values A return value of 0 indicates successful completion and 1 indicates failure Note The function will convert the offset and the length align to cluster address Example if fd open LPSTR A test bin O_RDWR 1 return 1 De e ePa fea 230900 delete Eee dits Pom gt se x elese tds Generalplsu Technology Co Ltd PAGE 38 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 42 InserPartFile Insert a file into another file Function Required Header int InserPartFile int tagfd int srcfd unsigned long tagoff unsigned long srclen Parameter tagfd The file want to insert data Srcfd The file will be inserted tagoff The target file address you want to insert data srclen The source file data length you want to insert Return values A return value of 0 indicates successful completion and 1 indicates failure Note The function will convert the offset and the length align to cluster address Example if tagfd open GLPSTR A tagfile bin O_RDWR 1 return 1 if srcfd open GLPSTR A srcfile bin O_RDWR 1 return 1 offset 0x800 length 0x5000 InserPartFile tagfd srcfd offset length close tagfd close srcfd unlink GLPSTR A srcfile bin E SCSC C Generalplsu Technology Co Ltd PAGE 39 BR200 A 00001 V1 0 JAN 01 2002 GPL162002 File Syste
22. es The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example enr ds AS ol So o 221 switch _getfserrcode case EACCES D EE EEE C GPL162002 File Syste A Generalplus User Manual 2 13 rename The function can be used to move or rename a file or a directory Required Header rename vfs h int rename LPSTR oldname LPSTR newname Parameter oldname The old name of the file newname The new name of the file Return values 1 returned when error occurred Error code list Value Description EACCES One of the directories containing newname or oldname refuses write permission or newname and oldname are directories and write permission is refused for one of them EEXIST The file or directory newname is already existed ENOENT The file oldname doesn t exist ENOSPC The directory that would contain newname has no room for another entry and there is no space left in the file system to expand it ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example change the filename of filel into file2 int res AAA AA AS eee eee lp A A el if res 1 printf rename failed n Generalplsu Technology Co Ltd PAGE 16
23. int filedes unsigned long buffer unsigned int size Parameter filedes File node index maybe it s open s return value buffer Buffer pointer It s data pointer given to specify an offset in the SRAM Note it must be word address size Writes up to size bytes from buffer to the file Note it must be byte size Return values The return value is the number of bytes actually written This may be size but can always be smaller Your program should always call write in a loop iterating until all the data is written In the case of an error write returns 1 Error code list Generalplsu Technology Co Ltd PAGE 10 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual EBADF The filedes argument is not a valid file descriptor or is not open for writing For many devices and for disk files this error code indicates a hardware error EACCES File access mode error Write to a file which is opened with O_ RDONLY access mode ENOSPC Media is full File system cannot allocate any free cluster for the new write operation Example Crest a new tire fp open LPSTR e OR O RDWR H write a string data to Fite writeB fp buffer 14 Write the first 14 bytes in SRAM into the file close fp 2 7 Iseek The Iseek sets the read write file pointer for the open file specified by the fd Required Header long lseek int fd long offset int whence Parameter fd Index of
24. listed in the following table means file node is visibly required Require file node structure variables number 0 2 Generalplsu Technology Co Ltd PAGE 41 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 4 3 Copy Operation Performance We can not make sure which part of the SRAM is available to work as a data buffer when user is calling _copy to duplicate a file So we declared a 64 byte length unsigned char array as buffer in _copy function The array size is limited by the size of the memory size on board lt means than we can not make a high performance when user is trying to duplicate a file by _copy We strongly suggest the user to write a new copy function instead of the _copy in your application 4 4 Maximum Pathname String Length The maximum pathname string length is 255 bytes includes the drive letter and the character and the backslashes but not includes the terminal zero character O Generalplsu Technology Co Ltd PAGE 42 BR200 A 00001 V1 0 JAN 01 2002
25. mple return value means error occurred bare SO ses pul oo o O ae ic So oc sapo aa 2 11 getcwd Get current directory if success return buffer address else return NULL Required Header LPSTR getcwd LPSTR buffer int size Parameter buffer Pointer to directory string buffer size Maximum length of the directory string can be stored Return values The return value is buffer on success and a null pointer on failure Error code list EINVAL The size argument is zero and buffer is not a null pointer Generalplsu Technology Co Ltd PAGE 14 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual ERANGE The size argument is less than the length of the working directory name You need to prepare a bigger array and try again Example int size 100 char butter005 if getcwd buffer size buffer printf nCurrent path s buffer 2 12 unlink Delete the specified file Required Header int unlink LPSTR filename Parameter filename The file will be unlinked Return values This function returns O on successful completion and 1 on error Error code list Description EACCES Write permission is denied for the directory from which the file is to be removed or the file is busy ENOENT The filename to be deleted doesn t exist Unlink cannot be used to delete the name of a directory To avoid such problems use rmdir to delete directori
26. oint path Return values This function returns O on successful completion and 1 on error Error code list Value Description Generalplsu Technology Co Ltd PAGE 26 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist Or the file named by filename doesn t exist EACCES Write permission is denied for the directory from which the file is to be removed The deleteall process will terminated after such an accident Low level I O error ENFILE The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example dele eal kan be nsed o erp a deer y E a empty a temporary directory inte res res deletea ms os ne empre if res 2 26 devicemount Mount a disk load the information about the device and the file system information on the device Required Header vis h int _devicemount unsigned char diskid Parameter diskid To appoint mounted disked Return values This function returns 0 on successful completion and 1 on error Error code list Description EINVAL Parameter list value error EBUSY The device specified by diskid is busy Low level I O error Example Es init O if devicemount 0 Wicca O Generalplsu Technology Co Ltd PAGE 27 BR200
27. r code indicates a hardware error Example psa fp open PoIP ello txi O nS write fp NS bu fF ter lt lt Hh write 24 bytes start form bufferto file close Ip sytten oo ose E PST cac o ae on o Ca ian o ne read 14 byte form the file into buffer sLese 2 Generalplsu Technology Co Ltd PAGE 8 BR200 A 00001 V1 0 JAN 01 2002 ej GPL162002 File Syste A Generalplus User Manual 2 4 write The write function writes up to size bytes from buffer to the file with descriptor filedes Required Header int write int filedes unsigned long buffer unsigned int size Parameter filedes File node index maybe it s open s return value buffer Buffer pointer It s data pointer given to specify an offset in the SRAM Note it must be byte address Size Writes up to size bytes from buffer to the file Note it must be byte size Return values The return value is the number of bytes actually written This may be s ze but can always be smaller Your program should always call write in a loop iterating until all the data is written In the case of an error write returns 1 Error code list EBADF The filedes argument is not a valid file descriptor or is not open for writing EIO For many devices and for disk files this error code indicates a hardware error EACCES File access mode error Write to a file which is opened with O_RDONLY access mode ENOSPC Media is full File system cannot
28. tes a hardware error fd CreatFileBySize LPSTR HELLO TXT 10000 if fd lt 0 return 1 close fd Generalplsu Technology Co Ltd PAGE 36 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual 2 39 UpdataDir Write the dir info back to the device and flush all the buffers but not close file Required Header UpdataDir int UpdataDir int fd Parameter fd Index of the file node Return values A return value of 0 indicates successful completion and 1 indicates failure Example int dsk Lee Est Ent R Lora write tfd GINB 2 bufterx 2AA UpdataDir fd RE PCS ae ene tO ane a be Fs u rer eElose fa 2 40 FileRepair Repair the bad file that may cause by power supply broken Required Header vis h int FileRepair int fd Parameter fd Index of the file node Return values A return value of 0 indicates successful completion and 1 indicates failure Generalplsu Technology Co Ltd PAGE 37 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual Example int dsk fd open LPSTR test txt O_RDWR FileRepair fd close fd 2 41 DeletePartFile Delete some data of the the file Required Header DeletePartFile int DeletePartFile int fd unsigned long offset unsigned long length Parameter fd Index of the file node offset The address start to delete L
29. th the mkdir function Required Header A int mkdir LPSTR filename Parameter filename Pointer to a string specify the directory name will be created Return values A return value of 0 indicates successful completion and 1 indicates failure Error code list Value Description EACCES Write permission is denied for the parent directory in which the new directory is to be added EEXIST A file named filename already exists ENOSPC The file system doesn t have enough room to create the new directory ENOENT This error is reported when a file referenced as a directory component in the file name doesn t exist The entire file system cannot allocate any file node structure variable for search at the moment See Limits and Suggestions Example void create_temp_directory rome Deh ein Rene pein can MO crea e l enporary Me LOTO printf temporary directory created n C GPL162002 File Syste A Generalplus User Manual 2 9 rmdir The rmdir function deletes a directory Required Header nm int rmdir LPSTR filename Parameter filename Pointer to a string specify the directory name will be deleted Return values This function returns O on successful completion and 1 on error Error code list ENOTEMPTY The directory to be deleted is not empty EACCES Write permission is denied
30. ture variable for search at the moment See Limits and Suggestions Example iae do nn Oa 4 inte res resc R R if res PA amp sen pae t ie pacea errors return 1 2 23 _ format Create a file system with the specified driver Required Header int _format unsigned char drv unsigned char fstype Parameter Generalplsu Technology Co Ltd PAGE 24 BR200 A 00001 V1 0 JAN 01 2002 C GPL162002 File Syste A Generalplus User Manual drv Zero based driver set index For example index for SD card is 0 fstype Specify the file system Should be one of these values FAT16 Type Format the disk with FAT16 storage format FAT32 Type Format the disk with FAT32 storage format FORCE FAT16 Type Format the disk with FAT16 storage format and force rewrite MBR FORCE FAT32 Type Format the disk with FAT32 storage format and force rewrite MBR Return values This function returns O on successful completion and 1 on error Error code list Description For many devices and for disk files this error code indicates a hardware error EINVAL argument list error detected May be the drv value is larger than NBLKDEV or the fstype is greater than FAT32 Type EBUSY The target device is a mounted device Can not format a mounted device Note Format should be used on a device which is not mounted Example fs imt 0 i format 0 FAT 6 Type make a FAT b lile syslem
Download Pdf Manuals
Related Search
Related Contents
IOTech Personal488 DOS and Windows3.X User Manual Télécharger le dossier de candidature (extraits) en format Copyright © All rights reserved.
Failed to retrieve file