[darwinbuild-changes] [486] branches/PR-6688645/darwinup/Depot.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 18 18:37:38 PDT 2009
Revision: 486
http://trac.macosforge.org/projects/darwinbuild/changeset/486
Author: wsiegrist at apple.com
Date: 2009-03-18 18:37:38 -0700 (Wed, 18 Mar 2009)
Log Message:
-----------
Remove the destination prefix from file object paths before moving them or creating the directories in the archive
Modified Paths:
--------------
branches/PR-6688645/darwinup/Depot.cpp
Modified: branches/PR-6688645/darwinup/Depot.cpp
===================================================================
--- branches/PR-6688645/darwinup/Depot.cpp 2009-03-18 23:39:58 UTC (rev 485)
+++ branches/PR-6688645/darwinup/Depot.cpp 2009-03-19 01:37:38 UTC (rev 486)
@@ -360,9 +360,18 @@
char path[PATH_MAX];
char* backup_dirpath;
- size_t len = strlcpy(path, actual->path(), sizeof(path));
+ // we need the path minus our destination path for moving to the archive
+ char *relpath = strstr(actual->path(), m_prefix);
+ if (relpath) {
+ // advance to just past the destination path
+ relpath += strlen(m_prefix);
+ }
+
+ size_t len = strlcpy(path, (relpath ? relpath : actual->path()),
+ sizeof(path));
assert(len <= sizeof(path));
+
const char* dir = dirname(path);
assert(dir != NULL);
@@ -432,10 +441,17 @@
int res = 0;
if (INFO_TEST(file->info(), FILE_INFO_ROLLBACK_DATA)) {
- char* dstpath;
+ char *dstpath, *relpath;
char uuidstr[37];
+ // we need the path minus our destination path for moving to the archive
+ relpath = strstr(file->path(), context->depot->m_prefix);
+ if (relpath) {
+ // advance to just past the destination path
+ relpath += strlen(context->depot->m_prefix);
+ }
uuid_unparse_upper(context->archive->uuid(), uuidstr);
- asprintf(&dstpath, "%s/%s/%s", context->depot->m_archives_path, uuidstr, file->path());
+ asprintf(&dstpath, "%s/%s/%s", context->depot->m_archives_path,
+ uuidstr, (relpath ? relpath : file->path()));
assert(dstpath != NULL);
++context->files_modified;
@@ -645,6 +661,7 @@
char* actpath;
asprintf(&actpath, "%s/%s", context->depot->m_prefix, file->path());
+ IF_DEBUG("[uninstall] actual path is %s\n", actpath);
File* actual = FileFactory(actpath);
uint32_t flags = File::compare(file, actual);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20090318/11545187/attachment.html>
More information about the darwinbuild-changes
mailing list