CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 {
9  assert(filename);
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) {
20  assert(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 
30  assert(filename);
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
assert(be >=bs)
std::string joinDir1WithName2(const char *fname1, const char *fname2)
Definition: uriUtils.cc:38
std::string localFileURI(const char *filename)
Definition: uriUtils.cc:8
std::string fileDirname(const char *filename)
Definition: uriUtils.cc:29
std::string fileTail(const char *filename)
Definition: uriUtils.cc:19
tuple filename
Definition: lut2db_cfg.py:20