Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFilesystem.hh
Go to the documentation of this file.
1 #ifndef __JSYSTEM_JFILEJSYSTEM__
2 #define __JSYSTEM_JFILEJSYSTEM__
3 
4 #include <string>
5 #include <vector>
6 #include <fstream>
7 #include <dirent.h>
8 
9 
10 namespace JSYSTEM {}
11 namespace JPP { using namespace JSYSTEM; }
12 
13 namespace JSYSTEM {
14 
15  /**
16  * Auxiliary data structure to list files in directory.
17  */
18  struct ls :
19  public std::vector<std::string>
20  {
21  /**
22  * Constructor.
23  *
24  * \param dir directory
25  */
26  ls(const std::string& dir)
27  {
28  DIR* top = opendir(dir.c_str());
29 
30  if (top != NULL) {
31 
32  for (dirent* i; (i = readdir(top)) != NULL; ) {
33  this->push_back(i->d_name);
34  }
35 
36  closedir(top);
37  }
38  }
39  };
40 
41 
42  /**
43  * Rename file across file systems.
44  *
45  * \param inputFile input file
46  * \param outputFile input file
47  * \return zero upon success; else non-zero
48  */
49  inline int rename(const std::string& inputFile,
50  const std::string& outputFile)
51  {
52  using namespace std;
53 
54  ifstream in (inputFile .c_str(), ios::binary);
55  ofstream out(outputFile.c_str(), ios::binary);
56 
57  out << in.rdbuf();
58 
59  if (out)
60  return remove(inputFile.c_str());
61  else
62  return -1;
63  }
64 }
65 
66 #endif
string outputFile
int rename(const std::string &inputFile, const std::string &outputFile)
Rename file across file systems.
Definition: JFilesystem.hh:49
then fatal Wrong number of arguments fi DIR
ls(const std::string &dir)
Constructor.
Definition: JFilesystem.hh:26
then awk string
Auxiliary data structure to list files in directory.
Definition: JFilesystem.hh:18
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48