osPfsAllocateFile.3p 3.17 KB
.TH osPfsAllocateFile 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
osPfsAllocateFile, osPfsDeleteFile, osPfsFindFile \- Allocate, delete or search a specified file.
.SH SYNOPSIS
.nf
\f3
.Op c
#include <ultra64.h>
.sp .8v
s32 osPfsAllocateFile(OSPfs \(**pfs, u16 company_code, u32 game_code,
                      u8 \(**game_name, u8 \(**ext_name, int length,
                      s32 \(**file_no);
.sp .8v
s32 osPfsDeleteFile(OSPfs \(**pfs, u16 company_code, u32 game_code,
                    u8 \(**game_name, u8 \(**ext_name);
.sp .8v
s32 osPfsFindFile(OSPfs \(**pfs, u16 company_code, u32 game_code,
                  u8 \(**game_name, u8 \(**ext_name, s32 \(**file_no);
.Op
\f1
.fi
.SH DESCRIPTION
.sp
The 
.I osPfsAllocateFile
function creates a file whose name is given by
.I company_code, game_code, game_name, 
and 
.I ext_name.
If the file exists, an error code
.I PFS_ERR_EXIST
is returned. Otherwise, the file is created and the size of the
file will be set to
.I length
bytes which must be multiple of 
.I BLOCKSIZE
bytes. The maximum size of a file is 
.I PFS_MAX_FILE_SIZE
bytes. 
.I game_name 
is restricted to up to a sixteen character name and 
.I ext_name
is four character filename extension.
The 
.I OSPfs
handle 
must be the handle returned from 
.I osPfsInit.
See
.IR osPfsInit (3P)
for details on how to create this handle. A file descriptor is returned to 
.I file_no
if the calls succeed. 
.sp
The 
.I osPfsDeleteFile
function deletes a file whose name is given by
.I company_code, game_code, game_name, 
and 
.I ext_name.
If the specified file doesn't exist, an error code
.I PFS_ERR_INVALID
is returned.
.sp
The 
.I osPfsFindFile
function seeks the file that match the name by
.I company_code, game_code, game_name, 
and 
.I ext_name.
A file descriptor is returned to
.I file_no
if the file exists, otherwise an error code
.I PFS_ERR_INVALID
is returned.
.sp
A value of 0 is returned if the calls succeed, otherwise
one of the following error code is returned.
.PP
.nf
.ta 5 26 
	PFS_ERR_CONTRFAIL	The controller sends data at higher data
			transfer rate than the hardware handling 
			capability or the hardware CRC error
			occurs.
.sp
	PFS_ERR_INVALID		Invalid parameter or the specified file
			does not exist. Application should change 
			parameter and then retry.
.sp
	PFS_ERR_EXIST	The specified file which will be created 
			exists.
.sp
	PFS_ERR_NEW_PACK	CONTROLLER PAK has been changed to a
 			different one. Application needs to call 
			osPfsInit(3p) to initialize the new
			CONTROLLER PAK.
.sp
	PFS_ERR_INCONSISTENT	File system is corrupted. Application needs
			to call osPfsChecker(3p) to fix the file 
			system.
.sp
	PFS_DIR_FULL	Directory is full, no new files can be
			created. Application should ask users to 
			change to a new CONTROLLER PAK or loop 
			through directory to let users delete files.
			
.fi
.sp
Note that the file is not allowed to grow on the write. The application
should declare the size needed on allocation time or use
.I osPfsReSizeFile (3P)
to grow/truncate the file.
.SH "SEE ALSO"
osContInit (3P),
osPfsChecker (3P),
osPfsFileState (3P),
osPfsFreeBlocks (3P),
osPfsInit (3P),
osPfsIsPlug (3P),
osPfsReSizeFile (3P),
osPfsReadWriteFile (3P),
osPfsSetLabel (3P)