FX::QFile Class Reference
[File type i/o devices]

#include <QFile.h>

Inheritance diagram for FX::QFile:

FX::QIODevice List of all members.

Detailed Description

An i/o device accessing the filing system directly (Qt compatible).

Not much to say about this - it works as you'd expect. It's also thread-safe so multiple threads can read and write from it (though the current file pointer is the same for both, so it probably doesn't help you much).

Most likely you'll prefer to use FX::QMemMap all the time as it offers superior performance and facilities in most cases. Indeed, QFile does no internal buffering as it is expected it will only be used rarely, mostly for small files with little i/o performed to them.

Like all file type i/o classes, QFile can perform automatic CR/LF translation as well as UTF-8 to UTF-16 and UTF-32 conversion. If you enable IO_Translate, the file data is probed and its unicode type determined such that the file unicode type is transparently converted into UTF-8 and back into its original form. This allows your code to work exclusively in UTF-8 using the standard FX::FXString functions. You can set the type of output using setUnicodeTranslation().

For speed, QFile maintains its own record of file length which it manages. This normally isn't a problem, but when multiple QFile's are working on the same file (either in-process or across processes) then the internal count can become desynchronised with the actual length. If you want to reset the length, call reloadSize().

One major difference is default security, especially on NT. QFile like all TnFOX sets very conservative permissions on all things it creates - see FX::FXACL::default_(). Note that until the file is opened, permissions() returns what will be applied to the file on open() rather than the file itself - if you want the latter, use the static method.

Warning:
Try not to call atEnd() too much. Because of limitations in POSIX it works by reading a byte which if successful means not EOF and a ungetch() or moving the file pointer back!

Definition at line 76 of file QFile.h.

Public Types

typedef FXfval Offset
 Default
 Unix
 MacOS
 MSDOS
 NoTranslation
 UTF8
 UTF16
 UTF16LE
 UTF32
 UTF32LE
enum  CRLFType { Default, Unix, MacOS, MSDOS }
enum  UnicodeType {
  NoTranslation, UTF8, UTF16, UTF16LE,
  UTF32, UTF32LE
}

Public Member Functions

 QFile ()
 QFile (const FXString &name)
 ~QFile ()
const FXStringname () const
void setName (const FXString &name)
bool exists () const
bool remove ()
FXfval reloadSize ()
virtual bool open (FXuint mode)
virtual void close ()
virtual void flush ()
virtual FXfval size () const
virtual void truncate (FXfval size)
virtual FXfval at () const
virtual bool at (FXfval newpos)
virtual bool atEnd () const
virtual const FXACLpermissions () const
virtual void setPermissions (const FXACL &perms)
virtual FXuval readBlock (char *data, FXuval maxlen)
virtual FXuval writeBlock (const char *data, FXuval maxlen)
virtual FXuval readBlockFrom (char *data, FXuval maxlen, FXfval pos)
virtual FXuval writeBlockTo (FXfval pos, const char *data, FXuval maxlen)
virtual int ungetch (int c)
FXuint flags () const
FXuint mode () const
FXuint state () const
CRLFType crlfFormat () const
void setCRLFFormat (CRLFType type)
UnicodeType unicodeTranslation () const
void setUnicodeTranslation (UnicodeType type)
bool isBuffered () const
bool isRaw () const
bool isTranslated () const
bool isUTF16Translated () const
bool isUTF32Translated () const
bool isReadable () const
bool isWriteable () const
bool isWritable () const
bool isReadWrite () const
bool isClosed () const
bool isInactive () const
bool isOpen () const
virtual bool isSynchronous () const
FXuval readBlock (FXuchar *data, FXuval maxlen)
FXuval writeBlock (const FXuchar *data, FXuval maxlen)
virtual FXuval readLine (char *data, FXuval maxlen)
FXuval readBlockFrom (FXuchar *data, FXuval maxlen, FXfval pos)
FXuval writeBlockTo (FXfval pos, const FXuchar *data, FXuval maxlen)
virtual int getch ()
virtual int putch (int c)
FXfval shredData (FXfval offset, FXfval len=(FXfval)-1)

Static Public Member Functions

static QIODevicestdio (bool applyCRLFTranslation=false)
static FXACL permissions (const FXString &path)
static void setPermissions (const FXString &path, const FXACL &perms)
static UnicodeType determineUnicodeType (FXuchar *data, FXuval len) throw ()
static FXuval applyCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, CRLFType crlftype=Default, UnicodeType utftype=NoTranslation)
static FXuval removeCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, UnicodeType utftype=NoTranslation)

Protected Member Functions

void setFlags (int f)
void setMode (int m)
void setState (int s)

Protected Attributes

FXfval ioIndex

Friends

class QMemMap
class FXProcess
FXAPI FXStreamoperator<< (FXStream &s, QIODevice &i)
FXAPI FXStreamoperator>> (FXStream &s, QIODevice &i)


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:37 2009 for TnFOX by doxygen v1.4.7