pdftron::Filters::StdFile Class Reference

StdFile is a utility class to read from, write to, open, and close files on a file system. More...

#include <StdFile.h>

Inheritance diagram for pdftron::Filters::StdFile:

Inheritance graph
[legend]
Collaboration diagram for pdftron::Filters::StdFile:

Collaboration graph
[legend]

List of all members.

Public Types

enum  OpenMode { e_read_mode, e_write_mode, e_append_mode }

Public Member Functions

 StdFile (const UString &filename, OpenMode open_mode, size_t buf_sz=1024)
 Create a new instance of StdFile class with the specified path and creation mode.
 StdFile (const char *filename, OpenMode open_mode, size_t buf_sz=1024)
 StdFile (FILE *stm, OpenMode open_mode, size_t buf_sz=1024)
 Create a new instance of StdFile class using the given instance of standard file stream.
bool operator== (const StdFile &f) const
 Check is the two StdFile-s refer to the same file on disc.
size_t FileSize ()

Static Public Member Functions

static bool Equivalent (const UString &ph1, const UString &ph2)
 Check is the two file paths are equivalent (i.e.


Detailed Description

StdFile is a utility class to read from, write to, open, and close files on a file system.

Because StdFile file is derived from pdftron.Filters.Filter you can directly chain StdFile objects to other 'pdftron.Filters'.

StdFile objects support random access to files using the Seek method. Seek allows the read/write position to be moved to any position within the file. This is done with byte offset reference point parameters. The byte offset is relative to the seek reference point, which can be the beginning, the current position, or the end of the underlying file, as represented by the three properties of the Fileter.ReferencePos class.

Disk files always support random access. At the time of construction, the CanSeek() property value is set to true or false depending on the underlying file type.

Note:
.NET or Java applications should explicitly Close() files when they are not needed. If the files are not closed or disposed this may lead to the resource exhaustion.

Member Enumeration Documentation

Enumerator:
e_read_mode  Opens file for reading. An exception is thrown if the file doesn't exist.
e_write_mode  Opens an empty file for writing. If the given file exists, its contents are destroyed.
e_append_mode  Opens for reading and appending. Creates the file first if it doesn't exist.


Constructor & Destructor Documentation

pdftron::Filters::StdFile::StdFile ( const UString filename,
OpenMode  open_mode,
size_t  buf_sz = 1024 
)

Create a new instance of StdFile class with the specified path and creation mode.

pdftron::Filters::StdFile::StdFile ( const char *  filename,
OpenMode  open_mode,
size_t  buf_sz = 1024 
)

pdftron::Filters::StdFile::StdFile ( FILE *  stm,
OpenMode  open_mode,
size_t  buf_sz = 1024 
)

Create a new instance of StdFile class using the given instance of standard file stream.

Note:
StdFile does not take the ownership of the file stream and the calling function is responsible for closing the file.


Member Function Documentation

bool pdftron::Filters::StdFile::operator== ( const StdFile f  )  const

Check is the two StdFile-s refer to the same file on disc.

Returns:
true if the two files share the same filename, false otherwise.

static bool pdftron::Filters::StdFile::Equivalent ( const UString ph1,
const UString ph2 
) [static]

Check is the two file paths are equivalent (i.e.

they refer to the same file on disc.

Returns:
true if the two files share the same filename, false otherwise.

size_t pdftron::Filters::StdFile::FileSize (  ) 

Returns:
the size of the current file.


© 2002-2010 PDFTron Systems Inc.