MDA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
filesystem.h
Go to the documentation of this file.
1 /*
2  * filesystem.h
3  *
4  * Created on: Oct 9, 2011
5  * Author: Carsten Kemena
6  *
7  * This file is part of MDAT.
8  *
9  * MDAT is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser 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  * MDAT 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 Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with MDAT. If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23 
24 #ifndef FILESYSTEM_H_
25 #define FILESYSTEM_H_
26 
27 
28 // C header
29 #include <cstdio>
30 #include <cstring>
31 #include <cerrno>
32 
33 // C++ header
34 #include <string>
35 #include <vector>
36 #include <exception>
37 
38 // MDAT header
39 #include "./MDAT_Exceptions.hpp"
40 
46 namespace MDAT {
47 
54 inline FILE *
55 my_fopen(std::string name_f, std::string mode)
56 {
57  FILE *name_F = fopen(name_f.c_str(), mode.c_str());
58  if (name_F == nullptr)
59  {
60  throw MDAT_IO_Exception(strerror(errno));
61  }
62  else
63  return name_F;
64 }
65 
66 } /* namespace MDAT */
67 
68 //void
69 //get_files_in_dir(const std::string &directory, std::vector<std::string> &files, std::vector<std::string> ending, bool recursive);
70 
71 #endif /* FILESYSTEM_H_ */