PICCANTE  0.4
The hottest HDR imaging library!
file_lister.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_UTIL_FILE_LISTER_HPP
19 #define PIC_UTIL_FILE_LISTER_HPP
20 
21 #include <string>
22 #include <iostream>
23 #include <fstream>
24 
25 #include "../util/string.hpp"
26 
27 namespace pic {
28 
30 {
31 public:
33  {
34  }
35 
36  static std::string getFileNumber(std::string nameFile, std::string nameExt)
37  {
38  int counter = 0;
39 
40  std::string nameTime = nameFile;
41  nameTime += ".";
42  nameTime += nameExt;
43 
44  std::ifstream infile(nameTime.c_str());
45 
46  while(infile) {
47  infile.close();
48  nameTime = nameFile;
49  nameTime += "_";
50  nameTime += fromNumberToString(counter);
51  nameTime += ".";
52  nameTime += nameExt;
53 
54  infile.open(nameTime.c_str());
55  counter++;
56  }
57 
58  return nameFile;
59  }
60 
61  static StringVec *getList(std::string nameDir, std::string nameFilter,
62  StringVec *sVecOut)
63  {
64  if(sVecOut == NULL) {
65  sVecOut = new StringVec;
66  } else {
67  sVecOut->clear();
68  }
69 
70  /*
71 #ifndef PIC_DISABLE_BOOST
72 
73  try {
74  fs::path full_path(fs::initial_path<fs::path>());
75 
76  fs::path path_c = fs::path(nameDir.c_str());
77  full_path = fs::system_complete(path_c);//, fs::native);
78 
79  fs::directory_iterator end_iter;
80 
81  for(fs::directory_iterator dir_itr(full_path);
82  dir_itr != end_iter;
83  ++dir_itr) {
84 
85  if(is_regular(dir_itr->status())) {
86 
87  std::string tmp2 = dir_itr->path().generic_string();
88 
89  if(tmp2.find(nameFilter.c_str()) == std::string::npos) {
90  continue;
91  }
92 
93  //Save the name in the list
94  sVecOut->push_back(tmp2);
95 #ifdef PIC_DEBUG
96  printf("%s\n", tmp2.c_str());
97 #endif
98  }
99  }
100  } catch(std::exception &e) {
101  std::cout << "Problem with directory: " + nameDir + " " + e.what();
102  }
103 
104 #endif
105  */
106  return sVecOut;
107  }
108 };
109 
110 } // end namespace pic
111 
112 #endif /* PIC_UTIL_FILE_LISTER_HPP */
113 
static std::string getFileNumber(std::string nameFile, std::string nameExt)
Definition: file_lister.hpp:36
std::vector< std::string > StringVec
StringVec is an std::vector of std::string.
Definition: string.hpp:49
std::string fromNumberToString(T num)
fromNumberToString converts a number into a string.
Definition: string.hpp:102
FileLister()
Definition: file_lister.hpp:32
static StringVec * getList(std::string nameDir, std::string nameFilter, StringVec *sVecOut)
Definition: file_lister.hpp:61
Definition: bilateral_separation.hpp:25
Definition: file_lister.hpp:29