fileName: Added cpFiles function

//- Copy all the files from the source to the target directory
void cpFiles(const fileName& srcDir, const fileName& targetDir);
This commit is contained in:
Henry Weller
2018-05-28 22:14:22 +01:00
parent 03727e711d
commit 64da5dab55
3 changed files with 31 additions and 16 deletions

View File

@ -50,13 +50,6 @@ class regIOobject;
class objectRegistry;
class Time;
// Description of processor directory naming:
// - processor directory naming
// - whether directory contains a range (so differs on different processors)
// - index in range
//typedef Tuple2<fileName, Tuple2<bool, label>> dirIndex;
//typedef List<dirIndex> dirIndexList;
/*---------------------------------------------------------------------------*\
Class fileOperation Declaration
\*---------------------------------------------------------------------------*/
@ -83,9 +76,16 @@ public:
PROCBASEINSTANCE, // as PROCBASEOBJECT but with instance
PROCINSTANCE // as PROCOBJECT but with instance
};
static const NamedEnum<pathType, 12> pathTypeNames_;
//- Description of processor directory naming:
// - processor directory naming
// - whether directory contains a range
// (so differs on different processors)
// - index in range
typedef Tuple2<fileName, Tuple2<pathType, label>> dirIndex;
typedef List<dirIndex> dirIndexList;
@ -298,13 +298,13 @@ public:
//- Remove a directory and its contents
virtual bool rmDir(const fileName&) const = 0;
// //- Open a shared library. Return handle to library. Print error
// // message if library cannot be loaded (check = true)
// virtual void* dlOpen
// (
// const fileName& lib,
// const bool check = true
// ) const = 0;
// //- Open a shared library. Return handle to library. Print error
// // message if library cannot be loaded (check = true)
// virtual void* dlOpen
// (
// const fileName& lib,
// const bool check = true
// ) const = 0;
// (reg)IOobject functinality

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -426,4 +426,17 @@ Foam::fileName Foam::search(const word& file, const fileName& directory)
}
void Foam::cpFiles(const fileName& srcDir, const fileName& targetDir)
{
mkDir(targetDir);
const fileNameList srcFiles(readDir(srcDir, fileName::FILE, true));
forAll(srcFiles, filei)
{
cp(srcDir/srcFiles[filei], targetDir);
}
}
// ************************************************************************* //

View File

@ -242,12 +242,14 @@ public:
//- Assemble words and fileNames as pathnames by adding a '/' separator
fileName operator/(const string&, const string&);
//- Recursively search the given directory for the file
// returning the path relative to the directory or
// fileName::null if not found
fileName search(const word& file, const fileName& directory);
//- Copy all the files from the source to the target directory
void cpFiles(const fileName& srcDir, const fileName& targetDir);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //