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  @file FileHelpers.hpp
34 
35  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
36 */
37 
38 
39 
40 #ifndef __OPENFLUID_TOOLS_FILEHELPERS_HPP__
41 #define __OPENFLUID_TOOLS_FILEHELPERS_HPP__
42 
43 #include <openfluid/dllexport.hpp>
44 
45 #include <vector>
46 
47 
48 namespace openfluid { namespace tools {
49 
50 
51 /**
52  Gets the list of files with specified extension contained in the specified directory
53  @param[in] Path the directory to explore
54  @param[in] Ext the file extension
55  @param[in] WithPath return full path with file name if true, file name only otherwise
56  @param[in] ExtIncludeDot if true, the given extension through Ext parameter is suffixed by a dot
57 */
58 std::vector<std::string> OPENFLUID_API findFilesByExtension(const std::string& Path,
59  const std::string& Ext,
60  bool WithPath = false,
61  bool ExtIncludeDot = false);
62 
63 /**
64  Get list of files with specified extension contained in the specified dir
65  @param[in] Path the directory to explore
66  @param[in] Ext the file extension
67  @param[in] Suffix the file suffix
68  @param[in] WithPath return full path with file name if true, file name only otherwise
69  @param[in] ExtIncludeDot if true, the given extension through Ext parameter is suffixed by a dot
70 */
71 std::vector<std::string> OPENFLUID_API findFilesBySuffixAndExtension(const std::string& Path,
72  const std::string& Suffix,
73  const std::string& Ext,
74  bool WithPath = false,
75  bool ExtIncludeDot = false);
76 
77 /**
78  Gets the list of directories found in the specified directory
79  @param[in] Path the directory to explore
80  @param[in] WithPath return full path if true, directory name only otherwise
81 */
82 std::vector<std::string> OPENFLUID_API findDirectories(const std::string& Path,
83  bool WithPath = false);
84 
85 /**
86  Recursively removes all files and directories contained in the given directory.
87  It deletes the directory and recreates it.
88  @param[in] Path the directory to empty
89  @return true if successful
90 */
91 bool OPENFLUID_API emptyDirectoryRecursively(const std::string& Path);
92 
93 /**
94  Copies a source directory to destination path, not including the root of the source directory.
95  If the destination path does not exists, it is created.
96  @param[in] SrcPath the source directory to copy
97  @param[in] DestPath the destination directory
98  @param[in] DontCopyDotDirs flag for copying dot ('.*') directories. Default is false.
99 */
100 void OPENFLUID_API copyDirectoryContentsRecursively(const std::string& SrcPath,
101  const std::string& DestPath,
102  const bool DontCopyDotDirs = false);
103 
104 
105 } } // namespaces
106 
107 
108 #endif /* __OPENFLUID_TOOLS_FILEHELPERS_HPP__ */
void OPENFLUID_API copyDirectoryContentsRecursively(const std::string &SrcPath, const std::string &DestPath, const bool DontCopyDotDirs=false)
bool OPENFLUID_API emptyDirectoryRecursively(const std::string &Path)
Definition: ApplicationException.hpp:47
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:87
std::vector< std::string > OPENFLUID_API findDirectories(const std::string &Path, bool WithPath=false)
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)