CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
uriUtils.cc
Go to the documentation of this file.
1 #include <cstring>
2 #include <cassert>
3 #include "Alignment/Geners/interface/IOException.hh"
4 
5 #include "Alignment/Geners/interface/uriUtils.hh"
6 
7 namespace gs {
9  {
10  assert(filename);
11  if (strlen(filename) == 0) throw gs::IOInvalidArgument(
12  "In gs::localFileURI: empty file name");
13  std::string uri("file://");
14  if (filename[0] != '/')
15  uri += "./";
16  uri += filename;
17  return uri;
18  }
19 
21  {
22  assert(filename);
23  const char *progname = std::strrchr(filename, '/');
24  if (progname)
25  ++progname;
26  else
27  progname = filename;
28  return std::string(progname);
29  }
30 
32  {
33  assert(filename);
34  const char *progname = std::strrchr(filename, '/');
35  if (progname)
36  return std::string(filename, progname - filename);
37  else
38  return std::string(".");
39  }
40 
41  std::string joinDir1WithName2(const char* fname1, const char* fname2)
42  {
43  std::string res(fileDirname(fname1));
44  res += '/';
45  res += fileTail(fname2);
46  return res;
47  }
48 }
std::string joinDir1WithName2(const char *fname1, const char *fname2)
Definition: uriUtils.cc:41
std::string localFileURI(const char *filename)
Definition: uriUtils.cc:8
std::string fileDirname(const char *filename)
Definition: uriUtils.cc:31
std::string fileTail(const char *filename)
Definition: uriUtils.cc:20
tuple filename
Definition: lut2db_cfg.py:20