Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:21

0001 #include "Alignment/Geners/interface/IOException.hh"
0002 #include <cassert>
0003 #include <cstring>
0004 
0005 #include "Alignment/Geners/interface/uriUtils.hh"
0006 
0007 namespace gs {
0008   std::string localFileURI(const char *filename) {
0009     assert(filename);
0010     if (strlen(filename) == 0)
0011       throw gs::IOInvalidArgument("In gs::localFileURI: empty file name");
0012     std::string uri("file://");
0013     if (filename[0] != '/')
0014       uri += "./";
0015     uri += filename;
0016     return uri;
0017   }
0018 
0019   std::string fileTail(const char *filename) {
0020     assert(filename);
0021     const char *progname = std::strrchr(filename, '/');
0022     if (progname)
0023       ++progname;
0024     else
0025       progname = filename;
0026     return std::string(progname);
0027   }
0028 
0029   std::string fileDirname(const char *filename) {
0030     assert(filename);
0031     const char *progname = std::strrchr(filename, '/');
0032     if (progname)
0033       return std::string(filename, progname - filename);
0034     else
0035       return std::string(".");
0036   }
0037 
0038   std::string joinDir1WithName2(const char *fname1, const char *fname2) {
0039     std::string res(fileDirname(fname1));
0040     res += '/';
0041     res += fileTail(fname2);
0042     return res;
0043   }
0044 }  // namespace gs