mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
logging: implement get_dirname, move get_basename
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
This commit is contained in:
parent
ef22366455
commit
b00baab159
@ -117,6 +117,24 @@ static int safe_write(int fd, const char *buf, signed int len)
|
||||
}
|
||||
}
|
||||
|
||||
static std::string get_basename(const std::string &filename)
|
||||
{
|
||||
size_t last_slash = filename.find_last_of("/");
|
||||
if (last_slash == std::string::npos)
|
||||
return filename;
|
||||
return filename.substr(last_slash + 1);
|
||||
}
|
||||
|
||||
static std::string get_dirname(const std::string &filename)
|
||||
{
|
||||
size_t last_slash = filename.find_last_of("/");
|
||||
if (last_slash == std::string::npos)
|
||||
return ".";
|
||||
if (last_slash == 0)
|
||||
return filename;
|
||||
return filename.substr(0, last_slash);
|
||||
}
|
||||
|
||||
static int create_symlink(const string &oldpath, const string &newpath)
|
||||
{
|
||||
while (1) {
|
||||
@ -145,14 +163,6 @@ static int create_symlink(const string &oldpath, const string &newpath)
|
||||
}
|
||||
}
|
||||
|
||||
static std::string get_basename(const std::string &filename)
|
||||
{
|
||||
size_t last_slash = filename.find_last_of("/");
|
||||
if (last_slash == std::string::npos)
|
||||
return filename;
|
||||
return filename.substr(last_slash + 1);
|
||||
}
|
||||
|
||||
///////////////////////////// DoutStreambuf /////////////////////////////
|
||||
template <typename charT, typename traits>
|
||||
DoutStreambuf<charT, traits>::DoutStreambuf()
|
||||
|
Loading…
Reference in New Issue
Block a user