AliRoot Core  3dc7879 (3dc7879)
AliFileUtilities.h
Go to the documentation of this file.
1 #ifndef ALIFILEUTILITIES_H
2 #define ALIFILEUTILITIES_H
3 
4 #include <vector>
5 #include <string>
6 #include <cstdlib>
7 #include <cstdio>
8 
9 // put a standard header
10 // History: 25.4.2016 -- initial version (sandro.wenzel@cern.ch)
11 
12 // A namespace encapsulating some standard static "filesystem" like functions
13 // The purpose of this class is to prevent (very expensive) calls
14 // to the OS via system or gSystem->Exec("..")
15 namespace AliFileUtilities {
16 
17 // removes a specifc file specified by filename
18 // returns true of successfull (false if failure)
19 inline bool RemoveLocalFile(const char *filename) {
20  return (std::remove(filename) == 0);
21 }
22 
23 // brief: removes (multiple) files matching a pattern from the filesystem
24 // returns the number of successfull remove operations
25 // example RemoveLocalFile("/tmp/all*.root")
26 // note that a list of filenames will not work
27 size_t RemoveLocalFiles(const char * /*pattern*/);
28 
29 // counts the local files matching a pattern
30 size_t CountLocalFiles(const char * /*pattern*/);
31 
32 // retrieve the local files matching a pattern in a vevtor
33 void GetLocalFiles(const char *, std::vector<std::string> &);
34 
35 // remove a directory given by paramer name and all its including things
36 // mimics behaviour of std::remove_all available in C++17
37 // returns the number of objects deleted
38 size_t Remove_All(const char * /*name*/);
39 
40 }
41 
42 #endif
bool RemoveLocalFile(const char *filename)
size_t CountLocalFiles(const char *pattern)
size_t RemoveLocalFiles(const char *pattern)
size_t Remove_All(const char *name)
void GetLocalFiles(const char *, std::vector< std::string > &)