BARE2D
Filesystem.cpp
Go to the documentation of this file.
1 #include "Filesystem.hpp"
2 
3 namespace fs = boost::filesystem;
4 
5 namespace BARE2D {
6 
7 std::vector<std::string> Filesystem::getDirectoriesIn(std::string path)
8 {
9  std::vector<std::string> ret;
10 
11  fs::path filepath(path);
12 
13  if(fs::exists(filepath) && fs::is_directory(filepath))
14  {
15  for(fs::directory_iterator it(filepath); it != fs::directory_iterator(); it++)
16  {
17  auto filename = static_cast<std::string>(it->path().filename().string());
18 
19  if(fs::is_directory(filename))
20  {
21  ret.push_back(filename);
22  }
23  }
24  }
25 
26  return ret;
27 }
28 
29 std::vector<std::string> Filesystem::getFilesIn(std::string path)
30 {
31  std::vector<std::string> ret;
32 
33  fs::path filepath(path);
34 
35  if(fs::exists(filepath) && fs::is_directory(filepath))
36  {
37  for(fs::directory_iterator it(filepath); it != fs::directory_iterator(); it++)
38  {
39  auto filename = static_cast<std::string>(it->path().filename().string());
40 
41  if(fs::is_regular_file(it->status()))
42  {
43  ret.push_back(filename);
44  }
45  }
46  }
47 
48  return ret;
49 }
50 
52 {
53  return fs::current_path().string();
54 }
55 
56 } // namespace BARE2D
BARE2D::Filesystem::getFilesIn
static std::vector< std::string > getFilesIn(std::string path)
Gets all the names of files at the given path.
Definition: Filesystem.cpp:29
BARE2D::Filesystem::getWorkingDirectory
static std::string getWorkingDirectory()
Definition: Filesystem.cpp:51
BARE2D
Definition: App.cpp:13
Filesystem.hpp
BARE2D::Filesystem::getDirectoriesIn
static std::vector< std::string > getDirectoriesIn(std::string path)
Gets all the names of directories at the given path.
Definition: Filesystem.cpp:7