Skip to content

Commit

Permalink
For #1635, refine inotify watch for relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 16, 2020
1 parent 88336b1 commit 8db2c3d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions trunk/src/kernel/srs_kernel_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8db2c3d

Please sign in to comment.