Shinobi Library - Memory Card Function

buSaveFile

Saves a file

FORMAT

Sint32 buSaveFile( drive, *fname, *buf, nblock, *time, flag )
Sint32 drive
const char *fname
const void *buf
Uint32 nblock
const BUS_TIME *time
Sint32 flag

PARAMETER

 drive  Extension socket number 
 *fname  File name 
 *buf  Read address 
 nblock  Number of blocks to be read 
 *time  Time stamp 
 flag  Flag 
   BUD_FLAG_VERIFY:Verify enabled 
   BUD_FLAG_COPY(n):Copy flag ("n" is the value of the copy flag) 

RETURN

 BUD_ERR_OK  Processing request was received 
 BUD_ERR_BUSY  Busy - request could not be accepted 

DESCRIPTION

Saves a file on the memory card inserted in a specified extension socket.

The following values can be designated for drive that specifies extension sockets.

 BUD_DRIVE_A1  Extension socket 1 on board A 
 BUD_DRIVE_A2  Extension socket 2 on board A 
 BUD_DRIVE_B1  Extension socket 1 on board B 
 BUD_DRIVE_B2  Extension socket 2 on board B 
 BUD_DRIVE_C1  Extension socket 1 on board C 
 BUD_DRIVE_C2  Extension socket 2 on board C 
 BUD_DRIVE_D1  Extension socket 1 on board D 
 BUD_DRIVE_D2  Extension socket 2 on board D 

In a normal application, this function saves an entire file. If a file with the same name already exists, the old file is deleted. However, if the file with the same name was an executable file, an error results. In addition, the address that is specified for buf must be on a four-byte boundary.


EXAMPLE

Sint32 ret;
Sint32 blocks, flag;
BUS_TIME time;
SYS_RTC_DATE rtc;
extern char SaveData[];
	/* Data to be saved (512*10 bytes) */
	:
blocks = 10;
	/* File size is 10 blocks */
flag = BUD_FLAG_VERIFY | BUD_FLAG_COPY(0x00);
	/* Verify enabled | Set copy flag to 00H */
syRtcGetDate( &rtc );
time = ( BUS_TIME )rtc;  /* Time stamp setting */
ret = buSaveFile(BUD_DRIVE_A1, "SAVEDATA", SaveData, blocks, &time, flag);
if (ret == BUD_ERR_OK) {
	/* Save request was successful */
} else {
	/* Save request failed (busy) */
}
	:

NOTE

Even if a verify error occurs, the file is still saved.

The following are the completion statuses for this function that are obtained by buStat():

 BUD_ERR_OK  Normal end 
 BUD_ERR_NO_DISK  Memory card not found 
 BUD_ERR_UNFORMAT  Disk not formatted 
 BUD_ERR_FILE_NOT_FOUND  File not found 
 BUD_ERR_CANNOT_OPEN  Cannot open file 

A save requires (number of blocks being saved x 5 Int). (Depending on the status of other extension sockets, the time required to save a file varies.)


buSaveFile
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999