pspsdk-1.0+beta2
File IO Library

This module contains the imports for the kernel's IO routines. More...

Enumerations

enum  IoAssignPerms { IOASSIGN_RDWR = 0, IOASSIGN_RDONLY = 1 }
 Permission value for the sceIoAssign function. More...

Functions

SceUID sceIoOpen (const char *file, int flags, SceMode mode)
 Open or create a file for reading or writing.
SceUID sceIoOpenAsync (const char *file, int flags, SceMode mode)
 Open or create a file for reading or writing (asynchronous)
int sceIoClose (SceUID fd)
 Delete a descriptor.
int sceIoCloseAsync (SceUID fd)
 Delete a descriptor (asynchronous)
int sceIoRead (SceUID fd, void *data, SceSize size)
 Read input.
int sceIoReadAsync (SceUID fd, void *data, SceSize size)
 Read input (asynchronous)
int sceIoWrite (SceUID fd, const void *data, SceSize size)
 Write output.
int sceIoWriteAsync (SceUID fd, const void *data, SceSize size)
 Write output (asynchronous)
SceOff sceIoLseek (SceUID fd, SceOff offset, int whence)
 Reposition read/write file descriptor offset.
int sceIoLseekAsync (SceUID fd, SceOff offset, int whence)
 Reposition read/write file descriptor offset (asynchronous)
int sceIoLseek32 (SceUID fd, int offset, int whence)
 Reposition read/write file descriptor offset (32bit mode)
int sceIoLseek32Async (SceUID fd, int offset, int whence)
 Reposition read/write file descriptor offset (32bit mode, asynchronous)
int sceIoRemove (const char *file)
 Remove directory entry.
int sceIoMkdir (const char *dir, SceMode mode)
 Make a directory file.
int sceIoRmdir (const char *path)
 Remove a directory file.
int sceIoChdir (const char *path)
 Change the current directory.
int sceIoRename (const char *oldname, const char *newname)
 Change the name of a file.
SceUID sceIoDopen (const char *dirname)
 Open a directory.
int sceIoDread (SceUID fd, SceIoDirent *dir)
 Reads an entry from an opened file descriptor.
int sceIoDclose (SceUID fd)
 Close an opened directory file descriptor.
int sceIoDevctl (const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
 Send a devctl command to a device.
int sceIoAssign (const char *dev1, const char *dev2, const char *dev3, int mode, void *unk1, long unk2)
 Assigns one IO device to another (I guess)
int sceIoUnassign (const char *dev)
 Unassign an IO device.
int sceIoGetstat (const char *file, SceIoStat *stat)
 Get the status of a file.
int sceIoChstat (const char *file, SceIoStat *stat, int bits)
 Change the status of a file.
int sceIoIoctl (SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
 Perform an ioctl on a device.
int sceIoIoctlAsync (SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
 Perform an ioctl on a device.
int sceIoSync (const char *device, unsigned int unk)
 Synchronise the file data on the device.
int sceIoWaitAsync (SceUID fd, SceInt64 *res)
 Wait for asyncronous completion.
int sceIoWaitAsyncCB (SceUID fd, SceInt64 *res)
 Wait for asyncronous completion (with callbacks).
int sceIoPollAsync (SceUID fd, SceInt64 *res)
 Poll for asyncronous completion.
int sceIoGetAsyncStat (SceUID fd, int poll, SceInt64 *res)
 Get the asyncronous completion status.
int sceIoCancel (SceUID fd)
 Cancel an asynchronous operation on a file descriptor.
int sceIoGetDevType (SceUID fd)
 Get the device type of the currently opened file descriptor.
int sceIoChangeAsyncPriority (SceUID fd, int pri)
 Change the priority of the asynchronous thread.
int sceIoSetAsyncCallback (SceUID fd, SceUID cb, void *argp)
 Sets a callback for the asynchronous action.

Detailed Description

This module contains the imports for the kernel's IO routines.

Enumeration Type Documentation

Permission value for the sceIoAssign function.

Enumerator:
IOASSIGN_RDWR 

Assign the device read/write.

IOASSIGN_RDONLY 

Assign the device read only.

Function Documentation

int sceIoAssign ( const char *  dev1,
const char *  dev2,
const char *  dev3,
int  mode,
void *  unk1,
long  unk2 
)

Assigns one IO device to another (I guess)

Parameters
dev1- The device name to assign.
dev2- The block device to assign from.
dev3- The filesystem device to mape the block device to dev1
mode- Read/Write mode. One of IoAssignPerms.
unk1- Unknown, set to NULL.
unk2- Unknown, set to 0.
Returns
< 0 on error.
Example: Reassign flash0 in read/write mode.
sceIoUnassign("flash0");
sceIoAssign("flash0", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
int sceIoCancel ( SceUID  fd)

Cancel an asynchronous operation on a file descriptor.

Parameters
fd- The file descriptor to perform cancel on.
Returns
< 0 on error.
int sceIoChangeAsyncPriority ( SceUID  fd,
int  pri 
)

Change the priority of the asynchronous thread.

Parameters
fd- The opened fd on which the priority should be changed.
pri- The priority of the thread.
Returns
< 0 on error.
int sceIoChdir ( const char *  path)

Change the current directory.

Parameters
path- The path to change to.
Returns
< 0 on error.
int sceIoChstat ( const char *  file,
SceIoStat stat,
int  bits 
)

Change the status of a file.

Parameters
file- The path to the file.
stat- A pointer to an io_stat_t structure.
bits- Bitmask defining which bits to change.
Returns
< 0 on error.
int sceIoClose ( SceUID  fd)

Delete a descriptor.

Parameters
fd- File descriptor to close
Returns
< 0 on error
int sceIoCloseAsync ( SceUID  fd)

Delete a descriptor (asynchronous)

Parameters
fd- File descriptor to close
Returns
< 0 on error
int sceIoDclose ( SceUID  fd)

Close an opened directory file descriptor.

Parameters
fd- Already opened file descriptor (using sceIoDopen)
Returns
< 0 on error
int sceIoDevctl ( const char *  dev,
unsigned int  cmd,
void *  indata,
int  inlen,
void *  outdata,
int  outlen 
)

Send a devctl command to a device.

Example: Sending a simple command to a device (not a real devctl)
sceIoDevctl("ms0:", 0x200000, indata, 4, NULL, NULL);
Parameters
dev- String for the device to send the devctl to (e.g. "ms0:")
cmd- The command to send to the device
indata- A data block to send to the device, if NULL sends no data
inlen- Length of indata, if 0 sends no data
outdata- A data block to receive the result of a command, if NULL receives no data
outlen- Length of outdata, if 0 receives no data
Returns
0 on success, < 0 on error

Referenced by _gdbSupportLibFlushCaches().

SceUID sceIoDopen ( const char *  dirname)

Open a directory.

Example:
int dfd;
dfd = sceIoDopen("device:/");
if(dfd >= 0)
{ Do something with the file descriptor }
Parameters
dirname- The directory to open for reading.
Returns
If >= 0 then a valid file descriptor, otherwise a Sony error code.
int sceIoDread ( SceUID  fd,
SceIoDirent dir 
)

Reads an entry from an opened file descriptor.

Parameters
fd- Already opened file descriptor (using sceIoDopen)
dir- Pointer to an io_dirent_t structure to hold the file information
Returns
Read status
  • 0 - No more directory entries left
  • > 0 - More directory entired to go
  • < 0 - Error
int sceIoGetAsyncStat ( SceUID  fd,
int  poll,
SceInt64 res 
)

Get the asyncronous completion status.

Parameters
fd- The file descriptor which is current performing an asynchronous action.
poll- If 0 then waits for the status, otherwise it polls the fd.
res- The result of the async action.
Returns
< 0 on error.
int sceIoGetDevType ( SceUID  fd)

Get the device type of the currently opened file descriptor.

Parameters
fd- The opened file descriptor.
Returns
< 0 on error. Otherwise the device type?
int sceIoGetstat ( const char *  file,
SceIoStat stat 
)

Get the status of a file.

Parameters
file- The path to the file.
stat- A pointer to an io_stat_t structure.
Returns
< 0 on error.
int sceIoIoctl ( SceUID  fd,
unsigned int  cmd,
void *  indata,
int  inlen,
void *  outdata,
int  outlen 
)

Perform an ioctl on a device.

Parameters
fd- Opened file descriptor to ioctl to
cmd- The command to send to the device
indata- A data block to send to the device, if NULL sends no data
inlen- Length of indata, if 0 sends no data
outdata- A data block to receive the result of a command, if NULL receives no data
outlen- Length of outdata, if 0 receives no data
Returns
0 on success, < 0 on error
int sceIoIoctlAsync ( SceUID  fd,
unsigned int  cmd,
void *  indata,
int  inlen,
void *  outdata,
int  outlen 
)

Perform an ioctl on a device.

(asynchronous)

Parameters
fd- Opened file descriptor to ioctl to
cmd- The command to send to the device
indata- A data block to send to the device, if NULL sends no data
inlen- Length of indata, if 0 sends no data
outdata- A data block to receive the result of a command, if NULL receives no data
outlen- Length of outdata, if 0 receives no data
Returns
0 on success, < 0 on error
SceOff sceIoLseek ( SceUID  fd,
SceOff  offset,
int  whence 
)

Reposition read/write file descriptor offset.

Example:
pos = sceIoLseek(fd, -10, SEEK_END);
Parameters
fd- Opened file descriptor with which to seek
offset- Relative offset from the start position given by whence
whence- Set to SEEK_SET to seek from the start of the file, SEEK_CUR seek from the current position and SEEK_END to seek from the end.
Returns
The position in the file after the seek.
int sceIoLseek32 ( SceUID  fd,
int  offset,
int  whence 
)

Reposition read/write file descriptor offset (32bit mode)

Example:
pos = sceIoLseek32(fd, -10, SEEK_END);
Parameters
fd- Opened file descriptor with which to seek
offset- Relative offset from the start position given by whence
whence- Set to SEEK_SET to seek from the start of the file, SEEK_CUR seek from the current position and SEEK_END to seek from the end.
Returns
The position in the file after the seek.
int sceIoLseek32Async ( SceUID  fd,
int  offset,
int  whence 
)

Reposition read/write file descriptor offset (32bit mode, asynchronous)

Parameters
fd- Opened file descriptor with which to seek
offset- Relative offset from the start position given by whence
whence- Set to SEEK_SET to seek from the start of the file, SEEK_CUR seek from the current position and SEEK_END to seek from the end.
Returns
< 0 on error.
int sceIoLseekAsync ( SceUID  fd,
SceOff  offset,
int  whence 
)

Reposition read/write file descriptor offset (asynchronous)

Parameters
fd- Opened file descriptor with which to seek
offset- Relative offset from the start position given by whence
whence- Set to SEEK_SET to seek from the start of the file, SEEK_CUR seek from the current position and SEEK_END to seek from the end.
Returns
< 0 on error. Actual value should be passed returned by the sceIoWaitAsync call.
int sceIoMkdir ( const char *  dir,
SceMode  mode 
)

Make a directory file.

Parameters
dir
mode- Access mode.
Returns
Returns the value 0 if its succesful otherwise -1
SceUID sceIoOpen ( const char *  file,
int  flags,
SceMode  mode 
)

Open or create a file for reading or writing.

Example1: Open a file for reading
if(!(fd = sceIoOpen("device:/path/to/file", O_RDONLY, 0777)) {
// error
}
Example2: Open a file for writing, creating it if it doesnt exist
if(!(fd = sceIoOpen("device:/path/to/file", O_WRONLY|O_CREAT, 0777)) {
// error
}
Parameters
file- Pointer to a string holding the name of the file to open
flags- Libc styled flags that are or'ed together
mode- File access mode.
Returns
A non-negative integer is a valid fd, anything else an error

Referenced by _gdbSupportLibInit().

SceUID sceIoOpenAsync ( const char *  file,
int  flags,
SceMode  mode 
)

Open or create a file for reading or writing (asynchronous)

Parameters
file- Pointer to a string holding the name of the file to open
flags- Libc styled flags that are or'ed together
mode- File access mode.
Returns
A non-negative integer is a valid fd, anything else an error
int sceIoPollAsync ( SceUID  fd,
SceInt64 res 
)

Poll for asyncronous completion.

Parameters
fd- The file descriptor which is current performing an asynchronous action.
res- The result of the async action.
Returns
< 0 on error.
int sceIoRead ( SceUID  fd,
void *  data,
SceSize  size 
)

Read input.

Example:
bytes_read = sceIoRead(fd, data, 100);
Parameters
fd- Opened file descriptor to read from
data- Pointer to the buffer where the read data will be placed
size- Size of the read in bytes
Returns
The number of bytes read

Referenced by getDebugChar().

int sceIoReadAsync ( SceUID  fd,
void *  data,
SceSize  size 
)

Read input (asynchronous)

Example:
bytes_read = sceIoRead(fd, data, 100);
Parameters
fd- Opened file descriptor to read from
data- Pointer to the buffer where the read data will be placed
size- Size of the read in bytes
Returns
< 0 on error.
int sceIoRemove ( const char *  file)

Remove directory entry.

Parameters
file- Path to the file to remove
Returns
< 0 on error
int sceIoRename ( const char *  oldname,
const char *  newname 
)

Change the name of a file.

Parameters
oldname- The old filename
newname- The new filename
Returns
< 0 on error.
int sceIoRmdir ( const char *  path)

Remove a directory file.

Parameters
path- Removes a directory file pointed by the string path
Returns
Returns the value 0 if its succesful otherwise -1
int sceIoSetAsyncCallback ( SceUID  fd,
SceUID  cb,
void *  argp 
)

Sets a callback for the asynchronous action.

Parameters
fd- The filedescriptor currently performing an asynchronous action.
cb- The UID of the callback created with sceKernelCreateCallback
argp- Pointer to an argument to pass to the callback.
Returns
< 0 on error.
int sceIoSync ( const char *  device,
unsigned int  unk 
)

Synchronise the file data on the device.

Parameters
device- The device to synchronise (e.g. msfat0:)
unk- Unknown
int sceIoUnassign ( const char *  dev)

Unassign an IO device.

Parameters
dev- The device to unassign.
Returns
< 0 on error
Example: See ::sceIoAssign
int sceIoWaitAsync ( SceUID  fd,
SceInt64 res 
)

Wait for asyncronous completion.

Parameters
fd- The file descriptor which is current performing an asynchronous action.
res- The result of the async action.
Returns
< 0 on error.
int sceIoWaitAsyncCB ( SceUID  fd,
SceInt64 res 
)

Wait for asyncronous completion (with callbacks).

Parameters
fd- The file descriptor which is current performing an asynchronous action.
res- The result of the async action.
Returns
< 0 on error.
int sceIoWrite ( SceUID  fd,
const void *  data,
SceSize  size 
)

Write output.

Example:
bytes_written = sceIoWrite(fd, data, 100);
Parameters
fd- Opened file descriptor to write to
data- Pointer to the data to write
size- Size of data to write
Returns
The number of bytes written

Referenced by putDebugChar().

int sceIoWriteAsync ( SceUID  fd,
const void *  data,
SceSize  size 
)

Write output (asynchronous)

Parameters
fd- Opened file descriptor to write to
data- Pointer to the data to write
size- Size of data to write
Returns
< 0 on error.