PROGRAMMER'S GUIDEFile system library
BackForward
File system library

8. Function specifications-2


8.2 File operations


 List
 Title

Function specifications

 Function

Open file

 Function Name

GFS_Open

 No

2.1

Form
GfsHn GFS_Open (Sint32 fid)
input
fid: file identifier
output
none
Function value
File handle. Returns NULL in case of error.
function
Opens the specified file and returns a file handle.

 List
 Title

Function specifications

 Function

File close

 Function Name

GFS_Close

 No

2.2

Form
void GFS_Close (GfsHn gfs)
input
gfs: file handle
output
none
Function value
none
function
Closes the specified file handle.

 List
 Title

Function specifications

 Function

Move access pointer

 Function Name

GFS_Seek

 No

2.3

Form
Sint32 GFS_Seek (GfsHn gfs, Sint32 off, Sint32 org)
input
 gfs
 : File handle
 off
 : Access pointer movement amount (sector unit)
 org
 : Movement criteria (seek mode: GFS_SEEK_ ~)
output
none
Function value
The position of the access pointer after the move. Negative error code if there is an error.
function
Move the access pointer off sector away from org.
You cannot specify an access pointer outside the range of the file.

 List
 Title

Function specifications

 Function

Get access pointer

 Function Name

GFS_Tell

 No

2.4

Form
Sint32 GFS_Tell (GfsHn gfs)
input
gfs: file handle
output
none
Function value
The position of the access pointer. Negative error code in case of error.
function
Gets the position of the access pointer.

 List
 Title

Function specifications

 Function

Checking the end of the file

 Function Name

GFS_IsEof

 No

2.5

Form
Bool GFS_IsEof (GfsHn gfs)
input
gfs: file handle
output
none
Function value
End-of-file flag.
function
Checks if the access pointer has reached the end of the file. Function values have the following meanings:
 TRUE
 : The end of the file has been reached.
 FALSE
 : The end of the file has not been reached.
If an invalid file handle is entered, it is considered that the end of the file has been reached.

 List
 Title

Function specifications

 Function

Conversion from byte size to sector length

 Function Name

GFS_ByteToSct

 No

2.6

Form
Sint32 GFS_ByteToSct (GfsHn gfs, Sint32 nbyte)
input
 gfs
 : File handle
 nbyte
 : Number of bytes
output
none
Function value
Number of sectors. Negative error code in case of error.
function
Converts units from bytes to sectors (nsct). The sector length nsct is calculated by the following formula.

nsct = (nbyte + file sector length-1) / file sector length;

If the sector length is indefinite (a mixture of Form1 and Form2), 0 is the function value.

 List
 Title

Function specifications

 Function

Get file size

 Function Name

GFS_GetFileSize

 No

2.7 2.7

Form
void GFS_GetFileSize (GfsHn gfs, Sint32 * sctsize, Sint32 * nsct, Sint32 * lastsize)
input
gfs: File handle
output
 sctsize
 : Sector length
 nsct
 : Number of sectors (including last sector)
 lastsize
 : Number of bytes occupied by file data in the last sector
Function value
none
function
Gets the information to determine the size of the file. You can suppress the output of that information by specifying NULL for sctsize, nsct, and lastsize. The file size (fsize) is calculated by the following formula.
fsize = sctsize * (nsct-1) + lastsize;
remarks
In a file in which Form1 and Form2 are mixed, both sctsize and lastsize will be 0.

 List
 Title

Function specifications

 Function

Get file information

 Function Name

GFS_GetFileInfo

 No

2.8

Form
void GFS_GetFileInfo (GfsHn gfs, Sint32 * fid, Sint32 * fn, Sint32 * fsize, Sint32 * atr)
input
gfs: File handle
output
 fid
 : File identifier
 fn
 : File number
 fsize
 : File size (unit: bytes)
 atr
 : File attributes
Function value
none
function
Get file information. You can suppress the output of that information by specifying NULL for fid, fn, fsize, and atr. Since the file size is the value recorded in the directory information, the size of one sector is calculated as 2048 bytes.

 List
 Title

Function specifications

 Function

Get the number of sectors in the CD buffer partition

 Function Name

GFS_GetNumCdbuf

 No

2.9

Form
Sint32 GFS_GetNumCdbuf (GfsHn gfs)
input
gfs: file handle
output
none
Function value
Number of sectors in the CD buffer partition
function
Gets the number of sectors existing in the CD buffer partition.

BackForward
PROGRAMMER'S GUIDEFile system library
Copyright SEGA ENTERPRISES, LTD., 1997