N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## osPfsAllocateFile

Syntax

    #include <ultra64.h>

    s32 osPfsAllocateFile(OSPfs *pfs,
       u16 company_code,
       u32 game_code,
       u8 *game_name,
       u8 *ext_name,
       int length,
       s32 *file_no);

Explanation
It creates a new game note (file) in a Controller Pak. The company_code (company code), game_code (game code), game_name (note name), ext_name (note extension), and length (size) arguments must be specified as the information for the game note.
The company_code and game_code are specified as ASCII character strings. The game_name and ext_name are specified by N64 font code.
The size of game_name is PFS_FILE_NAME_LEN(16) bytes. If the size is less than 16 bytes, fill the rest with 0x00. Be sure to make the length 16 bytes.
The size of ext_name is PFS_FILE_EXT_LEN(4) bytes. However, only the first byte is actually used. For this code, use '0'-'9', *A*~*Z* (0x10~0x33) of N64 font code. The second through fourth bytes are reserved, so use 0x00.
The size is specified by length, in bytes. Because the smallest internal unit is a page (256 bytes), if length is not specified in multiples of 256, the length will be rounded up to the nearest multiple of 256.
The newly created game note's note number (file descriptor) will be returned to file_no. Up to 16 game notes can be created. Therefore, file_no ranges from 0 to 15.
The OSPfs structure pointed to by pfs is the file handle to be initialized by the function osPfsInitPak. Please refer to osPfsInitPak to determine how to create this handle.
If this function is called successfully, 0 is retruned. If an error occurs, one of the following error codes is returned:

- PFS_ERR_NOPACK - Some type of PIF error has occurred. Either the Controller Pak is not inserted into the specified Controller or the Controller is not properly connected. To determine which is the case, use osContStartQuery or osContGetQuery.
- PFS_ERR_NEW_PACK - A different Controller Pak has been inserted. To use the inserted Controller Pak, initialize it by calling osPfsInitPak.
- PFS_ERR_CONTRFAIL - Data transfer to or from the Controller has failed. If a transfer error occurs, up to three tries will be done internally. Therefore, it is rather rare to see this error. If this error has returned, it is possible that either the Controller is not connected properly, or the Controller Pak or Controller Socket is damaged.
- PFS_ERR_INCONSISTENT - There is a problem in the file system's management area. Usually this error does not occur because osPfsChecker
  is called internally when you initialize the file system by calling osPfsInitPak. If this error is returned, either the Controller Pak is not connected properly, or the Controller Pak itself is damaged.
- PFS_ERR_INVALID - If this error is returned, an incorrect argument was specified when this function was called, the specified game note does not exist, or the Pfs function has been called without being initialized using osPfsInitPak. Therefore, usually this error is not returned.
- PFS_DATA_FULL - Although the creation of a new game note was attempted, one could not be created because there was not enough space in the Controller Pak.
- PFS_DIR_FULL - Although the creation of a new game note was attempted, it could not be done because the maximum (16) number of game notes have been stored in the Controller Pak.
- PFS_ERR_EXIST - Although the creation of a new game note was attempted, it could not be done because the same game note already exists in the Controller Pak.

See Also
osContInit
osContStartQuery
osContGetQuery
osPfsChecker
osPfsDeleteFile
osPfsFileState
osPfsFindFile
osPfsFreeBlocks
osPfsInitPak
osPfsIsPlug
osPfsReadWriteFile

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1998