1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 12:21:55 +00:00

For #1635, refine inotify watch for relative path

This commit is contained in:
winlin 2020-03-16 11:39:20 +08:00
parent 88336b1f5e
commit 8db2c3d821

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;
}