PSP2SDK  dirty-f9e4f2d
The free SDK for PSP2
Enumerations | Functions
include/psp2/io/fcntl.h File Reference

Header file which defines file control options. More...

#include <psp2/types.h>
Include dependency graph for fcntl.h:

Go to the source code of this file.

Enumerations

enum  {
  PSP2_O_RDONLY = 0x0001, PSP2_O_WRONLY = 0x0002, PSP2_O_RDWR = (PSP2_O_RDONLY | PSP2_O_WRONLY), PSP2_O_NBLOCK = 0x0004,
  PSP2_O_DIROPEN = 0x0008, PSP2_O_APPEND = 0x0100, PSP2_O_CREAT = 0x0200, PSP2_O_TRUNC = 0x0400,
  PSP2_O_EXCL = 0x0800, PSP2_O_NOWAIT = 0x8000
}
enum  { PSP2_SEEK_SET, PSP2_SEEK_CUR, PSP2_SEEK_END }

Functions

SceUID sceIoOpen (const char *file, int flags, SceMode mode)
SceUID sceIoOpenAsync (const char *file, int flags, SceMode mode)
int sceIoClose (SceUID fd)
int sceIoCloseAsync (SceUID fd)
int sceIoRead (SceUID fd, void *data, SceSize size)
int sceIoReadAsync (SceUID fd, void *data, SceSize size)
int sceIoWrite (SceUID fd, const void *data, SceSize size)
int sceIoWriteAsync (SceUID fd, const void *data, SceSize size)
SceOff sceIoLseek (SceUID fd, SceOff offset, int whence)
int sceIoLseekAsync (SceUID fd, SceOff offset, int whence)
int sceIoLseek32 (SceUID fd, int offset, int whence)
int sceIoLseek32Async (SceUID fd, int offset, int whence)
int sceIoRemove (const char *file)
int sceIoRename (const char *oldname, const char *newname)
int sceIoSync (const char *device, unsigned int unk)
int sceIoWaitAsync (SceUID fd, SceInt64 *res)
int sceIoWaitAsyncCB (SceUID fd, SceInt64 *res)
int sceIoPollAsync (SceUID fd, SceInt64 *res)
int sceIoGetAsyncStat (SceUID fd, int poll, SceInt64 *res)
int sceIoCancel (SceUID fd)
int sceIoGetDevType (SceUID fd)
int sceIoChangeAsyncPriority (SceUID fd, int pri)
int sceIoSetAsyncCallback (SceUID fd, SceUID cb, void *argp)

Detailed Description

Header file which defines file control options.

Copyright (C) 2015 PSP2SDK Project

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.


Function Documentation

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 sceIoClose ( SceUID  fd)

Delete a descriptor

 sceIoClose(fd);
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 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?
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.
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", PSP2_O_RDONLY, 0777)) {
    // error
 }
Example2: Open a file for writing, creating it if it doesnt exist
 if(!(fd = sceIoOpen("device:/path/to/file", PSP2_O_WRONLY|PSP2_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
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
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 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 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
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.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines