diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 861be3610..5fe03a129 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -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; }