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
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/Vector.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37class String;
38
39
40// <summary>
41// DO for accessing os-specific functions
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
47// </reviewed>
48
49// <prerequisite>
50// <li> <linkto module=OS>OS</linkto>
51// </prerequisite>
52
53// <etymology>
54// </etymology>
55
56// <synopsis>
57// This class serves as the connection between the OS module and a tasking
58// interface in Glish or Python.
59// It is meant for access to OS-specific functions, in
60// particular file handling.
61// </synopsis>
62
63// <example>
64// </example>
65
66// <motivation>
67// </motivation>
68
69// <thrown>
70// <li> AipsError if AIPSPATH or HOME is not defined
71// </thrown>
72
73// <todo asof="1997/09/16">
74// <li> Check for feasable extensions
75// </todo>
76
77
78class DOos
79{
80public:
81 // Are the given path names valid?
82 // I.e. does a file with the given name exist or can it be created?
84
85 // Do the given files exist?
86 // If follow is False, symbolic links are not followed.
87 static Vector<Bool> fileExists (const Vector<String>& fileName,
88 Bool follow = True);
89
90 // Give the type of the given files.
91 static Vector<String> fileType (const Vector<String>& fileName,
92 Bool follow = True);
93
94 // Give all file names in the directory matching the given pattern
95 // and file types.
96 // <br>The pattern can be a string like the filename pattern given in
97 // a shell (e.g. '*.cc'). If the string is empty, all files are taken
98 // into account.
99 // <br>Filetypes is a string determining which file types will be selected.
100 // Each character in the string determines a file type. They are:
101 // <dl>
102 // <dt>r<dd>regular file
103 // <dt>d<dd>directory
104 // <dt>s<dd>symbolic link
105 // <dt>R<dd>readable file
106 // <dt>W<dd>writable file
107 // <dt>X<dd>executable file
108 // </dl>
109 // The all flag determines if file names starting with a . will also
110 // be selected.
111 static Vector<String> fileNames (const String& directoryName,
112 const String& fileNamePattern,
113 const String& fileTypes,
114 Bool all = False,
115 Bool follow = True);
116
117 // Make directories. It throws an exception if a file with that
118 // name already exists.
119 static void makeDirectory (const Vector<String>& directoryNames,
120 Bool makeParent = False);
121
122 // Return the full absolute names for the given names.
123 static Vector<String> fullName (const Vector<String>& fileName);
124
125 // Return the full directory names of the given files.
126 static Vector<String> dirName (const Vector<String>& fileName);
127
128 // Return the base names of the given files.
129 static Vector<String> baseName (const Vector<String>& fileName);
130
131 // Get the time of the given files.
132 // <src>whichTime</src> determines which time to return:
133 // <br>1 = time of last access
134 // <br>2 = time of last modification
135 // <br>3 = time of last status change
136 static Vector<Double> fileTime (const Vector<String>& fileName,
137 Int whichTime = 1, Bool follow = True);
138
139 // Return the total size (in bytes) for each file or directory given.
140 // For a directory the size of all files (recursively) in it is given.
141 // If follow is False, symbolic links are not followed.
142 // <group>
143 static Vector<Double> totalSize (const Vector<String>& fileName,
144 Bool follow = True);
145 static Double totalSize (const String& fileName, Bool follow = True);
146 // </group>
147
148 // Return the total size on the devices the given directories are on.
149 // If follow is False, symbolic links are not followed.
150 static Vector<Double> freeSpace (const Vector<String>& fileName,
151 Bool follow = True);
152
153 // Copy the file (or directory recursively).
154 // If from is a symbolic link and follow is False, only the
155 // symbolic link is copied.
156 static void copy (const String& to, const String& from,
157 Bool overwrite = True, Bool follow = True);
158
159 // Move the file or directory.
160 // If from is a symbolic link and follow is False, only the
161 // symbolic link is moved.
162 static void move (const String& to, const String& from,
163 Bool overwrite = True, Bool follow = True);
164
165 // Remove the files (or directories recursively).
166 // If fileName is a symbolic link and follow is False, only the
167 // symbolic link is removed.
168 // <group>
169 static void remove (const String& fileName, Bool recursive,
170 Bool mustExist = True, Bool follow = True);
171 static void remove (const Vector<String>& fileNames, Bool recursive,
172 Bool mustExist = True, Bool follow = True);
173 // </group>
174
175 // Tell if a table is used or locked by another process.
176 // It returns a vector containing 3 integers.
177 // The first one tells if the table is in use or locked.
178 // See <linkto class=LockFile>LockFile</linkto>\::showLock for details.
179 // The second one gives the pid of the process using/locking the table.
180 // The third one tells if the table is permanently locked (0 = not).
181 static Vector<Int> lockInfo (const String& tableName);
182};
183
184
185
186} //# NAMESPACE CASACORE - END
187
188#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? I.e.
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? If follow is False, symbolic links are not followed.
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:223
this file contains all the compiler specific defines
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)