Difference between revisions of "Bfile ReadFile OS"

From WikiPrizm
Jump to navigationJump to search
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{preliminary}}
 
 
{{syscall
 
{{syscall
 
| name = Bfile_ReadFile_OS
 
| name = Bfile_ReadFile_OS
Line 5: Line 4:
 
| signature = int Bfile_ReadFile_OS(int handle, void *buf, int size, int pos)
 
| signature = int Bfile_ReadFile_OS(int handle, void *buf, int size, int pos)
 
| synopsis = Reads bytes from an open file.
 
| synopsis = Reads bytes from an open file.
 +
| header = fxcg/file.h
 
| parameters =
 
| parameters =
 
* '''handle''': File handle as returned by [[Bfile_OpenFile_OS]].
 
* '''handle''': File handle as returned by [[Bfile_OpenFile_OS]].
Line 12: Line 12:
 
| returns = Number of bytes read, or a negative error code on failure.
 
| returns = Number of bytes read, or a negative error code on failure.
 
| comments = Large values for ''size'' (one megabyte or more) may cause issues (hang the calculator).
 
| comments = Large values for ''size'' (one megabyte or more) may cause issues (hang the calculator).
 +
 +
If '''size''' is >0, then the position in the file handle will be moved to '''pos'''+'''size''' after the function.  If '''size''' is 0, the position will not be set to '''pos'''. Use [[Bfile_SeekFile_OS]] to set the file pointer.
 +
 +
{{BfileTimersWarning}}
 
}}
 
}}
 +
 +
[[Category:Syscalls:Bfile]]

Latest revision as of 06:52, 30 July 2014


Synopsis

Header: fxcg/file.h
Syscall index: 0x1DAC
Function signature: int Bfile_ReadFile_OS(int handle, void *buf, int size, int pos)

Reads bytes from an open file.

Parameters

  • handle: File handle as returned by Bfile_OpenFile_OS.
  • buf: Location to store data read from file.
  • size: Number of bytes to read.
  • pos: File offset to read at, or -1 to read from the current file pointer (like stdio).

Returns

Number of bytes read, or a negative error code on failure.

Comments

Large values for size (one megabyte or more) may cause issues (hang the calculator).

If size is >0, then the position in the file handle will be moved to pos+size after the function. If size is 0, the position will not be set to pos. Use Bfile_SeekFile_OS to set the file pointer.

Using Bfile functions while user timers are installed can cause SYSTEM ERRORs and other undefined behavior, especially with functions that change data on the file system. Make sure to stop and uninstall all timers before using Bfile functions (and optionally restore them later). See Incompatibility between Bfile Syscalls and Timers for more information.