~singpolyma/biboumi

ref: ffb402f0adb9f808c7b8bc9616e71f7b3f8931ac biboumi/src/utils/dirname.cpp -rw-r--r-- 372 bytes
ffb402f0 — louiz’ Drop support for botan < 2.0 6 years ago
                                                                                
7b3e0e0c louiz’
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <utils/dirname.hpp>

namespace utils
{
    std::string dirname(const std::string filename)
    {
      if (filename.empty())
        return "./";
      if (filename == ".." || filename == ".")
        return filename;
      auto pos = filename.rfind('/');
      if (pos == std::string::npos)
        return "./";
      return filename.substr(0, pos + 1);
    }
}