Author: kpvdr
Date: 2012-01-25 14:35:43 -0500 (Wed, 25 Jan 2012)
New Revision: 4491
Modified:
store/trunk/cpp/lib/jrnl/jdir.cpp
Log:
Minor fix to jdir: now able to handle symbolic links.
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2012-01-06 20:41:19 UTC (rev 4490)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2012-01-25 19:35:43 UTC (rev 4491)
@@ -284,15 +284,13 @@
if (std::strcmp(entry->d_name, ".") != 0 &&
std::strcmp(entry->d_name, "..") != 0)
{
std::string full_name(dirname + "/" + entry->d_name);
- if (::stat(full_name.c_str(), &s))
+ if (::lstat(full_name.c_str(), &s))
{
::closedir(dir);
std::ostringstream oss;
oss << "stat: file=\"" << full_name
<< "\"" << FORMAT_SYSERR(errno);
throw jexception(jerrno::JERR_JDIR_STAT, oss.str(), "jdir",
"delete_dir");
}
- // FIXME: This fn does not handle symbolic links correctly and throws up
- // For some reason, S_ISLNK() fails to identify links correctly.
if (S_ISREG(s.st_mode) || S_ISLNK(s.st_mode)) // This is a file or slink
{
if(::unlink(full_name.c_str()))
@@ -412,7 +410,7 @@
// Throw for any other condition
std::ostringstream oss;
oss << "file=\"" << name << "\""
<< FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_JDIR_STAT, oss.str(), "jdir",
"is_dir");
+ throw jexception(jerrno::JERR_JDIR_STAT, oss.str(), "jdir",
"exists");
}
return true;
}
Show replies by date