Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXEX::FXFileIO Class Reference

#include <FXFileIO.h>

Inheritance diagram for FXEX::FXFileIO::

FXEX::FXIOHandle FXEX::FXBaseObject FXObject List of all members.

Public Methods

 FXFileIO (FXApp *a, const FXString &file="", FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=0)
 FXFileIO (FXInputHandle f, FXApp *a, FXObject *tgt=NULL, FXSelector sel=0)
 FXFileIO (FXApp *a, FXObject *tgt=NULL, FXSelector=0)
virtual void create ()
FXString name () const
void name (const FXString &file)
void mode (FXuint m)
FXuint mode ()
virtual FXbool open ()
virtual void close ()
FXlong size ()
FXbool isTemp () const
void setTemp (FXbool t=TRUE)
virtual void enable ()
virtual void disable ()
void sync ()
FXlong current ()
FXbool seekbegin (FXlong pos=0)
FXbool seek (FXlong pos)
FXbool seekend (FXlong pos=0)
FXbool truncate (FXlong len)
FXbool lock ()
FXbool unlock (FXlong len)
FXint isLocked (FXlong len=0)
FXbool readLock (FXlong len=0, FXint timeout=0)
FXbool writeLock (FXlong len=0, FXint timeout=0)
void setLockRetry (FXuint retry)
FXbool map (FXlong len, FXbool writeable=TRUE)
void unmap ()
FXbool isMapped ()
void * getMapping ()
FXFileIO * duplicate (FXInputHandle newHandle=INVALID_HANDLE)
virtual void save (FXStream &store) const
virtual void load (FXStream &store)
virtual ~FXFileIO ()

Static Public Methods

void modeDefault (FXuint mode)
FXuint modeDefault ()

Constructor & Destructor Documentation

FXEX::FXFileIO::FXFileIO (  FXApp * a,
const FXString & file = "",
FXObject * tgt = NULL,
FXSelector sel = 0,
FXuint opts = 0
) 
 

get access to a file.

FXEX::FXFileIO::FXFileIO (  FXInputHandle f,
FXApp * a,
FXObject * tgt = NULL,
FXSelector sel = 0
) 
 

use an already open file :-).

FXEX::FXFileIO::FXFileIO (  FXApp * a,
FXObject * tgt = NULL,
FXSelector = 0
) 
 

create a temporary file, deletes on close.

virtual FXEX::FXFileIO::~FXFileIO (  )  [virtual]
 

Destructor If the object contains a mapped region, the region is unmapped before destruction.


Member Function Documentation

virtual void FXEX::FXFileIO::create (  )  [virtual]
 

create resource.

Reimplemented from FXEX::FXBaseObject.

FXString FXEX::FXFileIO::name (  )  const
 

get the filename.

void FXEX::FXFileIO::name (  const FXString & file ) 
 

set to new file, but only if the file is not open (fails silently).

void FXEX::FXFileIO::mode (  FXuint m ) 
 

Set file permissions (mode flags).

The permissions that can be set, are taken from the 'unix way' - I have looked at the Win32 security permissions/ACL's for files; get this, there is a permission to stop you deleting a file, but you can happily truncate to file to zero bytes - what the? If you have write access, then you might as well have delete access. In any case, if a better idea comes along we can always change it...

If the file exists, the permission is applied to a file immediately. If the file is yet to be opened, it is applied to the file on opening time.

FXuint FXEX::FXFileIO::mode (  ) 
 

Returns the permission (mode flags) on the file; if the file exists, the permission is the value from the file; if the file doesn't exist, the value returned is the 'default' value if no previous call to modeDefault() has been called, otherwise it is the value passed in the modeDefault() call.

virtual FXbool FXEX::FXFileIO::open (  )  [virtual]
 

open the file.

Reimplemented from FXEX::FXIOHandle.

virtual void FXEX::FXFileIO::close (  )  [virtual]
 

close the file.

Reimplemented from FXEX::FXIOHandle.

FXlong FXEX::FXFileIO::size (  ) 
 

get the current size.

FXbool FXEX::FXFileIO::isTemp (  )  const [inline]
 

is the file a temp file.

Definition at line 122 of file FXFileIO.h.

void FXEX::FXFileIO::setTemp (  FXbool t = TRUE ) 
 

mark the file, as a temp file - temp files are removed on close.

virtual void FXEX::FXFileIO::enable (  )  [virtual]
 

Enable FXFileIO to detect when new data is available from the file.

This moves the file pointer to the end of the file, reading in the file as it moves. It then tries to maintain the file pointer at the end of the file. The idea is that you can treat a file, like a socket, ie continually incoming data.

It is also used to enable 'auto-open' feature of FXFileIO which will detect when the filename exists, and if enabled will open the file for you.

If you want to have the 'auto-open' but not the 'new-data-available' functionality, handle SEL_IO_CONNECT in your app, then disable the FXFileIO object, finally return 0. eg

FXMAPFUNC(SEL_IO_CONNECT,App::ID_FILE,App::onAutoOpen),

long App::onAutoOpen(FXObject *sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),NULL); return 0; }

Reimplemented from FXEX::FXBaseObject.

virtual void FXEX::FXFileIO::disable (  )  [virtual]
 

Disable the ability to detect when mroe data is available from the file.

Reimplemented from FXEX::FXBaseObject.

void FXEX::FXFileIO::sync (  ) 
 

Flush/sync data to disk - returns when sync is complete.

Used to sunchronise memory mapped files, or when FILEIO_SYNC is not specified.

FXlong FXEX::FXFileIO::current (  ) 
 

what is current file pointer position.

FXbool FXEX::FXFileIO::seekbegin (  FXlong pos = 0 ) 
 

move to the start of file plus some number of pos bytes.

FXbool FXEX::FXFileIO::seek (  FXlong pos ) 
 

move to some point in the file, from where it is currently.

FXbool FXEX::FXFileIO::seekend (  FXlong pos = 0 ) 
 

move to the end of the file minus pos Note: zero is the first byte beyond the end of the file, -1 is one past the end of the file (differs from lseek).

FXbool FXEX::FXFileIO::truncate (  FXlong len ) 
 

truncate the file to some length Note: you should really check the size of the file, after you call truncate.

FXbool FXEX::FXFileIO::lock (  )  [inline]
 

nice and simple lock interface.

Definition at line 177 of file FXFileIO.h.

FXbool FXEX::FXFileIO::unlock (  FXlong len ) 
 

nice and simple unlock interface.

FXint FXEX::FXFileIO::isLocked (  FXlong len = 0 ) 
 

is the file already locked - a length of zero implies the whole file - for the simple interface, a non-zero return code implies some form of lock - otherwise, returns 'Unlocked' (0) if not locked, or the type of lock.

FXbool FXEX::FXFileIO::readLock (  FXlong len = 0,
FXint timeout = 0
) 
 

lock a file - read lock - multiple read locks can be in-force (by multiple processes) at any given time - never unlocks any other lock - locking with a length of zero means lock the whole file - otherwise lock the number of bytes, begining from the current position - timeout is in milliseconds.

FXbool FXEX::FXFileIO::writeLock (  FXlong len = 0,
FXint timeout = 0
) 
 

lock a file - write lock - only one lock can be in force at any given time, ie the write lock - cannot unlock any other lock - a write lock still allows you to read the file (ie it is a more powerful read lock) - locking with a length of zero means lock the whole file - otherwise lock the number of bytes, begining from the current position - timeout is in milliseconds.

void FXEX::FXFileIO::setLockRetry (  FXuint retry )  [inline]
 

this allows us to adjust or retry interval when trying to set a lock - retry in nanoseconds.

Definition at line 207 of file FXFileIO.h.

FXbool FXEX::FXFileIO::map (  FXlong len,
FXbool writeable = TRUE
) 
 

this class supports memory mapping of the file, but only one region at a time... load part of the file into memory, from the current seek position.

void FXEX::FXFileIO::unmap (  ) 
 

unload part of a file from memory.

FXbool FXEX::FXFileIO::isMapped (  )  [inline]
 

is the file mapped into memory.

Definition at line 217 of file FXFileIO.h.

void* FXEX::FXFileIO::getMapping (  )  [inline]
 

return pointer to mapped memory.

Definition at line 220 of file FXFileIO.h.

FXFileIO* FXEX::FXFileIO::duplicate (  FXInputHandle newHandle = INVALID_HANDLE )  [virtual]
 

duplicate this file handle.

Reimplemented from FXEX::FXIOHandle.

void FXEX::FXFileIO::modeDefault (  FXuint mode )  [inline, static]
 

set the default mode for all new FileIO objects.

Definition at line 226 of file FXFileIO.h.

FXuint FXEX::FXFileIO::modeDefault (  )  [inline, static]
 

get the default mode of all new FileIO objects.

Definition at line 229 of file FXFileIO.h.

virtual void FXEX::FXFileIO::save (  FXStream & store )  const [virtual]
 

save object to stream.

Reimplemented from FXEX::FXIOHandle.

virtual void FXEX::FXFileIO::load (  FXStream & store )  [virtual]
 

load object from stream.

Reimplemented from FXEX::FXIOHandle.