OpendTect-6_4  6.4
file.h
Go to the documentation of this file.
1 #ifndef file_h
2 #define file_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: January 2010
10  Contents: File utitlities
11  RCS: $Id$
12 ________________________________________________________________________
13 
14 -*/
15 
16 #include "basicmod.h"
17 #include "enums.h"
18 #include "gendefs.h"
19 #include "timefun.h"
20 
21 class BufferStringSet;
22 class Executor;
23 
24 
27 namespace File
28 {
29 
30 mGlobal(Basic) bool exists(const char*);
31 mGlobal(Basic) bool isEmpty(const char*);
32 mGlobal(Basic) bool isDirEmpty(const char*);
33 mGlobal(Basic) bool isFile(const char*);
34 mGlobal(Basic) bool isDirectory(const char*);
35 
36 mGlobal(Basic) const char* getCanonicalPath(const char*);
37 mGlobal(Basic) const char* getAbsolutePath(const char* dir,
38  const char* relfnm);
39 mGlobal(Basic) const char* getRelativePath(const char* reltodir,
40  const char* fnm);
41 mGlobal(Basic) void makeRecursiveFileList(const char* dir,
42  BufferStringSet& filelist,
43  bool followlinks=false);
44 
45 mGlobal(Basic) bool createLink(const char* from,const char* to);
46 mGlobal(Basic) bool isLink(const char*);
47 mGlobal(Basic) const char* linkTarget(const char* linkname);
48 mGlobal(Basic) const char* linkValue(const char* linkname);
49 
50 mGlobal(Basic) void hide(const char*,bool yn);
51 mGlobal(Basic) bool isHidden(const char*);
52 mGlobal(Basic) bool isWritable(const char*);
53 mGlobal(Basic) bool makeWritable(const char*,bool yesno,
54  bool recursive);
55 mGlobal(Basic) bool isExecutable(const char*);
56 mGlobal(Basic) bool makeExecutable(const char*,bool yesno);
57 mGlobal(Basic) bool setPermissions(const char*,const char* perms,
58  bool recursive);
59 mGlobal(Basic) bool isFileInUse(const char* fnm);
60 
61 mGlobal(Basic) bool createDir(const char*);
62 mGlobal(Basic) bool rename(const char* oldname,const char* newname);
63 mGlobal(Basic) bool copy(const char* from,const char* to,
64  BufferString* errmsg=0);
65 mGlobal(Basic) Executor* getRecursiveCopier(const char* from,
66  const char* to);
67 mGlobal(Basic) Executor* getRecursiveDeleter(const char* dirnm,
68  const BufferStringSet* externallist=0,
69  bool filesonly=false);
70 mGlobal(Basic) bool resize(const char*,od_int64);
71 mGlobal(Basic) bool remove(const char*);
72 mGlobal(Basic) bool saveCopy(const char* from,const char* to);
73 mGlobal(Basic) bool copyDir(const char* from,const char* to,
74  BufferString* errmsg=0);
75 mGlobal(Basic) bool removeDir(const char*);
76 mGlobal(Basic) bool changeDir(const char* path);
77 
78 mGlobal(Basic) bool getContent(const char*,BufferString&);
79 mGlobal(Basic) od_int64 getFileSize(const char* fnm,
80  bool followlink=true);
81 mGlobal(Basic) od_int64 getKbSize(const char*);
83 mGlobal(Basic) BufferString getFileSizeString(const char* fnm);
84 
85 mGlobal(Basic) const char* timeCreated(const char* filenm,
86  const char* fmt=Time::defDateTimeFmt());
87 mGlobal(Basic) const char* timeLastModified(const char* filenm,
88  const char* fmt=Time::defDateTimeFmt());
89 mGlobal(Basic) od_int64 getTimeInSeconds(const char*,bool modif=true);
90 mGlobal(Basic) od_int64 getTimeInMilliSeconds( const char* fnm,
91  bool lastmodif=true );//since day start
92 
93 mGlobal(Basic) const char* getCurrentPath();
94 mGlobal(Basic) const char* getHomePath();
95 mGlobal(Basic) const char* getTempPath();
96 mGlobal(Basic) const char* getRootPath(const char* path);
97 
98 
99 enum ViewStyle { Text, Table, Log, Bin };
101 
103 {
104 public:
105 
107  : style_(vs)
108  , editable_(false)
109  , maxnrlines_(vs==Table ? 500 : 10000) {}
110 
111  static const char* sKeyFile() { return "file"; }
112  static const char* sKeyMaxLines() { return "maxlines"; }
113  static const char* sKeyStyle() { return "style"; }
114  static const char* sKeyEdit() { return "edit"; }
115 
118  bool editable_;
119 
120 };
121 
122 mGlobal(Basic) bool launchViewer(const char*,
123  const ViewPars& vp=ViewPars());
124 
125 
126 } // namespace File
127 
128 
129 #endif
bool rename(const char *oldname, const char *newname)
bool isDirEmpty(const char *)
Interface for several file and directory related services.
Definition: file.h:27
bool editable_
only if possible
Definition: file.h:118
bool isLink(const char *)
static const char * sKeyStyle()
Definition: file.h:113
const char * defDateTimeFmt()
bool isFile(const char *)
bool launchViewer(const char *, const ViewPars &vp=ViewPars())
bool makeWritable(const char *, bool yesno, bool recursive)
Executor * getRecursiveCopier(const char *from, const char *to)
T to(const F &fr)
Definition: convert.h:33
Definition: file.h:99
const char * timeLastModified(const char *filenm, const char *fmt=Time::defDateTimeFmt())
Definition: file.h:99
bool makeExecutable(const char *, bool yesno)
#define mGlobal(module)
Definition: commondefs.h:163
#define mDeclareNameSpaceEnumUtils(mod, enm)
Definition: enums.h:274
bool copy(const char *from, const char *to, BufferString *errmsg=0)
#define od_int64
Definition: plftypes.h:36
ViewStyle style_
Definition: file.h:116
bool isHidden(const char *)
bool isExecutable(const char *)
bool createDir(const char *)
Definition: file.h:99
void hide(const char *, bool yn)
only Windows
Executor * getRecursiveDeleter(const char *dirnm, const BufferStringSet *externallist=0, bool filesonly=false)
Set of BufferString objects.
Definition: bufstringset.h:28
bool changeDir(const char *path)
bool isFileInUse(const char *fnm)
BufferString getFileSizeString(int64_t fileszinkb)
const char * linkValue(const char *linkname)
ViewStyle
Definition: file.h:99
const char * getTempPath()
bool getContent(const char *, BufferString &)
Definition: geom2dascio.h:21
static const char * sKeyFile()
Definition: file.h:111
bool isDirectory(const char *)
bool saveCopy(const char *from, const char *to)
static const char * sKeyMaxLines()
Definition: file.h:112
int64_t getFileSize(const char *fnm, bool followlink=true)
bytes
const char * timeCreated(const char *filenm, const char *fmt=Time::defDateTimeFmt())
bool removeDir(const char *)
const char * getCurrentPath()
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
bool isEmpty(const char *)
int64_t getKbSize(const char *)
bool resize(const char *, int64_t)
Definition: file.h:99
const char * linkTarget(const char *linkname)
const char * getHomePath()
bool isWritable(const char *)
const char * getRootPath(const char *path)
static const char * sKeyEdit()
Definition: file.h:114
Definition: file.h:102
bool copyDir(const char *from, const char *to, BufferString *errmsg=0)
ViewPars(ViewStyle vs=Text)
Definition: file.h:106
int maxnrlines_
max nr bytes when Bin
Definition: file.h:117
const char * getCanonicalPath(const char *)
const char * getRelativePath(const char *reltodir, const char *fnm)
#define mClass(module)
Definition: commondefs.h:164
bool createLink(const char *from, const char *to)
bool exists(const char *)
bool setPermissions(const char *, const char *perms, bool recursive)
int64_t getTimeInSeconds(const char *, bool modif=true)
const char * getAbsolutePath(const char *dir, const char *relfnm)
Specification to enable chunkwise execution of a process.
Definition: executor.h:39
void makeRecursiveFileList(const char *dir, BufferStringSet &filelist, bool followlinks=false)
int64_t getTimeInMilliSeconds(const char *fnm, bool lastmodif=true)

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