File dump fixes

This commit is contained in:
Pavel Dovgalyuk 2018-04-25 16:08:37 +03:00
parent b9a9897451
commit fa4dd6643f
2 changed files with 16 additions and 8 deletions

BIN
disk

Binary file not shown.

View File

@ -22,7 +22,7 @@ class Disk {
disk.seekg(VINF_OFFSET + 16); disk.seekg(VINF_OFFSET + 16);
drBILen = readByte(2); drBILen = readByte(2);
drNmAIBIks = readByte(2); drNmAIBIks = readByte(2);
allocBlockMap.resize(drNmAIBIks); allocBlockMap.resize(drNmAIBIks);
disk.seekg(ABMAP_OFFSET); disk.seekg(ABMAP_OFFSET);
@ -91,7 +91,7 @@ public:
static void volumeInfo() { static void volumeInfo() {
int temp; int temp;
Disk::getDiskStream().seekg(64 * 16); Disk::getDiskStream().seekg(512 * 2);
cout << hex; cout << hex;
cout << "--------------------" << endl; cout << "--------------------" << endl;
cout << "Volume Information" << endl; cout << "Volume Information" << endl;
@ -217,16 +217,22 @@ public:
int firstOffset = Disk::getFContOffset(); int firstOffset = Disk::getFContOffset();
char str[ALLOCBLOCK_LENGTH + 1]; char str[ALLOCBLOCK_LENGTH + 1];
while ((point != 1) && (point != 0)) { while ((point != 1) && (point != 0)) {
Disk::getDiskStream().seekg(firstOffset + (point - 2) * ALLOCBLOCK_LENGTH); int offset = firstOffset + (point - 2) * ALLOCBLOCK_LENGTH;
Disk::getDiskStream().get(str, ALLOCBLOCK_LENGTH + 1); //cout << hex << "block " << point << " offset " << offset << "\n";
out.write(str, ALLOCBLOCK_LENGTH + 1); Disk::getDiskStream().seekg(offset);
Disk::getDiskStream().read(str, ALLOCBLOCK_LENGTH);
out.write(str, ALLOCBLOCK_LENGTH);
//cout.write(str, ALLOCBLOCK_LENGTH);
point = Disk::getDisk().allocBlockMap[point - 2]; point = Disk::getDisk().allocBlockMap[point - 2];
} }
} }
void saveFile(string path) { void saveFile(string path) {
string fname;
if (flRStBlk != 0) { if (flRStBlk != 0) {
fstream file(path + getValidFileName() + ".resourсe", ios_base::binary | ios_base::out); fname = path + getValidFileName() + ".resourсe";
//cout << fname << "\n";
fstream file(fname, ios_base::binary | ios_base::out);
if (!file.is_open()) { if (!file.is_open()) {
cout << "error: file not created: " << flNamS << endl; cout << "error: file not created: " << flNamS << endl;
} }
@ -235,7 +241,9 @@ public:
} }
if (flStBlk != 0) { if (flStBlk != 0) {
fstream file(path + getValidFileName() + ".data", ios_base::binary | ios_base::out); fname = path + getValidFileName() + ".data";
//cout << fname << "\n";
fstream file(fname, ios_base::binary | ios_base::out);
if (!file.is_open()) { if (!file.is_open()) {
cout << "error: file not created: " << flNamS << endl; cout << "error: file not created: " << flNamS << endl;
} }
@ -289,4 +297,4 @@ int main() {
generInfoFile("Files/", files); generInfoFile("Files/", files);
return 1; return 1;
} }