casacore
Loading...
Searching...
No Matches
DOos.h
Go to the documentation of this file.
1// # DOos.h: Functions used to implement the DO functionality
2// # Copyright (C) 1999,2000,2001
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_DOOS_H
27#define CASA_DOOS_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Vector.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36class String;
37
38// <summary>
39// DO for accessing os-specific functions
40// </summary>
41
42// <use visibility=export>
43
44// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto module=OS>OS</linkto>
49// </prerequisite>
50
51// <etymology>
52// </etymology>
53
54// <synopsis>
55// This class serves as the connection between the OS module and a tasking
56// interface in Glish or Python.
57// It is meant for access to OS-specific functions, in
58// particular file handling.
59// </synopsis>
60
61// <example>
62// </example>
63
64// <motivation>
65// </motivation>
66
67// <thrown>
68// <li> AipsError if AIPSPATH or HOME is not defined
69// </thrown>
70
71// <todo asof="1997/09/16">
72// <li> Check for feasable extensions
73// </todo>
74
75class DOos {
76 public:
77 // Are the given path names valid?
78 // I.e. does a file with the given name exist or can it be created?
80
81 // Do the given files exist?
82 // If follow is False, symbolic links are not followed.
83 static Vector<Bool> fileExists(const Vector<String>& fileName, Bool follow = True);
84
85 // Give the type of the given files.
86 static Vector<String> fileType(const Vector<String>& fileName, Bool follow = True);
87
88 // Give all file names in the directory matching the given pattern
89 // and file types.
90 // <br>The pattern can be a string like the filename pattern given in
91 // a shell (e.g. '*.cc'). If the string is empty, all files are taken
92 // into account.
93 // <br>Filetypes is a string determining which file types will be selected.
94 // Each character in the string determines a file type. They are:
95 // <dl>
96 // <dt>r<dd>regular file
97 // <dt>d<dd>directory
98 // <dt>s<dd>symbolic link
99 // <dt>R<dd>readable file
100 // <dt>W<dd>writable file
101 // <dt>X<dd>executable file
102 // </dl>
103 // The all flag determines if file names starting with a . will also
104 // be selected.
105 static Vector<String> fileNames(const String& directoryName, const String& fileNamePattern,
106 const String& fileTypes, Bool all = False, Bool follow = True);
107
108 // Make directories. It throws an exception if a file with that
109 // name already exists.
110 static void makeDirectory(const Vector<String>& directoryNames, Bool makeParent = False);
111
112 // Return the full absolute names for the given names.
113 static Vector<String> fullName(const Vector<String>& fileName);
114
115 // Return the full directory names of the given files.
116 static Vector<String> dirName(const Vector<String>& fileName);
117
118 // Return the base names of the given files.
119 static Vector<String> baseName(const Vector<String>& fileName);
120
121 // Get the time of the given files.
122 // <src>whichTime</src> determines which time to return:
123 // <br>1 = time of last access
124 // <br>2 = time of last modification
125 // <br>3 = time of last status change
126 static Vector<Double> fileTime(const Vector<String>& fileName, Int whichTime = 1,
127 Bool follow = True);
128
129 // Return the total size (in bytes) for each file or directory given.
130 // For a directory the size of all files (recursively) in it is given.
131 // If follow is False, symbolic links are not followed.
132 // <group>
133 static Vector<Double> totalSize(const Vector<String>& fileName, Bool follow = True);
134 static Double totalSize(const String& fileName, Bool follow = True);
135 // </group>
136
137 // Return the total size on the devices the given directories are on.
138 // If follow is False, symbolic links are not followed.
139 static Vector<Double> freeSpace(const Vector<String>& fileName, Bool follow = True);
140
141 // Copy the file (or directory recursively).
142 // If from is a symbolic link and follow is False, only the
143 // symbolic link is copied.
144 static void copy(const String& to, const String& from, Bool overwrite = True, Bool follow = True);
145
146 // Move the file or directory.
147 // If from is a symbolic link and follow is False, only the
148 // symbolic link is moved.
149 static void move(const String& to, const String& from, Bool overwrite = True, Bool follow = True);
150
151 // Remove the files (or directories recursively).
152 // If fileName is a symbolic link and follow is False, only the
153 // symbolic link is removed.
154 // <group>
155 static void remove(const String& fileName, Bool recursive, Bool mustExist = True,
156 Bool follow = True);
157 static void remove(const Vector<String>& fileNames, Bool recursive, Bool mustExist = True,
158 Bool follow = True);
159 // </group>
160
161 // Tell if a table is used or locked by another process.
162 // It returns a vector containing 3 integers.
163 // The first one tells if the table is in use or locked.
164 // See <linkto class=LockFile>LockFile</linkto>\::showLock for details.
165 // The second one gives the pid of the process using/locking the table.
166 // The third one tells if the table is permanently locked (0 = not).
167 static Vector<Int> lockInfo(const String& tableName);
168};
169
170} // namespace casacore
171
172#endif
static void makeDirectory(const Vector< String > &directoryNames, Bool makeParent=False)
Make directories.
static void copy(const String &to, const String &from, Bool overwrite=True, Bool follow=True)
Copy the file (or directory recursively).
static Vector< String > fileType(const Vector< String > &fileName, Bool follow=True)
Give the type of the given files.
static Vector< Double > totalSize(const Vector< String > &fileName, Bool follow=True)
Return the total size (in bytes) for each file or directory given.
static Vector< Int > lockInfo(const String &tableName)
Tell if a table is used or locked by another process.
static void remove(const Vector< String > &fileNames, Bool recursive, Bool mustExist=True, Bool follow=True)
static Vector< Bool > isValidPathName(const Vector< String > &pathName)
Are the given path names valid?
static Vector< String > fullName(const Vector< String > &fileName)
Return the full absolute names for the given names.
static void move(const String &to, const String &from, Bool overwrite=True, Bool follow=True)
Move the file or directory.
static Vector< Bool > fileExists(const Vector< String > &fileName, Bool follow=True)
Do the given files exist?
static Vector< String > baseName(const Vector< String > &fileName)
Return the base names of the given files.
static Vector< String > dirName(const Vector< String > &fileName)
Return the full directory names of the given files.
static Vector< String > fileNames(const String &directoryName, const String &fileNamePattern, const String &fileTypes, Bool all=False, Bool follow=True)
Give all file names in the directory matching the given pattern and file types.
static Vector< Double > fileTime(const Vector< String > &fileName, Int whichTime=1, Bool follow=True)
Get the time of the given files.
static Double totalSize(const String &fileName, Bool follow=True)
static void remove(const String &fileName, Bool recursive, Bool mustExist=True, Bool follow=True)
Remove the files (or directories recursively).
static Vector< Double > freeSpace(const Vector< String > &fileName, Bool follow=True)
Return the total size on the devices the given directories are on.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53
LatticeExprNode all(const LatticeExprNode &expr)