IOSS  2.0
Ioss::FileInfo Class Reference

Return information about the specified file. More...

#include <Ioss_FileInfo.h>

Public Member Functions

 FileInfo ()
 Empty class referring to no file. More...
 
 FileInfo (std::string my_filename)
 
 FileInfo (const char *my_filename)
 
 FileInfo (const FileInfo &)
 Copy constructor. More...
 
 FileInfo (const std::string &dirpath, const std::string &my_filename)
 
 ~FileInfo ()
 
int parallel_exists (MPI_Comm communicator, std::string &where) const
 
bool exists () const
 returns True if file exists, false if nonexistent More...
 
bool is_readable () const
 Exists and is readable. More...
 
bool is_writable () const
 Exists and is writable. More...
 
bool is_executable () const
 Exists and is executable. More...
 
bool is_file () const
 Is a plain file. More...
 
bool is_dir () const
 Is a directory. More...
 
bool is_symlink () const
 Is a symbolic link to a file or directory. More...
 
time_t modified () const
 Time of last data modification. See 'man stat(2)'. More...
 
time_t accessed () const
 Time of last access. More...
 
time_t created () const
 Time of last status change. (creation, chmod, ...) More...
 
off_t size () const
 File size in bytes. Only if is_file() == true. More...
 
const std::string filename () const
 Complete filename including path. More...
 
const std::string basename () const
 strip path and extension More...
 
const std::string tailname () const
 basename() + extension() More...
 
const std::string extension () const
 file extension. More...
 
const std::string pathname () const
 directory path, no filename More...
 
void set_filename (const std::string &name)
 
void set_filename (const char *name)
 
bool operator== (const FileInfo &other) const
 
bool operator!= (const FileInfo &other) const
 
bool remove_file ()
 

Private Attributes

std::string filename_ {}
 
bool exists_ {false}
 this is used frequently, check on creation More...
 
bool readable_ {false}
 this is used frequently, check on creation More...
 

Detailed Description

Return information about the specified file.

Author
Greg Sjaardema A very minimal class (at least it used to be) for providing information about a file. FileInfo provides information about a file's name, path, and type (directory, symbolic link, file). Other information could be added as needed. It currently does not cache any information, so if it is heavily used, a caching capability should be added. See the Qt Toolkit QFileInfo class for a richer file class.

Constructor & Destructor Documentation

◆ FileInfo() [1/5]

Ioss::FileInfo::FileInfo ( )
default

Empty class referring to no file.

◆ FileInfo() [2/5]

Ioss::FileInfo::FileInfo ( std::string  my_filename)
explicit

Create object referring to file with name filename

Parameters
my_filenamename of file

◆ FileInfo() [3/5]

Ioss::FileInfo::FileInfo ( const char *  my_filename)
explicit

Create object referring to file with name filename

Parameters
my_filenamename of file

◆ FileInfo() [4/5]

Ioss::FileInfo::FileInfo ( const FileInfo )
default

Copy constructor.

◆ FileInfo() [5/5]

Ioss::FileInfo::FileInfo ( const std::string &  dirpath,
const std::string &  my_filename 
)

Constructor

Parameters
dirpathDirectory Path
my_filenamebase filename

◆ ~FileInfo()

Ioss::FileInfo::~FileInfo ( )
default

Member Function Documentation

◆ accessed()

time_t Ioss::FileInfo::accessed ( ) const

Time of last access.

◆ basename()

const std::string Ioss::FileInfo::basename ( ) const

strip path and extension

◆ created()

time_t Ioss::FileInfo::created ( ) const

Time of last status change. (creation, chmod, ...)

◆ exists()

bool Ioss::FileInfo::exists ( ) const

returns True if file exists, false if nonexistent

◆ extension()

const std::string Ioss::FileInfo::extension ( ) const

file extension.

◆ filename()

const std::string Ioss::FileInfo::filename ( ) const

Complete filename including path.

◆ is_dir()

bool Ioss::FileInfo::is_dir ( ) const

Is a directory.

◆ is_executable()

bool Ioss::FileInfo::is_executable ( ) const

Exists and is executable.

◆ is_file()

bool Ioss::FileInfo::is_file ( ) const

Is a plain file.

◆ is_readable()

bool Ioss::FileInfo::is_readable ( ) const

Exists and is readable.

◆ is_symlink()

bool Ioss::FileInfo::is_symlink ( ) const

Is a symbolic link to a file or directory.

◆ is_writable()

bool Ioss::FileInfo::is_writable ( ) const

Exists and is writable.

◆ modified()

time_t Ioss::FileInfo::modified ( ) const

Time of last data modification. See 'man stat(2)'.

◆ operator!=()

bool Ioss::FileInfo::operator!= ( const FileInfo other) const
inline

◆ operator==()

bool Ioss::FileInfo::operator== ( const FileInfo other) const
inline

◆ parallel_exists()

int Ioss::FileInfo::parallel_exists ( MPI_Comm  communicator,
std::string &  where 
) const

returns the number of processors that this file exists. 0: Exists nowhere #proc: Exists everywhere else: exists on some proc, but not all. In the last case, a list of processors where it is missing is returned in 'where' on processor 0.

◆ pathname()

const std::string Ioss::FileInfo::pathname ( ) const

directory path, no filename

◆ remove_file()

bool Ioss::FileInfo::remove_file ( )

◆ set_filename() [1/2]

void Ioss::FileInfo::set_filename ( const std::string &  name)

◆ set_filename() [2/2]

void Ioss::FileInfo::set_filename ( const char *  name)

◆ size()

off_t Ioss::FileInfo::size ( ) const

File size in bytes. Only if is_file() == true.

◆ tailname()

const std::string Ioss::FileInfo::tailname ( ) const

Member Data Documentation

◆ exists_

bool Ioss::FileInfo::exists_ {false}
private

this is used frequently, check on creation

◆ filename_

std::string Ioss::FileInfo::filename_ {}
private

◆ readable_

bool Ioss::FileInfo::readable_ {false}
private

this is used frequently, check on creation


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