Kanzi 3.9.10
kzs_file.hpp File Reference

Standard file I/O functions. More...

Macros

#define KZS_FILE_ERROR
 Result value indicating that an error occurred in the function.
 
#define KZS_FILE_READONLY
 File is opened in read only text mode.
 
#define KZS_FILE_READONLY_BINARY
 File is opened in read only binary mode.
 
#define KZS_FILE_WRITEONLY
 File is opened in writeable text mode.
 
#define KZS_FILE_WRITEONLY_BINARY
 File is opened in writeable binary mode.
 

Typedefs

typedef void kzsFile
 File type.
 

Enumerations

enum  KzsFileOrigin { KZS_FILE_ORIGIN_SEEK_SET , KZS_FILE_ORIGIN_SEEK_CUR , KZS_FILE_ORIGIN_SEEK_END }
 Origin for kzsFseek. More...
 

Functions

kzInt kzsFclose (kzsFile *file)
 Closes a file.
 
kzBool kzsFeof (kzsFile *file)
 Checks if the end of a file has been reached.
 
kzInt kzsFerror (kzsFile *file)
 Checks if there is an error in a file.
 
kzInt kzsFflush (kzsFile *file)
 Flushes the stream.
 
kzInt kzsFgetc (kzsFile *file)
 Gets a byte from a file.
 
kzInt kzsFileGetSize (kzsFile *file)
 Get the size of a file.
 
kzInt kzsFileno (const kzsFile *file)
 Gets file descriptor.
 
kzInt kzsFileReadSkip (kzsFile *file, kzUint byteCount)
 Skips bytes in a file.
 
kzsFilekzsFopen (kzString fileName, kzString mode)
 Opens a file.
 
kzInt kzsFputc (kzInt character, kzsFile *file)
 Writes a byte to a file.
 
kzUint kzsFread (void *buffer, kzUint elementSize, kzUint elementCount, kzsFile *file)
 Reads elements from a file.
 
kzInt kzsFseek (kzsFile *file, kzInt offset, enum KzsFileOrigin origin)
 Seeks to given position in a file.
 
kzInt kzsFtell (kzsFile *file)
 Gets the current position in a file.
 
kzUint kzsFwrite (const void *buffer, kzUint elementSize, kzUint elementCount, kzsFile *file)
 Writes elements to a file.
 

Detailed Description

Standard file I/O functions.

Copyright 2008-2017 by Rightware. All rights reserved.

Macro Definition Documentation

◆ KZS_FILE_ERROR

#define KZS_FILE_ERROR

Result value indicating that an error occurred in the function.

◆ KZS_FILE_WRITEONLY

#define KZS_FILE_WRITEONLY

File is opened in writeable text mode.

◆ KZS_FILE_WRITEONLY_BINARY

#define KZS_FILE_WRITEONLY_BINARY

File is opened in writeable binary mode.

◆ KZS_FILE_READONLY

#define KZS_FILE_READONLY

File is opened in read only text mode.

◆ KZS_FILE_READONLY_BINARY

#define KZS_FILE_READONLY_BINARY

File is opened in read only binary mode.

Typedef Documentation

◆ kzsFile

typedef void kzsFile

File type.

Enumeration Type Documentation

◆ KzsFileOrigin

Origin for kzsFseek.

Enumerator
KZS_FILE_ORIGIN_SEEK_SET 

Seek from the start of the file.

KZS_FILE_ORIGIN_SEEK_CUR 

Seek from the current location.

KZS_FILE_ORIGIN_SEEK_END 

Seek from the end of the file.

Function Documentation

◆ kzsFopen()

kzsFile * kzsFopen ( kzString fileName,
kzString mode )

Opens a file.

◆ kzsFclose()

kzInt kzsFclose ( kzsFile * file)

Closes a file.

◆ kzsFeof()

kzBool kzsFeof ( kzsFile * file)

Checks if the end of a file has been reached.

◆ kzsFerror()

kzInt kzsFerror ( kzsFile * file)

Checks if there is an error in a file.

◆ kzsFseek()

kzInt kzsFseek ( kzsFile * file,
kzInt offset,
enum KzsFileOrigin origin )

Seeks to given position in a file.

◆ kzsFtell()

kzInt kzsFtell ( kzsFile * file)

Gets the current position in a file.

◆ kzsFflush()

kzInt kzsFflush ( kzsFile * file)

Flushes the stream.

Writes any unwritten data to file.

◆ kzsFgetc()

kzInt kzsFgetc ( kzsFile * file)

Gets a byte from a file.

◆ kzsFputc()

kzInt kzsFputc ( kzInt character,
kzsFile * file )

Writes a byte to a file.

◆ kzsFread()

kzUint kzsFread ( void * buffer,
kzUint elementSize,
kzUint elementCount,
kzsFile * file )

Reads elements from a file.

Returns the number of elements read.

◆ kzsFwrite()

kzUint kzsFwrite ( const void * buffer,
kzUint elementSize,
kzUint elementCount,
kzsFile * file )

Writes elements to a file.

Returns the number of elements written.

◆ kzsFileno()

kzInt kzsFileno ( const kzsFile * file)

Gets file descriptor.

◆ kzsFileGetSize()

kzInt kzsFileGetSize ( kzsFile * file)

Get the size of a file.

Returns -1 if an error occurred.

◆ kzsFileReadSkip()

kzInt kzsFileReadSkip ( kzsFile * file,
kzUint byteCount )

Skips bytes in a file.

Returns the number of bytes skipped. Returns KZS_FILE_ERROR if an error occurred. This function is intended for skipping in a file only when reading it. To skip in a writable file, use kzsFseek with KZS_FILE_ORIGIN_SEEK_CUR as origin.