Add print file names
This commit is contained in:
parent
9588b4dfb5
commit
f87c65a93f
171
disk.cpp
171
disk.cpp
|
@ -11,72 +11,137 @@ using namespace std;
|
||||||
|
|
||||||
class Disk {
|
class Disk {
|
||||||
|
|
||||||
struct VTOC {
|
fstream disk;
|
||||||
int track;
|
|
||||||
int sector;
|
|
||||||
|
|
||||||
init() {
|
Disk() {
|
||||||
track = read(VTOC_OFFSET + 1);
|
disk.open("copy.dsk", ios_base::binary | ios_base::in);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
VTOC s;
|
~Disk() {
|
||||||
fstream disk;
|
disk.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
Disk(const Disk&) = delete;
|
||||||
|
|
||||||
|
Disk& operator=(const Disk&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Disk() {
|
static int read(int size) {
|
||||||
disk.open("copy.dsk", ios_base::binary | ios_base::in);
|
int res = 0;
|
||||||
s.init();
|
for (int i = 0; i < size; ++i) {
|
||||||
}
|
res = res << 8;
|
||||||
|
res |= getDisk().get();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
~Disk() {
|
static fstream& getDisk() {
|
||||||
disk.close();
|
static Disk _this;
|
||||||
}
|
return _this.disk;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Disk(const Disk&) = delete;
|
class File {
|
||||||
|
|
||||||
Disk& operator=(const Disk&) = delete;
|
public:
|
||||||
|
int flFIags;
|
||||||
|
int flTyp;
|
||||||
|
int flUsrWds;
|
||||||
|
int flFINum;
|
||||||
|
int flStBlk;
|
||||||
|
int flLgLen;
|
||||||
|
int flPyLen;
|
||||||
|
int flRStBlk;
|
||||||
|
int flRLgLen;
|
||||||
|
int flRPyLen;
|
||||||
|
int flCrDat;
|
||||||
|
int flMdDat;
|
||||||
|
int flNam;
|
||||||
|
string flNamS;
|
||||||
|
|
||||||
int read(int offset) {
|
int fBegin;
|
||||||
disk.seekg(offset);
|
int fEnd;
|
||||||
return disk.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*int getNextSector(int this_sector) {
|
File(int offset) {
|
||||||
disk.seekg(this_sector + 1);
|
Disk::getDisk().seekg(offset);
|
||||||
int track = disk.get();
|
flFIags = Disk::read(1);
|
||||||
int sector = disk.get();
|
if (isValid()) {
|
||||||
return ((track * SECTOR_COUNT) + sector) * SECTOR_SIZE;
|
flTyp = Disk::read(1);
|
||||||
}
|
flUsrWds = Disk::read(16);
|
||||||
|
flFINum = Disk::read(4);
|
||||||
|
flStBlk = Disk::read(2);
|
||||||
|
flLgLen = Disk::read(4);
|
||||||
|
flPyLen = Disk::read(4);
|
||||||
|
flRStBlk = Disk::read(2);
|
||||||
|
flRLgLen = Disk::read(4);
|
||||||
|
flRPyLen = Disk::read(4);
|
||||||
|
flCrDat = Disk::read(4);
|
||||||
|
flMdDat = Disk::read(4);
|
||||||
|
flNam = Disk::read(1);
|
||||||
|
|
||||||
int getName(int this_sector) {
|
char *temp = new char[flNam + 1];
|
||||||
disk.seekg(this_sector + 14);
|
Disk::getDisk().get(temp, flNam + 1);
|
||||||
char name[31];
|
flNamS = string(temp);
|
||||||
disk.get(name, 30);
|
delete temp;
|
||||||
string s(name);
|
|
||||||
for (int i=0; i<30; i++) cout << name[i];
|
|
||||||
cout << s << endl;
|
|
||||||
return 0;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void printSector(int offset, int size, int strsize) {
|
fBegin = offset;
|
||||||
disk.seekg(offset);
|
fEnd = fBegin + 51 + flNam;
|
||||||
size /= 2;
|
if (fEnd % 2) {
|
||||||
for (int i = 1; i <= size; ++i) {
|
++fEnd;
|
||||||
cout << hex << setw(2) << setfill('0') << disk.get();
|
}
|
||||||
cout << hex << setw(2) << setfill('0') << disk.get() << " ";
|
printAll();
|
||||||
if (!(i % strsize)) {
|
}
|
||||||
cout << endl;
|
}
|
||||||
}
|
|
||||||
}
|
bool isValid() {
|
||||||
cout << endl;
|
/*return flFIags & 0x80;*/
|
||||||
}
|
return flFIags == 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printAll() {
|
||||||
|
cout << "--------------------" << endl;
|
||||||
|
cout << hex;
|
||||||
|
cout << flFIags << endl;
|
||||||
|
cout << flTyp << endl;
|
||||||
|
cout << flUsrWds << endl;
|
||||||
|
cout << flFINum << endl;
|
||||||
|
cout << flStBlk << endl;
|
||||||
|
cout << flLgLen << endl;
|
||||||
|
cout << flPyLen << endl;
|
||||||
|
cout << flRStBlk << endl;
|
||||||
|
cout << flRLgLen << endl;
|
||||||
|
cout << flRPyLen << endl;
|
||||||
|
cout << flCrDat << endl;
|
||||||
|
cout << flMdDat << endl;
|
||||||
|
cout << flNam << endl;
|
||||||
|
printFileName();
|
||||||
|
cout << "--------------------" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printFileName() {
|
||||||
|
cout << "\\" << flNamS << "\\" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Disk disk;
|
int fBegin = 128 * 16;
|
||||||
disk.printSector(VTOC_OFFSET, SECTOR_SIZE, 8);
|
/*for(;;) {
|
||||||
return 1;
|
File f(fBegin);
|
||||||
|
if (!f.isValid()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fBegin = f.fEnd;
|
||||||
|
f.printFileName();
|
||||||
|
}
|
||||||
|
File f1(fBegin + 20);
|
||||||
|
File f2(f1.fEnd);*/
|
||||||
|
|
||||||
|
/* SUPER FINDER!!!!!!!!!!!! */
|
||||||
|
for (int i = 0; i < 10000000; ++i) {
|
||||||
|
File f(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue