diff options
author | David Cole <david.cole@kitware.com> | 2008-09-11 18:34:04 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2008-09-11 18:34:04 (GMT) |
commit | bd1935dcd12d23a23878dc727545743fb078c7cb (patch) | |
tree | f25e552c73dc9ea3c31ff186829f5bdd905c1324 /Source/kwsys | |
parent | 0e5319f21dc6a6079a8af82e40ca3e9da563b6de (diff) | |
download | CMake-bd1935dcd12d23a23878dc727545743fb078c7cb.zip CMake-bd1935dcd12d23a23878dc727545743fb078c7cb.tar.gz CMake-bd1935dcd12d23a23878dc727545743fb078c7cb.tar.bz2 |
ENH: Improve FILE GLOB_RECURSE handling of symlinks with a new CMake policy. CMP0009 establishes NEW default behavior of not recursing through symlinks. OLD default behavior or explicit FOLLOW_SYMLINKS argument to FILE GLOB_RECURSE will still recurse through symlinks.
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/Glob.cxx | 9 | ||||
-rw-r--r-- | Source/kwsys/Glob.hxx.in | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 80fdf29..f5dc512 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -67,6 +67,7 @@ Glob::Glob() this->RecurseThroughSymlinks = true; // RecurseThroughSymlinks is true by default for backwards compatibility, // not because it's a good idea... + this->FollowedSymlinkCount = 0; } //---------------------------------------------------------------------------- @@ -266,9 +267,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, } if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { - if (!kwsys::SystemTools::FileIsSymlink(realname.c_str()) || - this->RecurseThroughSymlinks) + bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); + if (!isSymLink || this->RecurseThroughSymlinks) { + if (isSymLink) + { + ++this->FollowedSymlinkCount; + } this->RecurseDirectory(start+1, realname, dir_only); } } diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index a66dd6f..fb4eac6 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -64,6 +64,9 @@ public: void SetRecurseThroughSymlinks(bool i) { this->RecurseThroughSymlinks = i; } bool GetRecurseThroughSymlinks() { return this->RecurseThroughSymlinks; } + //! Get the number of symlinks followed through recursion + unsigned int GetFollowedSymlinkCount() { return this->FollowedSymlinkCount; } + //! Set relative to true to only show relative path to files. void SetRelative(const char* dir); const char* GetRelative(); @@ -98,6 +101,7 @@ protected: bool Recurse; kwsys_stl::string Relative; bool RecurseThroughSymlinks; + unsigned int FollowedSymlinkCount; private: Glob(const Glob&); // Not implemented. |