Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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"
33/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
34
35namespace Foam
36{
37namespace fileOperations
38{
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 * * * * * * * * * * * * * * * //
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{
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
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(
324 const fileName& fName,
325 const word& typeName,
326 const bool readOnProc
327) const
328{
330 return dummyISstream::New();
331}
332
333
335(
337 const bool masterOnly,
339 const word& typeName
340) const
349(
350 const fileName& filePath
351) const
362 IOstreamOption streamOpt,
363 const bool writeOnProc
364) const
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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary | coherent).
atomicType
Atomic operations (output).
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Definition OFstream.H:75
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
Inter-processor communications stream.
Definition UPstream.H:69
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< ISstream > New()
Return a dummyISstream.
A class for handling file names.
Definition fileName.H:75
Type
Enumerations to handle directory entry types.
Definition fileName.H:82
@ UNDEFINED
Undefined type.
Definition fileName.H:83
An encapsulation of filesystem-related operations.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
fileOperation(const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false)
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
Dummy fileOperation, to be used as a placeholder for interfaces taking a reference to a fileOperation...
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
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.
dummyFileOperation(bool verbose=false)
Default construct.
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 readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
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 time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a 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 chMod(const fileName &, const mode_t) const
Set the file mode.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
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 rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
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?
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
Registry of regIOobjects.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeName(Type)
Define the typeName.
Definition className.H:113
bool local
Definition EEqn.H:20
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
const auto & io
Namespace for implementations of a fileOperation.
Definition regIOobject.H:60
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
List< fileName > fileNameList
List of fileName.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition POSIX.C:775
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition fileName.C:642
word format(conversionProperties.get< word >("format"))