FileStream.h
declares the API that this chapter describes. For more information on file streaming, see the chapter "Files and Databases" in the Palm OS Programmer's Companion.
openMode
parameter to the
FileOpen
function. These constants specify the mode in which a file stream is opened.
FileOpen
function only one of the primary mode selectors listed.
|
operator (bitwise inclusive OR) to append to a primary mode selector one or more of the secondary mode selectors listed below.
Err FileClearerr (FileHand stream)
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
FileGetLastError
,
FileRewind
fileModeTemporary
, it is deleted upon closing.
Err FileClose (FileHand stream)
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
op
parameter on the stream
file stream.
Err FileControl (FileOpEnum op, FileHand stream, void* valueP, Int32* valueLenP)
  |
|
The operation to perform, and its associated formal parameters. See the Comments section for a list of possible values. |
  |
--> |
Open stream handle if required for file stream operation. |
  |
<--> |
Pointer to value or buffer, as required. This parameter is defined by the selector passed as the value of the op parameter. For details, see the Comments section. |
  |
<--> |
Pointer to value or buffer, as required. This parameter is defined by the selector passed as the value of the op parameter. For details, see the Comments section. |
op
parameter, or an error code resulting from the requested operation. For details, see the Comments section.
FileControl
function yourself; it is called for you by most of the other file streaming functions and macros to perform common file streaming operations. You can call
FileControl
yourself to enable specialized read modes.
FileClearerr
,
FileEOF
,
FileError
,
FileFlush
,
FileGetLastError
,
FileRewind
Err FileDelete (UInt16 cardNo, Char* nameP)
  |
|
Card on which the file stream to delete resides. Currently, no Palm OS® devices support multiple cards, so this value must be 0. |
  |
|
String that is the name of the stream to delete. |
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
FileOpen
Int32 FileDmRead (FileHand stream, void* startOfDmChunkP, Int32 destOffset, Int32 objSize, Int32 numObj, Err* errP)
  |
--> |
Handle to open stream. |
  |
--> |
Pointer to beginning of chunk, record or resource residing in a database. |
  |
|
Offset from startOfDmChunkP (base pointer) to the destination area (must be >= 0). |
  |
|
Size of each stream object to read. |
  |
|
Number of stream objects to read. |
  |
<--> |
Pointer to variable that is to hold the error code returned by this function. Pass NULL to ignore. See the section "File Streaming Error Codes" for more information. |
errP
parameter or by calling the
FileGetLastError
function. If the cause is insufficient data in the stream to satisfy the full request, the current stream position is at end-of-file and the "end of file" indicator is set. If a non-NULL
pointer was passed as the value of the errP
parameter when the FileDmRead
function was called and an error was encountered, *errP
holds a non-zero error code when the function returns. In addition, the
FileError
and
FileEOF
functions may be used to check for I/O errors.
FileRead
,
FileError
,
FileEOF
fileErrEOF
indicates end of file condition).
Err FileEOF (FileHand stream)
feof
function provided by the C programming language runtime library.
FileClearerr
to clear the I/O error status.
FileClearerr
,
FileGetLastError
,
FileRewind
Err FileError (FileHand stream)
ferror
runtime function.
FileClearerr
to clear the I/O error status.
FileClearerr
,
FileGetLastError
,
FileRewind
Err FileFlush (FileHand stream)
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
fflush
function provided by the C programming language runtime library, you only need to call it explicitly under circumstances similar to those in which you would call fflush
explicitly.
FileClearerr
to reset all error codes)
Err FileGetLastError (FileHand stream)
FileClearerr
,
FileEOF
,
FileError
openMode
parameter.
FileHand FileOpen (UInt16 cardNo, Char* nameP, UInt32 type, UInt32 creator, UInt32 openMode, Err* errP)
  |
|
Card on which the file stream to open resides. Currently, no Palm OS devices support multiple cards, so this value must be 0. |
  |
--> |
Pointer to text string that is the name of the file stream to open or create. This value must be a valid name--no wildcards allowed, must not be NULL . |
  |
|
Creator of stream to open or create. Pass 0 for wildcard, in which case the current application's creator ID is used for the creator of the stream this function creates. |
  |
|
Mode in which to open the file stream. You must specify only one primary mode selector. Additionally, you can use the | operator (bitwise inclusive OR) to append one or more secondary mode selectors to the primary mode selector. See "Primary Open Mode Constants" and "Secondary Open Mode Constants" for the list of possible values. |
  |
|
|
  |
<--> |
Pointer to variable that is to hold the error code returned by this function. Pass NULL to ignore. See the section "File Streaming Error Codes" for a list of error codes. |
0
.
fileModeReadOnly
, fileModeReadWrite
, fileModeUpdate
, and fileModeAppend
modes are mutually exclusive--pass only one of them to the FileOpen
function!
fileModeTemporary
open mode is used and the file type passed to FileOpen
is 0
, the FileOpen
function uses sysFileTTemp
(defined in SystemMgr.rh)
for the file type, as recommended. In future versions of Palm OS, this configuration will enable the automatic cleanup of undeleted temporary files after a system crash. Automatic post-crash cleanup is not implemented in current versions of Palm OS.
fileModeAnyTypeCreator
selector as a flag in the openMode
parameter to the
FileOpen
function.
fileModeLeaveOpen
mode is an esoteric option that most applications should not use. It may be useful for a library that needs to open a stream from the current application's context and keep it open even after the current application quits. By default, Palm OS automatically closes all databases that were opened in a particular application's context when that application quits. The fileModeLeaveOpen
option overrides this default behavior.
FileDmRead
function for such operations.
Int32 FileRead (FileHand stream, void* bufP, Int32 objSize, Int32 numObj, Err* errP)
  |
--> |
Handle to open stream. |
  |
--> |
Pointer to beginning of buffer into which data is read |
  |
|
Size of each stream object to read. |
  |
|
Number of stream objects to read. |
  |
<--> |
Pointer to variable that is to hold the error code returned by this function. Pass NULL to ignore. See the section "File Streaming Error Codes" for a list of error codes. |
FileDmRead
function for such operations.
errP
parameter or by calling the
FileGetLastError
function. If the cause is insufficient data in the stream to satisfy the full request, the current stream position is at end-of-file and the "end of file" indicator is set. If a non-NULL
pointer was passed as the value of the errP
parameter when the FileRead
function was called and an error was encountered, *errP
holds a non-zero error code when the function returns. In addition, the
FileError
and
FileEOF
functions may be used to check for I/O errors.
FileDmRead
Err FileRewind (FileHand stream)
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
FileSeek
,
FileTell
,
FileClearerr
,
FileEOF
,
FileError
,
FileGetLastError
Err FileSeek (FileHand stream, Int32 offset, FileOriginEnum origin)
  |
--> |
Handle to open stream. |
  |
|
Position to set, expressed as the number of bytes from origin. This value may be positive, negative, or 0 . |
  |
|
Describes the origin of the position change. Possible values are: |
  |
|
From the beginning (first data byte of file). |
  |
|
From the current position. |
  |
|
From the end of file (one position beyond last data byte). |
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for more information.
fseek
function provided by the C programming language runtime library.
FileRewind
,
FileTell
Int32 FileTell (FileHand stream, Int32* fileSizeP, Err* errP)
  |
--> |
Handle to open stream. |
  |
<-> |
Pointer to variable that holds value describing size of stream in bytes when this function returns. Pass NULL to ignore. |
  |
<--> |
Pointer to variable that is to hold the error code returned by this function. Pass NULL to ignore. See the section "File Streaming Error Codes" for a list of possible error codes. |
-1
as a signed long integer.
FileRewind
,
FileSeek
Err FileTruncate (FileHand stream, Int32 newSize)
  |
--> |
Handle of open stream. |
  |
|
New size; must not exceed current stream size. |
fileErr
code if an error occurs. See the section "File Streaming Error Codes" for a list of possible error codes.
FileTell
Int32 FileWrite (FileHand stream, void* dataP, Int32 objSize, Int32 numObj, Err* errP)
  |
--> |
Handle to open stream. |
  |
--> |
Pointer to buffer holding data to write. |
  |
|
Size of each stream object to write; must be >= 0 . |
  |
|
Number of stream objects to write. |
  |
<--> |
Optional pointer to variable that holds the error code returned by this function. Pass NULL to ignore. See the section "File Streaming Error Codes" for a list of possible error codes. |
FileWrite
,
FileSeek
, or
FileTruncate
functions on a stream that is in destructive read mode. One exception to this rule applies to streams that were opened in "write + append" mode and then switched into destructive read state. In this case, the FileWrite
function can append data to the stream, but it also preserves the current stream position so that subsequent reads pick up where they left off (you can think of this as a pseudo-pipe).
  |   |