mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
For #1635, refine inotify watch for relative path
This commit is contained in:
parent
88336b1f5e
commit
8db2c3d821
1 changed files with 12 additions and 7 deletions
|
@ -652,15 +652,20 @@ bool srs_path_exists(std::string path)
|
||||||
string srs_path_dirname(string path)
|
string srs_path_dirname(string path)
|
||||||
{
|
{
|
||||||
std::string dirname = path;
|
std::string dirname = path;
|
||||||
size_t pos = string::npos;
|
|
||||||
|
|
||||||
if ((pos = dirname.rfind("/")) != string::npos) {
|
// No slash, it must be current dir.
|
||||||
|
size_t pos = string::npos;
|
||||||
|
if ((pos = dirname.rfind("/")) == string::npos) {
|
||||||
|
return "./";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path under root.
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
dirname = dirname.substr(0, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Fetch the directory.
|
||||||
|
dirname = dirname.substr(0, pos);
|
||||||
return dirname;
|
return dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue