1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Merge branch '3.0release' into 4.0release

This commit is contained in:
winlin 2020-03-21 19:36:16 +08:00
commit 955de3dac9
4 changed files with 57 additions and 45 deletions

View file

@ -652,15 +652,20 @@ bool srs_path_exists(std::string path)
string srs_path_dirname(string path)
{
std::string dirname = path;
// No slash, it must be current dir.
size_t pos = string::npos;
if ((pos = dirname.rfind("/")) != string::npos) {
if (pos == 0) {
return "/";
}
dirname = dirname.substr(0, pos);
if ((pos = dirname.rfind("/")) == string::npos) {
return "./";
}
// Path under root.
if (pos == 0) {
return "/";
}
// Fetch the directory.
dirname = dirname.substr(0, pos);
return dirname;
}