Project
Loading...
Searching...
No Matches
FileSystemUtils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12// A C++ way to list / iterate files with glob searches
13
14#ifndef O2_FILEITERATOR_H
15#define O2_FILEITERATOR_H
16
17#include <vector>
18#include <string>
19#include <unistd.h>
20
21namespace o2::utils
22{
23
24// Return a vector of file names (not directories), with full path information, in a given directory "dir".
25// If searchpattern is empty, all files will be returned. Otherwise
26// searchpattern will be treated/parsed as a proper regular expression.
27std::vector<std::string> listFiles(std::string const& dir, std::string const& searchpattern);
28
29// same in the current dir
30std::vector<std::string> listFiles(std::string const& searchpattern);
31
32// create path if absent, account for eventual concurrent creation
33void createDirectoriesIfAbsent(std::string const& path);
34
35// A function to expand a string containing shell variables
36// to a string in which these vars have been substituted.
37// Motivation:: filesystem::exists() does not do this by default
38// and I couldn't find information on this. Potentially there is an
39// existing solution.
40std::string expandShellVarsInFileName(std::string const& input);
41
42} // namespace o2::utils
43
44#endif //O2_FILEITERATOR_H
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
std::vector< std::string > listFiles(std::string const &dir, std::string const &searchpattern)
void createDirectoriesIfAbsent(std::string const &path)
std::string expandShellVarsInFileName(std::string const &input)