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:
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue