dummyFileOperation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "dummyFileOperation.H"
29 #include "dummyISstream.H"
30 #include "Fstream.H"
31 #include "objectRegistry.H"
32 
33 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
34 
35 namespace Foam
36 {
37 namespace fileOperations
38 {
39  defineTypeName(dummyFileOperation);
40 
41 // No runtime selection
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  bool verbose
51 )
52 :
54  (
55  // Use COMM_SELF for now, but COMM_NULL is probably more appropriate
56  Tuple2<label, labelList>
57  (
58  UPstream::commSelf(),
59  fileOperation::getGlobalIORanks()
60  )
61  )
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * Filesystem Operations * * * * * * * * * * * * * //
72 
74 (
75  const fileName& dir,
76  mode_t mode
77 ) const
78 {
80  return false;
81 }
82 
83 
85 (
86  const fileName& fName,
87  mode_t mode
88 ) const
89 {
91  return false;
92 }
93 
94 
96 (
97  const fileName& fName,
98  const bool followLink
99 ) const
100 {
102  return mode_t(0);
103 }
104 
105 
107 (
108  const fileName& fName,
109  const bool followLink
110 ) const
111 {
113  return fileName::Type::UNDEFINED;
114 }
115 
116 
118 (
119  const fileName& fName,
120  const bool checkGzip,
121  const bool followLink
122 ) const
123 {
125  return false;
126 }
127 
128 
130 (
131  const fileName& fName,
132  const bool followLink
133 ) const
134 {
136  return false;
137 }
138 
139 
141 (
142  const fileName& fName,
143  const bool checkGzip,
144  const bool followLink
145 ) const
146 {
148  return false;
149 }
150 
151 
153 (
154  const fileName& fName,
155  const bool followLink
156 ) const
157 {
159  return off_t(0);
160 }
161 
162 
164 (
165  const fileName& fName,
166  const bool followLink
167 ) const
168 {
170  return time_t(0);
171 }
172 
173 
175 (
176  const fileName& fName,
177  const bool followLink
178 ) const
179 {
181  return 0;
182 }
183 
184 
185 
187 (
188  const fileName& dir,
189  const fileName::Type type,
190  const bool filtergz,
191  const bool followLink
192 ) const
193 {
195  return fileNameList();
196 }
197 
198 
200 (
201  const fileName& src,
202  const fileName& dst,
203  const bool followLink
204 ) const
205 {
207  return false;
208 }
209 
210 
212 (
213  const fileName& src,
214  const fileName& dst
215 ) const
216 {
218  return false;
219 }
220 
221 
223 (
224  const fileName& src,
225  const fileName& dst,
226  const bool followLink
227 ) const
228 {
230  return false;
231 }
232 
233 
235 (
236  const fileName& fName,
237  const std::string& ext
238 ) const
239 {
241  return false;
242 }
243 
244 
246 (
247  const fileName& fName
248 ) const
249 {
251  return false;
252 }
253 
254 
256 (
257  const fileName& dir,
258  const bool silent,
259  const bool emptyOnly
260 ) const
261 {
263  return false;
264 }
265 
266 
267 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
268 
270 (
271  const bool checkGlobal,
272  const IOobject& io,
273  const word& typeName,
274  const bool search
275 ) const
276 {
278  return fileName();
279 }
280 
281 
283 (
284  const bool checkGlobal,
285  const IOobject& io,
286  const bool search
287 ) const
288 {
290  return fileName();
291 }
292 
293 
295 (
296  const objectRegistry& db,
297  const fileName& instance,
298  const fileName& local,
299  word& newInstance
300 ) const
301 {
303  return fileNameList();
304 }
305 
306 
308 (
309  IOobject& io,
310  const fileName& fName,
311  const word& typeName
312 ) const
313 {
315  io.resetHeader();
316  return false;
317 }
318 
319 
322 (
323  regIOobject& io,
324  const fileName& fName,
325  const word& typeName,
326  const bool readOnProc
327 ) const
328 {
330  return autoPtr<ISstream>(new dummyISstream());
331 }
332 
333 
335 (
336  regIOobject& io,
337  const bool masterOnly,
339  const word& typeName
340 ) const
341 {
343  return false;
344 }
345 
346 
349 (
350  const fileName& filePath
351 ) const
352 {
354  return autoPtr<ISstream>(new dummyISstream());
355 }
356 
357 
360 (
361  const fileName& pathName,
362  IOstreamOption streamOpt,
363  const bool writeOnProc
364 ) const
365 {
367  return autoPtr<OSstream>(new OFstream(nullptr)); // ie, /dev/null
368 }
369 
370 
373 (
375  const fileName& pathName,
376  IOstreamOption streamOpt,
377  const bool writeOnProc
378 ) const
379 {
381  return autoPtr<OSstream>(new OFstream(nullptr)); // ie, /dev/null
382 }
383 
384 
385 // ************************************************************************* //
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const
Top-level read.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
A class for handling file names.
Definition: fileName.H:72
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
Output to file stream, using an OSstream.
Definition: OFstream.H:49
dummyFileOperation(bool verbose=false)
Default construct.
A simple container for options an IOstream can normally have.
virtual bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist (as DIRECTORY or FILE) in the file system?
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
An encapsulation of filesystem-related operations.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
atomicType
Atomic operations (output)
defineTypeName(dummyFileOperation)
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool local
Definition: EEqn.H:20
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
word format(conversionProperties.get< word >("format"))
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream to read the contents.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal.
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object. checkGlobal.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
List< fileName > fileNameList
List of fileName.
Definition: fileNameList.H:32
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream...
Definition: dummyISstream.H:52
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: POSIX.C:773
Inter-processor communications stream.
Definition: UPstream.H:60
Type
Enumerations to handle directory entry types.
Definition: fileName.H:81
Namespace for OpenFOAM.