libgpac
Documentation of the core library of GPAC
File Interface Reference

import"core.idl";

Public Member Functions

 File ()
 
 File (DOMString name, DOMString mode, optional DOMString parent_fileio=null)
 
void flush ()
 
void close ()
 
unsigned long read (ArrayBuffer buf, optional unsigned long nb_bytes=0)
 
long seek (unsigned long long offset, long whence)
 
DOMString gets ()
 
DOMString getc (DOMString char)
 
unsigned long write (ArrayBuffer buf, optional unsigned long nb_bytes=0)
 
void puts (DOMString string)
 
void putc (DOMString value)
 
void putc (unsigned long value)
 

Data Fields

attribute unsigned long long pos
 
attribute readonly boolean eof
 
attribute readonly unsigned long error
 
attribute readonly unsigned long long size
 
attribute readonly boolean gfio
 

Detailed Description

FILE object

Constructor & Destructor Documentation

◆ File() [1/2]

File::File ( )

constructor for a temporary file

◆ File() [2/2]

File::File ( DOMString  name,
DOMString  mode,
optional DOMString  parent_fileio = null 
)

constructor for a file - see gf_fopen

Parameters
namename of file to open
moderead/write mode, same as fopen
parent_fileioparent GF_FileIO name - see gf_fopen_ex

Member Function Documentation

◆ flush()

void File::flush ( )

flush file - see gf_fflush

◆ close()

void File::close ( )

close file, underlying FILE object is destroyed and any futher calls to the file object will fail - see gf_fclose

◆ read()

unsigned long File::read ( ArrayBuffer  buf,
optional unsigned long  nb_bytes = 0 
)

read bytes in an array buffer - see gf_fread

Parameters
bufarray buffer to read bytes into
nb_bytesnumber of bytes to read - if 0, uses array buffer size. If more than array buffer size, truncated to array buffer size
Returns
the number of bytes read

◆ seek()

long File::seek ( unsigned long long  offset,
long  whence 
)

seek into file - see gf_fseek

Parameters
offsetoffset in file
whenceseek origin
Returns
-1 if error, 0 otherwise

◆ gets()

DOMString File::gets ( )

get a string from a file, stopping at first new line character found - see gf_fgets

Returns
string read

◆ getc()

DOMString File::getc ( DOMString char  )

read a character from file - see gf_fgetc

Returns
string containing a single character

◆ write()

unsigned long File::write ( ArrayBuffer  buf,
optional unsigned long  nb_bytes = 0 
)

write bytes of an array buffer to file - see gf_fwrite

Parameters
bufarray buffer to read bytes from
nb_bytesnumber of bytes to write - if 0, uses array buffer size. If more than array buffer size, truncated to array buffer size
Returns
the number of bytes written

◆ puts()

void File::puts ( DOMString  string)

put string to file - see gf_fputs

Parameters
stringstring to write

◆ putc() [1/2]

void File::putc ( DOMString  value)

put character to file - see gf_fputc

Parameters
valuecharacter to write (only first char of string is used)

◆ putc() [2/2]

void File::putc ( unsigned long  value)

put character to file - see gf_fputc

Parameters
valueinteger value to write

Field Documentation

◆ pos

attribute unsigned long long File::pos

read/write position in file - see gf_ftell and gf_fseek

◆ eof

attribute readonly boolean File::eof

EOF flag on file - see gf_feof

◆ error

attribute readonly unsigned long File::error

error code on file, 0 if no error - see gf_ferror

◆ size

attribute readonly unsigned long long File::size

file size - see gf_fsize

◆ gfio

attribute readonly boolean File::gfio

set to true if file is a GFIO wrapper - see gf_fileio_check