OpendTect  7.0
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...
 
const char * dirSep () const
 
BufferString dirUpTo (int) const
 nr < 0 returns last dir, including prefix More...
 
const char * domain () const
 
bool exists () const
 
const char * extension () const
 may return null More...
 
BufferString fileFrom (int level) const
 
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 isURI () const
 
bool makeAbsolute (const FilePath &)
 
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 (Style s=Local) const
 
const char * postfix () const
 
const char * prefix () const
 
BufferString rootPath () const
 
FilePathset (const char *fullinp)
 
void setDomain (const char *)
 
FilePathsetExtension (const char *, bool replace=true)
 !replace => add More...
 
FilePathsetFileName (const char *)
 pass null to remove level More...
 
FilePathsetPath (const char *)
 including prefix More...
 
BufferString winDrive () const
 

Static Public Member Functions

static const char * dirSep (Style)
 
static BufferString getFullLongPath (const FilePath &)
 
static BufferString getLongPath (const char *shortpath, BufferString *error=nullptr)
 
static BufferString getShortPath (const char *longpath, BufferString *error=nullptr)
 
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 const char * uriProtocolSeparator ()
 

Static Public Attributes

static const char * sPrefSep
 

Protected Member Functions

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

Protected Attributes

BufferString domain_
 
bool isabs_
 
BufferStringSet lvls_
 
BufferString postfix_
 after '?' More...
 
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() [1/2]

const char* FilePath::dirSep ( ) const

◆ dirSep() [2/2]

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

◆ dirUpTo()

BufferString FilePath::dirUpTo ( int  ) const

nr < 0 returns last dir, including prefix

◆ domain()

const char* FilePath::domain ( ) const

◆ exists()

bool FilePath::exists ( ) const

◆ extension()

const char* FilePath::extension ( ) const

may return null

◆ fileFrom()

BufferString FilePath::fileFrom ( int  level) const

◆ 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

◆ getLongPath()

static BufferString FilePath::getLongPath ( const char *  shortpath,
BufferString error = nullptr 
)
static

◆ getShortPath()

static BufferString FilePath::getShortPath ( const char *  longpath,
BufferString error = nullptr 
)
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.

◆ isURI()

bool FilePath::isURI ( ) const

◆ makeAbsolute()

bool FilePath::makeAbsolute ( const FilePath )

◆ 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()

BufferString FilePath::pathOnly ( Style  s = Local) const

◆ postfix()

const char* FilePath::postfix ( ) const

◆ prefix()

const char* FilePath::prefix ( ) const

◆ rootPath()

BufferString FilePath::rootPath ( ) const

◆ set()

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

◆ setDomain()

void FilePath::setDomain ( const char *  )

◆ setExtension()

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

!replace => add

◆ setFileName()

FilePath& FilePath::setFileName ( const char *  )

pass null to remove level

◆ setPath()

FilePath& FilePath::setPath ( const char *  )

including prefix

◆ trueDirIfLink()

void FilePath::trueDirIfLink ( )
protected

◆ uriProtocolSeparator()

static const char* FilePath::uriProtocolSeparator ( )
inlinestatic

◆ winDrive()

BufferString FilePath::winDrive ( ) const

Member Data Documentation

◆ domain_

BufferString FilePath::domain_
protected

◆ isabs_

bool FilePath::isabs_
protected

◆ lvls_

BufferStringSet FilePath::lvls_
protected

◆ postfix_

BufferString FilePath::postfix_
protected

after '?'

◆ 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-2024