CMS 3D CMS Logo

uriUtils.cc
Go to the documentation of this file.
1 #include "Alignment/Geners/interface/IOException.hh"
2 #include <cassert>
3 #include <cstring>
4 
5 #include "Alignment/Geners/interface/uriUtils.hh"
6 
7 namespace gs {
10  if (strlen(filename) == 0)
11  throw gs::IOInvalidArgument("In gs::localFileURI: empty file name");
12  std::string uri("file://");
13  if (filename[0] != '/')
14  uri += "./";
15  uri += filename;
16  return uri;
17  }
18 
19  std::string fileTail(const char *filename) {
21  const char *progname = std::strrchr(filename, '/');
22  if (progname)
23  ++progname;
24  else
25  progname = filename;
26  return std::string(progname);
27  }
28 
31  const char *progname = std::strrchr(filename, '/');
32  if (progname)
33  return std::string(filename, progname - filename);
34  else
35  return std::string(".");
36  }
37 
38  std::string joinDir1WithName2(const char *fname1, const char *fname2) {
39  std::string res(fileDirname(fname1));
40  res += '/';
41  res += fileTail(fname2);
42  return res;
43  }
44 } // namespace gs
gs::fileDirname
std::string fileDirname(const char *filename)
Definition: uriUtils.cc:29
cms::cuda::assert
assert(be >=bs)
gs
Definition: AbsArchive.cc:45
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
gs::fileTail
std::string fileTail(const char *filename)
Definition: uriUtils.cc:19
gs::joinDir1WithName2
std::string joinDir1WithName2(const char *fname1, const char *fname2)
Definition: uriUtils.cc:38
res
Definition: Electron.h:6
gs::localFileURI
std::string localFileURI(const char *filename)
Definition: uriUtils.cc:8