Public Types | Public Member Functions | Static Public Member Functions

base::FileT< sizeT, traits > Class Template Reference

Template File functions. More...

#include <libppbase/base/File.h>

Inheritance diagram for base::FileT< sizeT, traits >:
base::FileBase

List of all members.

Public Types

typedef sizeT size_type
 data type for sizes

Public Member Functions

 FileT ()
 Constructor that does not open a file.
 FileT (const char *name, int flags=ofReadOnly, int mode=0666)
 Constructor that opens a file.
 FileT (const String &name, int flags=ofReadOnly, int mode=0666)
 Constructor that opens a file.
 FileT (handle_type fd, const String &name="", bool temp=false, bool stayopen=false, int allocbufs=3)
 Constructor that creates a new file object with an already open file.
StatT< sizeT > fstat () const
 Returns information on the file.
sizeT getPos () const
 Returns current file position.
void seek (sizeT pos)
 Seeks to a file position.
void seekEOF ()
 Seeks to the end of the file.
sizeT size () const
 Returns the file size.
void truncate (sizeT len)
 Truncates the file to a given size.
 DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT (FileT)
 file objects cannot be duplicated

Static Public Member Functions

static StatT< sizeT > stat (const String &path)
 Returns information on a file.

Detailed Description

template<class sizeT, class traits = SizeTraits<sizeT>>
class base::FileT< sizeT, traits >

Template File functions.

Author:
Christoph Schwarz
Version:
$Id: File.h 21 2010-09-05 04:18:17Z cschwarz1 $

Constructor & Destructor Documentation

template<class sizeT, class traits = SizeTraits<sizeT>>
base::FileT< sizeT, traits >::FileT ( const char *  name,
int  flags = ofReadOnly,
int  mode = 0666 
) [inline]

Constructor that opens a file.

Parameters:
name file name
flags open flags
mode open mode
Exceptions:
std::bad_alloc when out of memory
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
base::FileT< sizeT, traits >::FileT ( const String name,
int  flags = ofReadOnly,
int  mode = 0666 
) [inline]

Constructor that opens a file.

Parameters:
name file name
flags open flags
mode open mode
Exceptions:
std::bad_alloc when out of memory
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
base::FileT< sizeT, traits >::FileT ( handle_type  fd,
const String name = "",
bool  temp = false,
bool  stayopen = false,
int  allocbufs = 3 
) [inline]

Constructor that creates a new file object with an already open file.

Parameters:
fd the already open file descriptor
name the file name
temp flag: this is a temporary file
stayopen flag: keep file descriptor open
allocbufs bitlist: bit 0 = allocate read buffer, bit 1 = allocate write buffer
Exceptions:
std::bad_alloc when out of memory
IOException on error

Member Function Documentation

template<class sizeT, class traits = SizeTraits<sizeT>>
StatT<sizeT> base::FileT< sizeT, traits >::fstat (  )  const [inline]

Returns information on the file.

Returns:
file information
Exceptions:
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
sizeT base::FileT< sizeT, traits >::getPos (  )  const [inline]

Returns current file position.

Returns:
current file position in bytes relative to the start of the file
Exceptions:
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
void base::FileT< sizeT, traits >::seek ( sizeT  pos  )  [inline]

Seeks to a file position.

Parameters:
pos the file position
Exceptions:
IOException on error

Referenced by base::FileT< size_t >::truncate().

template<class sizeT, class traits = SizeTraits<sizeT>>
sizeT base::FileT< sizeT, traits >::size (  )  const [inline]

Returns the file size.

Returns:
the file size in bytes
Exceptions:
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
static StatT<sizeT> base::FileT< sizeT, traits >::stat ( const String path  )  [inline, static]

Returns information on a file.

Returns:
file information
Exceptions:
IOException on error
template<class sizeT, class traits = SizeTraits<sizeT>>
void base::FileT< sizeT, traits >::truncate ( sizeT  len  )  [inline]

Truncates the file to a given size.

Parameters:
len the size to truncate the file to
Exceptions:
IOException on error

The documentation for this class was generated from the following file: