BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
fileutils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/utils/fileutils.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_MODEL_MVVM_UTILS_FILEUTILS_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_UTILS_FILEUTILS_H
17 
18 #include "mvvm/model_export.h"
19 #include <string>
20 #include <vector>
21 
22 namespace ModelView {
23 
24 namespace Utils {
25 
26 //! Returns true if file exists.
27 MVVM_MODEL_EXPORT bool exists(const std::string& fileName);
28 
29 //! Joins two path elements into the path.
30 MVVM_MODEL_EXPORT std::string join(const std::string& part1, const std::string& part2);
31 
32 //! Create directory, parent directory must exist. If path resolves to existing directory,
33 //! no error reported.
34 MVVM_MODEL_EXPORT bool create_directory(const std::string& path);
35 
36 //! Removes file or empty directory.
37 MVVM_MODEL_EXPORT bool remove(const std::string& path);
38 
39 //! Removes directory with all its content.
40 MVVM_MODEL_EXPORT void remove_all(const std::string& path);
41 
42 //! Provide the filename of a file path.
43 MVVM_MODEL_EXPORT std::string base_name(const std::string& path);
44 
45 //! Returns list of files with given extention found in given directory.
46 MVVM_MODEL_EXPORT std::vector<std::string> FindFiles(const std::string& dirname,
47  const std::string& ext);
48 
49 //! Returns the path to the parent directory.
50 MVVM_MODEL_EXPORT std::string parent_path(const std::string& path);
51 
52 //! Returns true if the file indicated by 'path' refers to empty file or directory.
53 MVVM_MODEL_EXPORT bool is_empty(const std::string& path);
54 
55 } // namespace Utils
56 
57 } // namespace ModelView
58 
59 #endif // BORNAGAIN_MVVM_MODEL_MVVM_UTILS_FILEUTILS_H
MVVM_MODEL_EXPORT std::string base_name(const std::string &path)
Provide the filename of a file path.
Definition: fileutils.cpp:78
MVVM_MODEL_EXPORT std::vector< std::string > FindFiles(const std::string &dirname, const std::string &ext)
Returns list of files with given extention found in given directory.
Definition: fileutils.cpp:87
MVVM_MODEL_EXPORT bool is_empty(const std::string &path)
Returns true if the file indicated by 'path' refers to empty file or directory.
Definition: fileutils.cpp:121
MVVM_MODEL_EXPORT bool remove(const std::string &path)
Removes file or empty directory.
Definition: fileutils.cpp:57
MVVM_MODEL_EXPORT void remove_all(const std::string &path)
Removes directory with all its content.
Definition: fileutils.cpp:67
MVVM_MODEL_EXPORT std::string parent_path(const std::string &path)
Returns the path to the parent directory.
Definition: fileutils.cpp:111
MVVM_MODEL_EXPORT std::string join(const std::string &part1, const std::string &part2)
Joins two path elements into the path.
Definition: fileutils.cpp:37
MVVM_MODEL_EXPORT bool exists(const std::string &fileName)
Returns true if file exists.
Definition: fileutils.cpp:27
MVVM_MODEL_EXPORT bool create_directory(const std::string &path)
Create directory, parent directory must exist.
Definition: fileutils.cpp:47
materialitems.h Collection of materials to populate MaterialModel.