Manual for OpenFLUID 2.1.10

FileHelpers.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file FileHelpers.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_TOOLS_FILEHELPERS_HPP__
41 #define __OPENFLUID_TOOLS_FILEHELPERS_HPP__
42 
43 
44 #include <vector>
45 
46 #include <openfluid/dllexport.hpp>
47 
48 
49 namespace openfluid { namespace tools {
50 
51 
52 /**
53  Gets the list of files with specified extension contained in the specified directory
54  @param[in] Path the directory to explore
55  @param[in] Ext the file extension
56  @param[in] WithPath return full path with file name if true, file name only otherwise
57  @param[in] ExtIncludeDot if true, the given extension through Ext parameter is suffixed by a dot
58 */
59 std::vector<std::string> OPENFLUID_API findFilesByExtension(const std::string& Path,
60  const std::string& Ext,
61  bool WithPath = false,
62  bool ExtIncludeDot = false);
63 
64 /**
65  Get list of files with specified extension contained in the specified dir
66  @param[in] Path the directory to explore
67  @param[in] Ext the file extension
68  @param[in] Suffix the file suffix
69  @param[in] WithPath return full path with file name if true, file name only otherwise
70  @param[in] ExtIncludeDot if true, the given extension through Ext parameter is suffixed by a dot
71 */
72 std::vector<std::string> OPENFLUID_API findFilesBySuffixAndExtension(const std::string& Path,
73  const std::string& Suffix,
74  const std::string& Ext,
75  bool WithPath = false,
76  bool ExtIncludeDot = false);
77 
78 /**
79  Gets the list of directories found in the specified directory
80  @param[in] Path the directory to explore
81  @param[in] WithPath return full path if true, directory name only otherwise
82 */
83 std::vector<std::string> OPENFLUID_API findDirectories(const std::string& Path,
84  bool WithPath = false);
85 
86 /**
87  Recursively removes all files and directories contained in the given directory.
88  It deletes the directory and recreates it.
89  @param[in] Path the directory to empty
90  @return true if successful
91 */
92 bool OPENFLUID_API emptyDirectoryRecursively(const std::string& Path);
93 
94 /**
95  Copies a source directory to destination path, not including the root of the source directory.
96  If the destination path does not exists, it is created.
97  @param[in] SrcPath the source directory to copy
98  @param[in] DestPath the destination directory
99  @param[in] DontCopyDotDirs flag for copying dot ('.*') directories. Default is false.
100 */
101 void OPENFLUID_API copyDirectoryContentsRecursively(const std::string& SrcPath,
102  const std::string& DestPath,
103  const bool DontCopyDotDirs = false);
104 
105 
106 } } // namespaces
107 
108 
109 #endif /* __OPENFLUID_TOOLS_FILEHELPERS_HPP__ */
Definition: ApplicationException.hpp:47
std::vector< std::string > OPENFLUID_API findFilesBySuffixAndExtension(const std::string &Path, const std::string &Suffix, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false)
bool OPENFLUID_API emptyDirectoryRecursively(const std::string &Path)
std::vector< std::string > OPENFLUID_API findFilesByExtension(const std::string &Path, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false)
#define OPENFLUID_API
Definition: dllexport.hpp:86
std::vector< std::string > OPENFLUID_API findDirectories(const std::string &Path, bool WithPath=false)
void OPENFLUID_API copyDirectoryContentsRecursively(const std::string &SrcPath, const std::string &DestPath, const bool DontCopyDotDirs=false)