TF++, Miscellaneous classes and modules in C++:
dirname.cc
Go to the documentation of this file.
1 
34 #define TF_DIRNAME_CC_VERSION \
35  "TF_DIRNAME_CC V1.0"
36 
37 #include <tfxx/fs.h>
38 #include <cstring>
39 #include <libgen.h>
40 
41 namespace tfxx {
42 
43  namespace fs {
44 
45  std::string dirname(const std::string& path)
46  {
47  unsigned int n=path.length()+2;
48  char* p=new char[n];
49  std::strncpy(p, path.c_str(), n);
50  std::string retval(::dirname(p));
51  delete[] p;
52  return retval;
53  }
54 
55  } // namespace fs
56 
57 }
58 
59 /* ----- END OF dirname.cc ----- */
std::string dirname(const std::string &path)
return path with its last non-slash component removed
Definition: dirname.cc:45
Namespace containing all code of library libtfxx.