Difference between revisions of "Bfile SeekFile OS"

From WikiPrizm
Jump to navigationJump to search
(Added resize warning and tip on seeking like fseek(SEEK_CUR, ...))
Line 2: Line 2:
 
| name = Bfile_SeekFile_OS
 
| name = Bfile_SeekFile_OS
 
| index = 0x1DA9
 
| index = 0x1DA9
| signature = int Bfile_SeekFile_OS( int handle, int pos );
+
| signature = int Bfile_SeekFile_OS(int handle, int pos);
 
| synopsis = Changes the position in the file handle, similar to fseek.
 
| synopsis = Changes the position in the file handle, similar to fseek.
 
| header = fxcg/file.h
 
| header = fxcg/file.h
Line 11: Line 11:
 
| comments = This function seeks to an absolute location in the file pointer.  To seek backwards, use [[Bfile_GetFileSize_OS]] and add the offset to that.
 
| comments = This function seeks to an absolute location in the file pointer.  To seek backwards, use [[Bfile_GetFileSize_OS]] and add the offset to that.
  
'''WARNING''': This function resizes the file if '''pos''' > [[Bfile_GetFileSize_OS]].  The file cannot shrink, only expand.
+
'''WARNING''': This function resizes the file if '''pos''' > [[Bfile_GetFileSize_OS]].  The file cannot shrink, only expand. If you need to shrink a file, [[Bfile_DeleteEntry|delete]] then [[Bfile_CreateFile_OS|recreate]] it, and [[Bfile_WriteFile_OS|write]] the new contents to it.
 +
 
 +
{{BfileTimersWarning}}
 
}}
 
}}
  
 
[[Category:Syscalls:Bfile]]
 
[[Category:Syscalls:Bfile]]

Revision as of 06:56, 30 July 2014


Synopsis

Header: fxcg/file.h
Syscall index: 0x1DA9
Function signature: int Bfile_SeekFile_OS(int handle, int pos);

Changes the position in the file handle, similar to fseek.

Parameters

  • handle: File handle as returned by Bfile_OpenFile_OS.
  • pos: Position (absolute, not relative) to seek to.

Returns

Returns the new position in the file handle.

Comments

This function seeks to an absolute location in the file pointer. To seek backwards, use Bfile_GetFileSize_OS and add the offset to that.

WARNING: This function resizes the file if pos > Bfile_GetFileSize_OS. The file cannot shrink, only expand. If you need to shrink a file, delete then recreate it, and write the new contents to it.

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.