assert(!snapper->getSnapshot1()->isCurrent() && !snapper->getSnapshot2()->isCurrent());
- string input = snapper->getSnapshot2()->baseDir() + "/filelist-" +
- decString(snapper->getSnapshot1()->getNum()) + ".txt";
+ unsigned int num1 = snapper->getSnapshot1()->getNum();
+ unsigned int num2 = snapper->getSnapshot2()->getNum();
+
+ bool invert = num1 > num2;
+
+ if (invert)
+ swap(num1, num2);
+
+ string input = snapper->snapshotsDir() + "/" + decString(num2) + "/filelist-" +
+ decString(num1) + ".txt";
FILE* file = fopen(input.c_str(), "r");
if (file == NULL)
string name = string(line, 5, strlen(line) - 6);
- File file(snapper, name, stringToStatus(string(line, 0, 4)));
+ unsigned int status = stringToStatus(string(line, 0, 4));
+
+ if (invert)
+ status = invertStatus(status);
+
+ File file(snapper, name, status);
entries.push_back(file);
}
assert(!snapper->getSnapshot1()->isCurrent() && !snapper->getSnapshot2()->isCurrent());
- string output = snapper->getSnapshot2()->baseDir() + "/filelist-" +
- decString(snapper->getSnapshot1()->getNum()) + ".txt";
+ unsigned int num1 = snapper->getSnapshot1()->getNum();
+ unsigned int num2 = snapper->getSnapshot2()->getNum();
+
+ bool invert = num1 > num2;
+
+ if (invert)
+ swap(num1, num2);
+
+ string output = snapper->snapshotsDir() + "/" + decString(num2) + "/filelist-" +
+ decString(num1) + ".txt";
char* tmp_name = (char*) malloc(output.length() + 12);
strcpy(tmp_name, output.c_str());
FILE* file = fdopen(fd, "w");
for (const_iterator it = entries.begin(); it != entries.end(); ++it)
- fprintf(file, "%s %s\n", statusToString(it->getPreToPostStatus()).c_str(),
- it->getName().c_str());
+ {
+ unsigned int status = it->getPreToPostStatus();
+
+ if (invert)
+ status = invertStatus(status);
+
+ fprintf(file, "%s %s\n", statusToString(status).c_str(), it->getName().c_str());
+ }
fclose(file);
y2mil("num1:" << snapshot1->getNum() << " num2:" << snapshot2->getNum());
+ bool invert = snapshot1->getNum() > snapshot2->getNum();
+
+ if (invert)
+ swap(snapshot1, snapshot1);
+
string dir1 = snapshot1->snapshotDir();
string dir2 = snapshot2->snapshotDir();
Snapshots::const_iterator new_snapshot2)
{
assert(new_snapshot1 != snapshots.end() && new_snapshot2 != snapshots.end());
+ assert(new_snapshot1 != new_snapshot2);
y2mil("num1:" << new_snapshot1->getNum() << " num2:" << new_snapshot2->getNum());