diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-07 22:40:29 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-07 22:40:29 +0000 |
commit | 531b48b2597082707cc173753633c44d1fa72e43 (patch) | |
tree | 9deb2bcaef9f88b2d330e3288684d796a4d9b045 /cpp/src/IcePatch/Util.cpp | |
parent | fixes (diff) | |
download | ice-531b48b2597082707cc173753633c44d1fa72e43.tar.bz2 ice-531b48b2597082707cc173753633c44d1fa72e43.tar.xz ice-531b48b2597082707cc173753633c44d1fa72e43.zip |
remove orphaned files
Diffstat (limited to 'cpp/src/IcePatch/Util.cpp')
-rw-r--r-- | cpp/src/IcePatch/Util.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index 1d11153c11a..0b59e8be821 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -106,6 +106,20 @@ IcePatch::getSuffix(const string& path) } } +string +IcePatch::removeSuffix(const string& path) +{ + string::size_type pos = path.rfind('.'); + if (pos == string::npos) + { + return path; + } + else + { + return path.substr(0, pos); + } +} + FileInfo IcePatch::getFileInfo(const string& path) { @@ -698,6 +712,40 @@ IcePatch::createBZ2Recursive(const string& path) } void +IcePatch::removeOrphanedRecursive(const string& path) +{ + assert(getFileInfo(path) == FileInfoDirectory); + + StringSeq paths = readDirectory(path); + StringSeq::const_iterator p; + for (p = paths.begin(); p != paths.end(); ++p) + { + string suffix = getSuffix(*p); + if (suffix == ".md5" || suffix == ".bz2") + { + pair<StringSeq::const_iterator, StringSeq::const_iterator> r = + equal_range(paths.begin(), paths.end(), removeSuffix(*p)); + if (r.first == r.second) + { + removeRecursive(*p); + } + } + else + { + if (getFileInfo(*p) == FileInfoDirectory) + { + removeOrphanedRecursive(*p); + } + } + } + + if (readDirectory(path).empty()) + { + removeRecursive(path); + } +} + +void IcePatch::getFile(const FilePrx& file, ProgressCB& progressCB) { string path = identityToPath(file->ice_getIdentity()); |