#define OPEN_MAX 20 /* Maximum number of files to open simultaneously */ #define MAX_DIR 10 /* Maximum number of directory information */Uint32 work[GFS_WORK_SIZE(OPEN_MAX)/4]; /* Library work area */ GfsDirTbl dirtbl; /* Directory information management structure */ GfsDirId dir[MAX_DIR]; /* Directory information storage area */
GFS_DIRTBL_TYPE(&dirtbl) = GFS_DIR_ID; /* Directory information storage area type */ GFS_DIRTBL_NDIR(&dirtbl) = MAX_DIR; /* Directory information storage area */ /* Maximum number of elements */ GFS_DIRTBL_DIRID(&dirtbl) = dir; /* Directory information storage area */ /* address */ GFS_Init(OPEN_MAX, work, &dirtbl);
Figure 3.1 Access by file identifier
Figure 3.2 Directory information settings
#define MAX_DIR 10 /* Maximum number of directory information */ GfsDirTbl dirtbl; /* Directory information storage area */ GfsDirId dirid[MAX_DIR]; /* Directory information storage area */ Sint32 dir_fid; /* Contains the directory file identifier */ Sint32 fid; /* Contains the identifier of the file to be accessed */ GfsHn gfs; /* File handle of the file to access */ GFS_DIRTBL_TYPE (&dirtbl) = GFS_DIR_ID; GFS_DIRTBL_NDIR (&dirtbl) = MAX_DIR; GFS_DIRTBL_DIRID(&dirtbl) = dirid; GFS_LoadDir(dir_fid, &dirtbl); /* Load directory information */ GFS_SetDir(&dirtbl); /* Set current directory */ /* Set the identifier of the file to access fid */ gfs = GFS_Open(fid); /* * File access here */ GFS_Close(gfs);
#define MAX_DIR1 10 /* Maximum number of directory information for dir_fid1 */ #define MAX_DIR2 10 /* Maximum number of directory information for dir_fid2 */ GfsDirTbl curdir; /* Current directory at this point */ GfsDirTbl dirtbl1, dirtbl2; /* Directory information management area */ GfsDirId dirid1[MAX_DIR1]; /* Directory information storage area */ GfsDirId dirid2[MAX_DIR2]; /* Directory information storage area */ Sint32 dir_fid1, dir_fid2; /* Contains the directory file identifier */ Sint32 fid1, fid2; /* Contains the identifier of the file to be accessed */ GfsHn gfs1, gfs2; /* File handle of the file to access */ /* Read the directory information of dir_fid1 in the current directory */ GFS_DIRTBL_TYPE (&dirtbl1) = GFS_DIR_ID; GFS_DIRTBL_NDIR (&dirtbl1) = MAX_DIR; GFS_DIRTBL_DIRID(&dirtbl1) = dirid1; GFS_LoadDir(dir_fid1, &dirtbl1); /* Read the directory information of dir_fid2 in the current directory */ GFS_DIRTBL_TYPE (&dirtbl2) = GFS_DIR_ID; GFS_DIRTBL_NDIR (&dirtbl2) = MAX_DIR; GFS_DIRTBL_DIRID(&dirtbl2) = dirid2; GFS_LoadDir(dir_fid2, &dirtbl2); /* Open file fid1 in directory dir_fid1 */ GFS_SetDir (&dirtbl1); gfs1 = GFS_Open(fid1); /* Open file fid2 in directory dir_fid2 */ GFS_SetDir (&dirtbl2); gfs2 = GFS_Open(fid2); /* * File access here */ GFS_Close(gfs1); GFS_Close(gfs2);
[Example] /* Open the file specified by file name */ GfsHn OpenByName(Sint8 *fname) { Sint32 fid = GFS_NameToId(fname);if (fid< 0) { return NULL; } return GFS_Open(fid); }
Strong Points | Cons |
---|---|
- Less host memory usage. | ・Access files in different directories |
・CD back that can be used by the application | |
- File name cannot be used. |