Added print all files
This commit is contained in:
parent
f87c65a93f
commit
94eba936f3
108
disk.cpp
108
disk.cpp
|
@ -1,11 +1,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#define SECTOR_SIZE 256
|
#define FDIR_OFFSET 128 * 16
|
||||||
#define SECTOR_COUNT 16
|
|
||||||
#define VTOC_OFFSET SECTOR_COUNT * 17 * SECTOR_SIZE
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -40,11 +39,42 @@ public:
|
||||||
static Disk _this;
|
static Disk _this;
|
||||||
return _this.disk;
|
return _this.disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int findFile(int offset) {
|
||||||
|
Disk::getDisk().seekg(offset);
|
||||||
|
while (!(Disk::read(1) && 0x80)) {
|
||||||
|
++offset;
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void volumeInfo() {
|
||||||
|
Disk::getDisk().seekg(64 * 16);
|
||||||
|
cout << hex;
|
||||||
|
cout << "--------------------" << endl;
|
||||||
|
cout << "always $D2D7 " << Disk::read(2) << endl;
|
||||||
|
cout << "date and time of initialization " << Disk::read(4) << endl;
|
||||||
|
cout << "date and time of last backup " << Disk::read(4) << endl;
|
||||||
|
cout << "volume attributes " << Disk::read(2) << endl;
|
||||||
|
cout << "number of files in directory " << Disk::read(2) << endl;
|
||||||
|
cout << "first block of directory " << Disk::read(2) << endl;
|
||||||
|
cout << "length of directory in blocks " << Disk::read(2) << endl;
|
||||||
|
cout << "number of allocation blocks on volume " << Disk::read(2) << endl;
|
||||||
|
cout << "size of allocation blocks " << Disk::read(4) << endl;
|
||||||
|
cout << "number of bytes to allocate " << Disk::read(4) << endl;
|
||||||
|
cout << "first allocation block in block map " << Disk::read(2) << endl;
|
||||||
|
cout << "next unused file number " << Disk::read(4) << endl;
|
||||||
|
cout << "number of unused allocation blocks " << Disk::read(2) << endl;
|
||||||
|
cout << "length of volume name " << Disk::read(1) << endl;
|
||||||
|
cout << "characters of volume namealways $D2D7 " << Disk::read(4) << endl;
|
||||||
|
cout << "--------------------" << endl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int flFIags;
|
int flFIags;
|
||||||
int flTyp;
|
int flTyp;
|
||||||
int flUsrWds;
|
int flUsrWds;
|
||||||
|
@ -66,7 +96,7 @@ public:
|
||||||
File(int offset) {
|
File(int offset) {
|
||||||
Disk::getDisk().seekg(offset);
|
Disk::getDisk().seekg(offset);
|
||||||
flFIags = Disk::read(1);
|
flFIags = Disk::read(1);
|
||||||
if (isValid()) {
|
if (flFIags & 0x80) {
|
||||||
flTyp = Disk::read(1);
|
flTyp = Disk::read(1);
|
||||||
flUsrWds = Disk::read(16);
|
flUsrWds = Disk::read(16);
|
||||||
flFINum = Disk::read(4);
|
flFINum = Disk::read(4);
|
||||||
|
@ -90,58 +120,54 @@ public:
|
||||||
if (fEnd % 2) {
|
if (fEnd % 2) {
|
||||||
++fEnd;
|
++fEnd;
|
||||||
}
|
}
|
||||||
printAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid() {
|
|
||||||
/*return flFIags & 0x80;*/
|
|
||||||
return flFIags == 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printAll() {
|
void printAll() {
|
||||||
cout << "--------------------" << endl;
|
|
||||||
cout << hex;
|
cout << hex;
|
||||||
cout << flFIags << endl;
|
cout << "--------------------" << endl;
|
||||||
cout << flTyp << endl;
|
cout << "flags " << flFIags << endl;
|
||||||
cout << flUsrWds << endl;
|
cout << "version number " << flTyp << endl;
|
||||||
cout << flFINum << endl;
|
cout << "information used by the Finder " << flUsrWds << endl;
|
||||||
cout << flStBlk << endl;
|
cout << "file number " << flFINum << endl;
|
||||||
cout << flLgLen << endl;
|
cout << "first allocation block of data fork " << flStBlk << endl;
|
||||||
cout << flPyLen << endl;
|
cout << "logical end-of-file of data fork " << flLgLen << endl;
|
||||||
cout << flRStBlk << endl;
|
cout << "physical end-of-file of data fork " << flPyLen << endl;
|
||||||
cout << flRLgLen << endl;
|
cout << "first allocation block of resource fork " << flRStBlk << endl;
|
||||||
cout << flRPyLen << endl;
|
cout << "logical end-of-file of resource fork " << flRLgLen << endl;
|
||||||
cout << flCrDat << endl;
|
cout << "physical end-of-file of resource fork " << flRPyLen << endl;
|
||||||
cout << flMdDat << endl;
|
cout << "date and time of creation " << flCrDat << endl;
|
||||||
cout << flNam << endl;
|
cout << "date and time of last modification " << flMdDat << endl;
|
||||||
printFileName();
|
cout << "length of file name " << flNam << endl;
|
||||||
cout << "--------------------" << endl;
|
cout << "--------------------" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printFileName() {
|
void printFileName() {
|
||||||
cout << "\\" << flNamS << "\\" << endl;
|
cout << "File name: " << flNamS << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int fBegin = 128 * 16;
|
|
||||||
/*for(;;) {
|
|
||||||
File f(fBegin);
|
|
||||||
if (!f.isValid()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fBegin = f.fEnd;
|
|
||||||
f.printFileName();
|
|
||||||
}
|
|
||||||
File f1(fBegin + 20);
|
|
||||||
File f2(f1.fEnd);*/
|
|
||||||
|
|
||||||
/* SUPER FINDER!!!!!!!!!!!! */
|
Disk::getDisk().seekg(64 * 16 + 12);
|
||||||
for (int i = 0; i < 10000000; ++i) {
|
int fileCount = Disk::read(2);
|
||||||
File f(i);
|
vector< File > files;
|
||||||
|
|
||||||
|
|
||||||
|
int fBegin = FDIR_OFFSET;
|
||||||
|
for(int i = 0; i < fileCount; ++i) {
|
||||||
|
fBegin = Disk::findFile(fBegin);
|
||||||
|
files.emplace_back(fBegin);
|
||||||
|
fBegin = files.back().fEnd;
|
||||||
|
|
||||||
|
cout << "counter: " << i << endl;
|
||||||
|
files.back().printFileName();
|
||||||
|
files.back().printAll();
|
||||||
|
cout << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Disk::volumeInfo();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue