filesystem.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // filesystem: A family of file-level utilities
4 //
5 // ======================================================================
6 
7 #include "cetlib/filesystem.h"
8 
9 #include <sys/stat.h>
10 
11 // ----------------------------------------------------------------------
12 
13 bool
14 cet::file_exists(std::string const& qualified_filename)
15 {
16  struct stat file_info;
17  return 0 == stat(qualified_filename.c_str(), &file_info);
18 }
19 
20 // ----------------------------------------------------------------------
21 
22 bool
23 cet::is_absolute_filepath(std::string const& qualified_filename)
24 {
25  return qualified_filename[0] == '/';
26 }
27 
28 bool
29 cet::is_relative_filepath(std::string const& qualified_filename)
30 {
31  return !is_absolute_filepath(qualified_filename);
32 }
33 
34 // ======================================================================
std::string string
Definition: nybbler.cc:12
bool is_relative_filepath(std::string const &qualified_filename)
Definition: filesystem.cc:29
bool is_absolute_filepath(std::string const &qualified_filename)
Definition: filesystem.cc:23
bool file_exists(std::string const &qualified_filename)
Definition: filesystem.cc:14