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

Static Public Member Functions

static const char * dirSep (Style)
 
static BufferString getFullLongPath (const FilePath &)
 
static BufferString getTempDir ()
 
static BufferString getTempFileName (const char *typ, const char *ext)
 
static BufferString getTempFullPath (const char *typ, const char *ext)
 
static BufferString getTempName (const char *ext=0)
 
static BufferString getTimeStampFileName (const char *ext)
 
static BufferString mkCleanPath (const char *path, Style fmt)
 

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_
 
BufferStringSet lvls_
 
BufferString prefix_
 

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

◆ Style

Enumerator
Local 
Unix 
Windows 

Constructor & Destructor Documentation

◆ FilePath() [1/4]

FilePath::FilePath ( const char *  fullinp = 0)

◆ FilePath() [2/4]

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

◆ FilePath() [3/4]

FilePath::FilePath ( const FilePath fp)
inline

◆ FilePath() [4/4]

FilePath::FilePath ( const FilePath ,
const char *  p2,
const char *  p3 = 0,
const char *  p4 = 0,
const char *  p5 = 0 
)

Member Function Documentation

◆ add()

FilePath& FilePath::add ( const char *  )

at end

◆ addPart()

void FilePath::addPart ( const char *  )
protected

◆ baseName()

BufferString FilePath::baseName ( ) const

return name of file w/o path & ext

◆ compress()

void FilePath::compress ( int  sl = 0)
protected

◆ dir()

const OD::String& FilePath::dir ( int  nr = -1) const

nr < 0 returns last dir name

◆ dirSep()

static const char* FilePath::dirSep ( Style  )
static

◆ dirUpTo()

BufferString FilePath::dirUpTo ( int  ) const

nr < 0 returns last dir, including prefix

◆ exists()

bool FilePath::exists ( ) const

◆ extension()

const char* FilePath::extension ( ) const

may return null

◆ fileName()

const OD::String& FilePath::fileName ( ) const

◆ fullPath()

BufferString FilePath::fullPath ( Style  s = Local,
bool  cleanup = true 
) const

◆ getFullLongPath()

static BufferString FilePath::getFullLongPath ( const FilePath )
static

◆ getTempDir()

static BufferString FilePath::getTempDir ( )
static

◆ getTempFileName()

static BufferString FilePath::getTempFileName ( const char *  typ,
const char *  ext 
)
static

◆ getTempFullPath()

static BufferString FilePath::getTempFullPath ( const char *  typ,
const char *  ext 
)
static

◆ getTempName()

static BufferString FilePath::getTempName ( const char *  ext = 0)
inlinestatic

◆ getTimeStampFileName()

static BufferString FilePath::getTimeStampFileName ( const char *  ext)
static

◆ insert()

FilePath& FilePath::insert ( const char *  )

after prefix at start

◆ isAbsolute()

bool FilePath::isAbsolute ( ) const

◆ isEmpty()

bool FilePath::isEmpty ( ) const

◆ isSubDirOf()

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

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

◆ makeCanonical()

bool FilePath::makeCanonical ( )

◆ makeRelativeTo()

bool FilePath::makeRelativeTo ( const FilePath )

◆ mkCleanPath()

static BufferString FilePath::mkCleanPath ( const char *  path,
Style  fmt 
)
static

◆ nrLevels()

int FilePath::nrLevels ( ) const

◆ operator!=() [1/2]

bool FilePath::operator!= ( const char *  fnm) const

◆ operator!=() [2/2]

bool FilePath::operator!= ( const FilePath ) const

◆ operator=() [1/2]

FilePath& FilePath::operator= ( const char *  fullinp)

◆ operator=() [2/2]

FilePath& FilePath::operator= ( const FilePath )

◆ operator==() [1/2]

bool FilePath::operator== ( const char *  fnm) const

◆ operator==() [2/2]

bool FilePath::operator== ( const FilePath ) const

◆ partitionName()

BufferString FilePath::partitionName ( ) const

◆ pathOnly() [1/2]

BufferString FilePath::pathOnly ( ) const

◆ pathOnly() [2/2]

BufferString FilePath::pathOnly ( Style  ) const

◆ prefix()

const char* FilePath::prefix ( ) const

◆ rootPath()

BufferString FilePath::rootPath ( ) const

◆ set()

FilePath& FilePath::set ( const char *  fullinp)

◆ setExtension()

void FilePath::setExtension ( const char *  ,
bool  replace = true 
)

!replace => add

◆ setFileName()

void FilePath::setFileName ( const char *  )

pass null to remove level

◆ setPath()

void FilePath::setPath ( const char *  )

including prefix

◆ trueDirIfLink()

void FilePath::trueDirIfLink ( )
protected

◆ winDrive()

BufferString FilePath::winDrive ( ) const

Member Data Documentation

◆ isabs_

bool FilePath::isabs_
protected

◆ lvls_

BufferStringSet FilePath::lvls_
protected

◆ prefix_

BufferString FilePath::prefix_
protected

◆ sPrefSep

const char* FilePath::sPrefSep
static

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