gatb.core-API-1.4.2
IFileSystem Class Referenceabstract

interface for some operations at file system level. More...

#include <IFileSystem.hpp>

Inheritance diagram for IFileSystem:
Inheritance graph

Public Types

typedef std::string Path
 

Public Member Functions

virtual size_t getMaxFilesNumber ()=0
 
virtual u_int64_t getAvailableSpace (const Path &path)=0
 
virtual Path getCurrentDirectory ()=0
 
virtual Path getDirectory (const Path &path)=0
 
virtual Path getTemporaryDirectory ()=0
 
virtual Path getBaseName (const Path &path, bool cutToFirstDot=false)=0
 
virtual Path getRealPath (const Path &file)=0
 
virtual std::string getExtension (const Path &file)=0
 
virtual std::string getTemporaryFilename (const std::string &filename="")=0
 
virtual bool doesExist (const Path &path)=0
 
virtual bool doesExistDirectory (const Path &path)=0
 
virtual bool isFolderEndingWith (const Path &path, const std::string &ending)=0
 
virtual u_int64_t getSize (const Path &path)=0
 
virtual int clearCache ()=0
 
virtual int mkdir (const Path &path, u_int64_t mode)=0
 
virtual int rmdir (const Path &path)=0
 
virtual int remove (const Path &path)=0
 
virtual int rename (const Path &from, const Path &to)=0
 
virtual void iterate (const Path &path, void(*callback)(const Path &entry, void *data), void *data)=0
 
virtual std::vector< Pathlistdir (const Path &path)=0
 
virtual IFilenewFile (const Path &path, const char *mode)=0
 
virtual IFilenewFile (const Path &dirpath, const Path &filename, const char *mode)=0
 
virtual ssize_t getAttribute (const Path &filename, const char *key, std::string &value)=0
 
virtual ssize_t setAttribute (const Path &filename, const char *key, const char *fmt,...)=0
 
virtual ~IFileSystem ()
 

Detailed Description

interface for some operations at file system level.

This interface define a few operations like creating/deleting directories.

It can provide information like the max number of files that can be used at the same time, or the available space at some location in the FFS.

It also acts as a factory that creates IFile instances.

See also
IFile

Member Typedef Documentation

typedef std::string Path

Alias type for a file system path.

Constructor & Destructor Documentation

virtual ~IFileSystem ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual int clearCache ( )
pure virtual

Clear the file system cache.

Implemented in FileSystemLinux, and FileSystemMacos.

virtual bool doesExist ( const Path path)
pure virtual

Tells whether a file exists or not.

Returns
true if file exists, false otherwise

Implemented in FileSystemCommon.

virtual bool doesExistDirectory ( const Path path)
pure virtual

Tells whether a folder exists or not.

Returns
true if folder exists, false otherwise

Implemented in FileSystemCommon.

virtual ssize_t getAttribute ( const Path filename,
const char *  key,
std::string &  value 
)
pure virtual

Get metadata associated with the file for a given key.

Parameters
[in]filename: name of the file.
[in]key: key for which we want the value
[in]value: value associated to the key
Returns
-1 if KO, 0 otherwise, otherwise length of the retrieved value.

Implemented in FileSystemCommon, FileSystemLinux, and FileSystemMacos.

virtual u_int64_t getAvailableSpace ( const Path path)
pure virtual

Return the available space at the location given by the provided path.

Parameters
[in]path: the location from where the space size is computed.
Returns
the available size (in KBytes).

Implemented in FileSystemCommon.

virtual Path getBaseName ( const Path path,
bool  cutToFirstDot = false 
)
pure virtual

Return the base of the URI

Parameters
[in]path: uri from which we want to extract the base name.
[in]cutToFirstDot: by default, getBaseName("a.b.c.fq") = "a.b.c". If cutToFirstDot is true, will return just "a"
Returns
the base name of the uri

Implemented in FileSystemCommon.

virtual Path getCurrentDirectory ( )
pure virtual

Retrieve the current directory absolute path.

Returns
the current directory to be retrieved.

Implemented in FileSystemCommon.

virtual Path getDirectory ( const Path path)
pure virtual

Retrieve the directory of the provided name.

Returns
the directory

Implemented in FileSystemCommon.

virtual std::string getExtension ( const Path file)
pure virtual

Return the extension to the given file,

Parameters
[in]file: file
Returns
extension

Implemented in FileSystemCommon.

virtual size_t getMaxFilesNumber ( )
pure virtual

Return the maximum number of files that can be used at the same time.

Returns
the max number of files.

Implemented in FileSystemLinux, and FileSystemMacos.

virtual Path getRealPath ( const Path file)
pure virtual

Return the canonical path to the given file, ie replace symbolic links or relative path.

Parameters
[in]file: the file we want the canonical path.
Returns
the real path.

Implemented in FileSystemCommon.

virtual u_int64_t getSize ( const Path path)
pure virtual

Return the size of the file given by the provided path.

Parameters
[in]path: the location from where the space size is computed.
Returns
the available size (in Bytes).

Implemented in FileSystemCommon.

virtual Path getTemporaryDirectory ( )
pure virtual

Retrieve the default temporary directory absolute path.

Returns
the temporary directory to be retrieved.

Implemented in FileSystemCommon.

virtual std::string getTemporaryFilename ( const std::string &  filename = "")
pure virtual

Get a temporary file name. One may provide an argument; in such a case some prefix/suffix will be appended to this name in order to make it unique.

Parameters
[in]filename: file name (may be empty)
Returns
a unique file name.

Implemented in FileSystemCommon.

virtual bool isFolderEndingWith ( const Path path,
const std::string &  ending 
)
pure virtual

Tells whether path is a folder that ends with a certain string

Returns
true if folder ends with string, false otherwise

Implemented in FileSystemCommon.

virtual void iterate ( const Path path,
void(*)(const Path &entry, void *data)  callback,
void *  data 
)
pure virtual

Iterates entries of a directory.

Parameters
[in]path: path of the directory to be iterated
[in]callback: callback called for each found entry
[in]data: private data given to the callback.

Implemented in FileSystemCommon.

virtual std::vector<Path> listdir ( const Path path)
pure virtual

Get entries of a directory.

Parameters
[in]path: path of the explored directory

Implemented in FileSystemCommon.

virtual int mkdir ( const Path path,
u_int64_t  mode 
)
pure virtual

Create a directory for the provided path and mode.

Parameters
[in]path: path of the directory to be created.
[in]mode: mode of creation (see 'mkdir' system function documentation).

Implemented in FileSystemCommon.

virtual IFile* newFile ( const Path path,
const char *  mode 
)
pure virtual

Creates a new IFile instance (equivalent to 'fopen' function)

Parameters
[in]path: uri of the file to be opened.
[in]mode: mode of the file (like fopen)
Returns
instance of IFile, 0 otherwise.

Implemented in FileSystemLinux, and FileSystemMacos.

virtual IFile* newFile ( const Path dirpath,
const Path filename,
const char *  mode 
)
pure virtual

Creates a new IFile instance (equivalent to 'fopen' function)

Parameters
[in]dirpath: uri of the directory where the file is meant to be.
[in]filename: name of the file
[in]mode: mode of the file (like fopen)
Returns
instance of IFile, 0 otherwise.

Implemented in FileSystemLinux, and FileSystemMacos.

virtual int remove ( const Path path)
pure virtual

Delete the file given its path.

Parameters
[in]path: path of the file to be removed from the file system.

Implemented in FileSystemCommon.

virtual int rename ( const Path from,
const Path to 
)
pure virtual

Rename the provided uri

Parameters
[in]from: initial name.
[in]to: final name.

Implemented in FileSystemCommon.

virtual int rmdir ( const Path path)
pure virtual

Delete the entry given its path.

Parameters
[in]path: path of the entry to be removed from the file system.

Implemented in FileSystemCommon.

virtual ssize_t setAttribute ( const Path filename,
const char *  key,
const char *  fmt,
  ... 
)
pure virtual

Set metadata associated with the file for a given key.

Parameters
[in]filename: name of the file.
[in]key: key for which we want the value
[in]fmt: format of the string (in the 'printf' way)
[in]...: paramters for the format parameter
Returns
-1 if error, 0 otherwise.

Implemented in FileSystemCommon, FileSystemLinux, and FileSystemMacos.


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