Zip-O-Matic: fix zipping single folder.

Fixes #12027. No clue why this code ever worked.
This commit is contained in:
Augustin Cavalier
2015-06-01 20:57:45 -04:00
parent 9fb72ec18e
commit d1d90b0462
+11 -19
View File
@@ -93,29 +93,25 @@ ZipperThread::ThreadStartup()
gotDirRef = true; gotDirRef = true;
} }
if (gotDirRef) { BString archiveName;
BEntry entry(&dirRef);
BPath path; if (gotDirRef || sameFolder) {
entry.GetPath(&path);
chdir(path.Path());
} else if (sameFolder) {
BEntry entry(&lastRef); BEntry entry(&lastRef);
BPath path; BPath path;
entry.GetParent(&entry); entry.GetParent(&entry);
entry.GetPath(&path); entry.GetPath(&path);
chdir(path.Path()); archiveName = path.Path();
} else { } else {
BPath path; BPath path;
if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK)
chdir(path.Path()); archiveName = path.Path();
} }
archiveName.Append("/");
BString archiveName;
if (refCount > 1) if (refCount > 1)
archiveName = B_TRANSLATE("Archive"); archiveName.Append(B_TRANSLATE("Archive"));
else else
archiveName = lastRef.name; archiveName.Append(lastRef.name);
int index = 1; int index = 1;
for (;; index++) { for (;; index++) {
@@ -144,13 +140,9 @@ ZipperThread::ThreadStartup()
for (int index = 0; index < refCount; index++) { for (int index = 0; index < refCount; index++) {
fThreadDataStore->FindRef("refs", index, &ref); fThreadDataStore->FindRef("refs", index, &ref);
if (gotDirRef || sameFolder) { BPath path(&ref);
argv[3 + index] = strdup(ref.name); BString file = path.Path();
} else { argv[3 + index] = strdup(path.Path());
BPath path(&ref);
BString file = path.Path();
argv[3 + index] = strdup(path.Path());
}
} }
argv[argc] = NULL; argv[argc] = NULL;