BUG: Revert the change to FileIsDirectory. Add FileIsSymlink and treat symlinks as files when removing directory
This commit is contained in:
parent
0e76ab6eb6
commit
eee2d2b035
@ -1827,7 +1827,8 @@ bool SystemTools::RemoveADirectory(const char* source)
|
|||||||
kwsys_stl::string fullPath = source;
|
kwsys_stl::string fullPath = source;
|
||||||
fullPath += "/";
|
fullPath += "/";
|
||||||
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
||||||
if(SystemTools::FileIsDirectory(fullPath.c_str()))
|
if(SystemTools::FileIsDirectory(fullPath.c_str()) &&
|
||||||
|
!SystemTools::FileIsSymlink(fullPath.c_str()))
|
||||||
{
|
{
|
||||||
if (!SystemTools::RemoveADirectory(fullPath.c_str()))
|
if (!SystemTools::RemoveADirectory(fullPath.c_str()))
|
||||||
{
|
{
|
||||||
@ -2044,11 +2045,7 @@ kwsys_stl::string SystemTools
|
|||||||
bool SystemTools::FileIsDirectory(const char* name)
|
bool SystemTools::FileIsDirectory(const char* name)
|
||||||
{
|
{
|
||||||
struct stat fs;
|
struct stat fs;
|
||||||
#if _WIN32
|
|
||||||
if(stat(name, &fs) == 0)
|
if(stat(name, &fs) == 0)
|
||||||
#else
|
|
||||||
if(lstat(name, &fs) == 0)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
return ((fs.st_mode & _S_IFDIR) != 0);
|
return ((fs.st_mode & _S_IFDIR) != 0);
|
||||||
@ -2062,6 +2059,23 @@ bool SystemTools::FileIsDirectory(const char* name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SystemTools::FileIsSymlink(const char* name)
|
||||||
|
{
|
||||||
|
#if _WIN32
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
struct stat fs;
|
||||||
|
if(lstat(name, &fs) == 0)
|
||||||
|
{
|
||||||
|
return S_ISLNK(fs.st_mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int SystemTools::ChangeDirectory(const char *dir)
|
int SystemTools::ChangeDirectory(const char *dir)
|
||||||
{
|
{
|
||||||
return Chdir(dir);
|
return Chdir(dir);
|
||||||
|
@ -501,6 +501,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool FileIsDirectory(const char* name);
|
static bool FileIsDirectory(const char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the file is a symlink
|
||||||
|
*/
|
||||||
|
static bool FileIsSymlink(const char* name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if the file has a given signature (first set of bytes)
|
* return true if the file has a given signature (first set of bytes)
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user