gatb.core-API-0.0.0
IFile Class Referenceabstract

Abstraction of what we need about file. More...

#include <IFileSystem.hpp>

Inheritance diagram for IFile:
Inheritance graph

Public Member Functions

virtual bool isOpen ()=0
 
virtual bool isEOF ()=0
 
virtual int seeko (u_int64_t offset, int whence)=0
 
virtual u_int64_t tell ()=0
 
virtual int get ()=0
 
virtual int unget (int c)=0
 
virtual int gets (char *s, int size)=0
 
virtual void print (const char *format,...)=0
 
virtual size_t fread (void *ptr, size_t size, size_t nmemb)=0
 
virtual size_t fwrite (const void *ptr, size_t size, size_t nmemb)=0
 
virtual void flush ()=0
 
virtual u_int64_t getSize ()=0
 
virtual const std::string & getPath () const =0
 
virtual ~IFile ()
 

Detailed Description

Abstraction of what we need about file.

We define here a few methods we need for handling files.

NOTE: deleting a IFile instance won't delete the file on the file system; one should see IFile as a logical handle on a physical file.

Constructor & Destructor Documentation

virtual ~IFile ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual void flush ( )
pure virtual

Flush the file.

Implemented in CommonFile.

virtual size_t fread ( void *  ptr,
size_t  size,
size_t  nmemb 
)
pure virtual

Reads a buffer from the file.

Parameters
[in]ptr: the buffer to be read
[in]size: size of the buffer
[in]nmemb: number of elements to be written
Returns
number of items successfully written

Implemented in CommonFile.

virtual size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb 
)
pure virtual

Writes a buffer into the file.

Parameters
[in]ptr: the buffer to be written
[in]size: size of the buffer
[in]nmemb: number of elements to be written
Returns
number of items successfully written

Implemented in CommonFile.

virtual int get ( )
pure virtual

Get the currently pointed character in the file.

Returns
the current character.

Implemented in CommonFile.

virtual const std::string& getPath ( ) const
pure virtual

Get the file URI

Returns
the URI of the file

Implemented in CommonFile.

virtual int gets ( char *  s,
int  size 
)
pure virtual

Reads a line in the file.

Parameters
[in]s: buffer where to put the read line.
[in]size: maximum number of characters to be read
Returns
the actual size of the read buffer (0 if nothing read)

Implemented in CommonFile.

virtual u_int64_t getSize ( )
pure virtual

Get the size of a file.

Returns
the size of the file.

Implemented in CommonFile.

virtual bool isEOF ( )
pure virtual

Tells whether or not we are at the end of a file.

Returns
true if we are at the end of the file, false otherwise.

Implemented in CommonFile.

virtual bool isOpen ( )
pure virtual

Tells whether the file is opened or not.

Returns
open status.

Implemented in CommonFile.

virtual void print ( const char *  format,
  ... 
)
pure virtual

Writes a buffer (0 terminated) into the file with a new line.

Parameters
[in]format: format of the data to be dumped into the file.
[in]...: arguments (as an ellipsis) to b dumped

Implemented in CommonFile.

virtual int seeko ( u_int64_t  offset,
int  whence 
)
pure virtual

Locates the cursor into the file (similar to 'fseeko' functions)

Parameters
[in]offset: bytes number we want to go, relatively from the 'whence' paramater
[in]whence: SEEK_SET, SEEK_END, or SEEK_CUR
Returns
0 if successful, -1 otherwise
virtual u_int64_t tell ( )
pure virtual

Get the position in a file.

Returns
the current position
virtual int unget ( int  c)
pure virtual

Unget the currently pointed character in the file.

Parameters
[in]c: the current character.
Returns
c on success, EOF on error

Implemented in CommonFile.


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