OpendTect  6.3
filepath.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H.Bril
8  Date: Mar 2004
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "basicmod.h"
14 #include "bufstringset.h"
15 
16 
17 namespace File
18 {
19 
36 {
37 public:
38 
39  enum Style { Local, Unix, Windows };
40 
41  Path(const char* fullinp=0);
42  Path(const char* p1,const char* p2,const char* p3=0,
43  const char* p4=0,const char* p5=0);
44  Path( const Path& fp ) { *this = fp; }
45  Path(const Path&,const char* p2,
46  const char* p3=0,const char* p4=0,
47  const char* p5=0);
48 
49  Path& operator =(const Path&);
50  Path& operator =(const char* fullinp);
51  bool operator ==(const Path&) const;
52  bool operator ==(const char* fnm) const;
53  bool operator !=(const Path&) const;
54  bool operator !=(const char* fnm) const;
55  bool isEmpty() const { return lvls_.isEmpty(); }
56 
57  Path& set(const char* fullinp);
58  Path& add(const char*);
59  Path& insert(const char*);
60  Path& setFileName(const char*);
61  Path& setPath(const char*);
62  Path& setExtension(const char*,bool replace=true);
64 
65  bool isAbsolute() const;
66  bool isSubDirOf(const Path&,Path* reldir = 0) const;
69  bool makeRelativeTo(const Path&);
70  bool makeCanonical();
71 
72  BufferString fullPath(Style s=Local,bool cleanup=true) const;
73  const char* prefix() const;
74  const char* postfix() const;
75  int nrLevels() const;
76  const char* extension() const;
77 
78  const OD::String& fileName() const;
79  BufferString baseName() const;
80  BufferString pathOnly() const;
81  BufferString winDrive() const;
82 
83  const OD::String& dir(int nr=-1) const;
85  BufferString dirUpTo(int) const;
87 
88  static BufferString getTempDir();
89  static BufferString getTempName(const char* ext=0);
90  static BufferString mkCleanPath(const char* path,Style fmt);
91  static BufferString getTimeStampFileName(const char*ext=0);
92 
93  const char* dirSep() const;
94  static const char* dirSep(Style);
95  static const char* sPrefSep;
96 
97 protected:
98 
99  bool isuri_;
100  bool isabs_;
104 
105  void addPart(const char*);
106  void compress(int sl=0);
107  void conv2TrueDirIfLink();
108 };
109 
110 } // namespace File;
111 
112 
#define mExpClass(module)
Definition: commondefs.h:157
Interface for several file and directory related services.
Definition: file.h:29
Style
Definition: filepath.h:39
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
bool isabs_
Definition: filepath.h:100
File pathname tools.
Definition: filepath.h:35
Set of BufferString objects.
Definition: bufstringset.h:25
BufferString postfix_
after '?'
Definition: filepath.h:102
File::Path FilePath
Definition: filepath.h:113
bool isuri_
Definition: filepath.h:99
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
#define mDeprecated
Definition: plfdefs.h:213
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
BufferString prefix_
Definition: filepath.h:101
bool isEmpty() const
Definition: filepath.h:55
Path(const Path &fp)
Definition: filepath.h:44
BufferStringSet lvls_
Definition: filepath.h:103
static const char * sPrefSep
Definition: filepath.h:95

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