OpendTect  6.3
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
File::Path Class Reference

File pathname tools. More...

Public Types

enum  Style { Local, Unix, Windows }
 

Public Member Functions

 Path (const char *fullinp=0)
 
 Path (const char *p1, const char *p2, const char *p3=0, const char *p4=0, const char *p5=0)
 
 Path (const Path &fp)
 
 Path (const Path &, const char *p2, const char *p3=0, const char *p4=0, const char *p5=0)
 
Pathoperator= (const Path &)
 
Pathoperator= (const char *fullinp)
 
bool operator== (const Path &) const
 
bool operator== (const char *fnm) const
 
bool operator!= (const Path &) const
 
bool operator!= (const char *fnm) const
 
bool isEmpty () const
 
Pathset (const char *fullinp)
 
Pathadd (const char *)
 at end More...
 
Pathinsert (const char *)
 after prefix at start More...
 
PathsetFileName (const char *)
 pass null to remove level More...
 
PathsetPath (const char *)
 including prefix More...
 
PathsetExtension (const char *, bool replace=true)
 !replace => bluntly add More...
 
bool isAbsolute () const
 
bool isSubDirOf (const Path &, Path *reldir=0) const
 
bool makeRelativeTo (const Path &)
 
bool makeCanonical ()
 
BufferString fullPath (Style s=Local, bool cleanup=true) const
 
const char * prefix () const
 
const char * postfix () const
 
int nrLevels () const
 
const char * extension () const
 may return null More...
 
const OD::StringfileName () const
 
BufferString baseName () const
 name of file w/o path or 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...
 
const char * dirSep () const
 

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

Protected Attributes

bool isuri_
 
bool isabs_
 
BufferString prefix_
 
BufferString postfix_
 after '?' More...
 
BufferStringSet lvls_
 

Detailed Description

File pathname tools.

This class splits a file or directory name 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

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

Member Function Documentation

Path& File::Path::add ( const char *  )

at end

void File::Path::addPart ( const char *  )
protected
BufferString File::Path::baseName ( ) const

name of file w/o path or ext

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

nr < 0 returns last dir name

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

nr < 0 returns last dir, including prefix

const char* File::Path::extension ( ) const

may return null

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

after prefix at start

bool File::Path::isAbsolute ( ) const
bool File::Path::isEmpty ( ) const
inline
bool File::Path::isSubDirOf ( const Path ,
Path reldir = 0 
) const

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

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

!replace => bluntly add

Path& File::Path::setFileName ( const char *  )

pass null to remove level

Path& File::Path::setPath ( const char *  )

including prefix

BufferString File::Path::winDrive ( ) const

Member Data Documentation

bool File::Path::isabs_
protected
bool File::Path::isuri_
protected
BufferStringSet File::Path::lvls_
protected
BufferString File::Path::postfix_
protected

after '?'

BufferString File::Path::prefix_
protected
const char* File::Path::sPrefSep
static

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