OpendTect-6_4  6.4
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
FilePath Class Reference

File pathname tools. More...

Public Types

enum  Style { Local, Unix, Windows }
 

Public Member Functions

 FilePath (const char *fullinp=0)
 
 FilePath (const char *p1, const char *p2, const char *p3=0, const char *p4=0, const char *p5=0)
 
 FilePath (const FilePath &fp)
 
 FilePath (const FilePath &, const char *p2, const char *p3=0, const char *p4=0, const char *p5=0)
 
FilePathoperator= (const FilePath &)
 
FilePathoperator= (const char *fullinp)
 
bool operator== (const FilePath &) const
 
bool operator== (const char *fnm) const
 
bool operator!= (const FilePath &) const
 
bool operator!= (const char *fnm) const
 
bool isEmpty () const
 
FilePathset (const char *fullinp)
 
FilePathadd (const char *)
 at end More...
 
FilePathinsert (const char *)
 after prefix at start More...
 
void setFileName (const char *)
 pass null to remove level More...
 
void setPath (const char *)
 including prefix More...
 
void setExtension (const char *, bool replace=true)
 !replace => add More...
 
bool exists () const
 
bool isAbsolute () const
 
bool isSubDirOf (const FilePath &, FilePath *reldir=0) const
 
bool makeRelativeTo (const FilePath &)
 
bool makeCanonical ()
 
BufferString fullPath (Style s=Local, bool cleanup=true) const
 
const char * prefix () const
 
int nrLevels () const
 
const char * extension () const
 may return null More...
 
const OD::StringfileName () const
 
BufferString baseName () const
 return name of file w/o path & ext More...
 
BufferString pathOnly () const
 
BufferString winDrive () const
 
const OD::Stringdir (int nr=-1) const
 nr < 0 returns last dir name More...
 
BufferString dirUpTo (int) const
 nr < 0 returns last dir, including prefix More...
 

Static Public Member Functions

static BufferString getTempDir ()
 
static BufferString getTempName (const char *ext=0)
 
static BufferString mkCleanPath (const char *path, Style fmt)
 
static BufferString getTimeStampFileName (const char *ext=0)
 
static const char * dirSep (Style)
 

Static Public Attributes

static const char * sPrefSep
 

Protected Member Functions

void addPart (const char *)
 
void compress (int sl=0)
 
void trueDirIfLink ()
 

Protected Attributes

bool isabs_
 
BufferString prefix_
 
BufferStringSet lvls_
 

Detailed Description

File pathname tools.

This class splits a full filename (with path) into the separate parts: directories and possibly a filename (the last part does not have to be a file name). That makes it easy to change the file name, or the path only, or the extension, add directories, etc.

To get the result after manipulation, use the fullPath().

fileName() returns the last part, pathOnly() returns all but the last part. setFileName() replaces the last part, setPath() replaces all but the last part.

Member Enumeration Documentation

Enumerator
Local 
Unix 
Windows 

Constructor & Destructor Documentation

FilePath::FilePath ( const char *  fullinp = 0)
FilePath::FilePath ( const char *  p1,
const char *  p2,
const char *  p3 = 0,
const char *  p4 = 0,
const char *  p5 = 0 
)
FilePath::FilePath ( const FilePath fp)
inline
FilePath::FilePath ( const FilePath ,
const char *  p2,
const char *  p3 = 0,
const char *  p4 = 0,
const char *  p5 = 0 
)

Member Function Documentation

FilePath& FilePath::add ( const char *  )

at end

void FilePath::addPart ( const char *  )
protected
BufferString FilePath::baseName ( ) const

return name of file w/o path & ext

void FilePath::compress ( int  sl = 0)
protected
const OD::String& FilePath::dir ( int  nr = -1) const

nr < 0 returns last dir name

static const char* FilePath::dirSep ( Style  )
static
BufferString FilePath::dirUpTo ( int  ) const

nr < 0 returns last dir, including prefix

bool FilePath::exists ( ) const
const char* FilePath::extension ( ) const

may return null

const OD::String& FilePath::fileName ( ) const
BufferString FilePath::fullPath ( Style  s = Local,
bool  cleanup = true 
) const
static BufferString FilePath::getTempDir ( )
static
static BufferString FilePath::getTempName ( const char *  ext = 0)
static
static BufferString FilePath::getTimeStampFileName ( const char *  ext = 0)
static
FilePath& FilePath::insert ( const char *  )

after prefix at start

bool FilePath::isAbsolute ( ) const
bool FilePath::isEmpty ( ) const
bool FilePath::isSubDirOf ( const FilePath ,
FilePath reldir = 0 
) const

If reldir is set, it will be filled with the relative path.

bool FilePath::makeCanonical ( )
bool FilePath::makeRelativeTo ( const FilePath )
static BufferString FilePath::mkCleanPath ( const char *  path,
Style  fmt 
)
static
int FilePath::nrLevels ( ) const
bool FilePath::operator!= ( const FilePath ) const
bool FilePath::operator!= ( const char *  fnm) const
FilePath& FilePath::operator= ( const FilePath )
FilePath& FilePath::operator= ( const char *  fullinp)
bool FilePath::operator== ( const FilePath ) const
bool FilePath::operator== ( const char *  fnm) const
BufferString FilePath::pathOnly ( ) const
const char* FilePath::prefix ( ) const
FilePath& FilePath::set ( const char *  fullinp)
void FilePath::setExtension ( const char *  ,
bool  replace = true 
)

!replace => add

void FilePath::setFileName ( const char *  )

pass null to remove level

void FilePath::setPath ( const char *  )

including prefix

void FilePath::trueDirIfLink ( )
protected
BufferString FilePath::winDrive ( ) const

Member Data Documentation

bool FilePath::isabs_
protected
BufferStringSet FilePath::lvls_
protected
BufferString FilePath::prefix_
protected
const char* FilePath::sPrefSep
static

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019