git-svn-id: https://spexeah.com:8443/svn/Asuro@757 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
cdf2267a25
commit
476a189b21
@ -363,7 +363,7 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pop_trace();
|
//pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure readPIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : puint32);
|
procedure readPIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : puint32);
|
||||||
@ -425,7 +425,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pop_trace();
|
//pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure readPIOPI(drive : uint8; LBA : uint32; buffer : Puint32);
|
procedure readPIOPI(drive : uint8; LBA : uint32; buffer : Puint32);
|
||||||
|
@ -118,7 +118,9 @@ var
|
|||||||
i : uint32;
|
i : uint32;
|
||||||
ii: uint32;
|
ii: uint32;
|
||||||
begin
|
begin
|
||||||
//cleanString:= pchar(kalloc(sizeof(10)));
|
//puint32(cleanString):= puint32(kalloc(sizeof(10)));
|
||||||
|
//memset(uint32(@cleanString), 0, 10);
|
||||||
|
push_trace('cleanstring()');
|
||||||
for i:=0 to 7 do begin
|
for i:=0 to 7 do begin
|
||||||
if str[i] = char(0) then begin
|
if str[i] = char(0) then begin
|
||||||
for ii:=i to 7 do begin
|
for ii:=i to 7 do begin
|
||||||
@ -135,6 +137,35 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function cleanStringCha(str : pchar) : pchar;
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
ii: uint32;
|
||||||
|
begin
|
||||||
|
cleanStringCha:= pchar(kalloc(10));
|
||||||
|
memset(uint32(cleanstringcha), 0, 10);
|
||||||
|
push_trace('cleanstringcha');
|
||||||
|
for i:=0 to 7 do begin
|
||||||
|
push_trace('cleanstringcha1');
|
||||||
|
|
||||||
|
if str[i] = char(0) then begin
|
||||||
|
push_trace('cleanstringcha1.1');
|
||||||
|
|
||||||
|
for ii:=i to 7 do begin
|
||||||
|
cleanStringCha[ii]:= ' ';
|
||||||
|
end;
|
||||||
|
break;
|
||||||
|
end else begin
|
||||||
|
push_trace('cleanstringcha1.2');
|
||||||
|
cleanstringcha[i]:= str[i];
|
||||||
|
push_trace('cleanstringcha1.3');
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
push_trace('cleanstringcha2');
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
function readBootRecord(volume : PStorage_volume) : PBootRecord; // need write functions for boot record!
|
function readBootRecord(volume : PStorage_volume) : PBootRecord; // need write functions for boot record!
|
||||||
var
|
var
|
||||||
buffer : puint32;
|
buffer : puint32;
|
||||||
@ -233,6 +264,7 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('fat32.findFreeClusters');
|
push_trace('fat32.findFreeClusters');
|
||||||
clusters := LL_New(8);
|
clusters := LL_New(8);
|
||||||
|
dirElm:= kalloc(sizeof(TDirectory_Entry)); //TODO FREE
|
||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
|
|
||||||
@ -317,6 +349,7 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('fat32.fat2GenericEntries');
|
push_trace('fat32.fat2GenericEntries');
|
||||||
puint32(entry) := kalloc(sizeof(TDirectory_Entry));
|
puint32(entry) := kalloc(sizeof(TDirectory_Entry));
|
||||||
|
dirElm:= kalloc(sizeof(TDirectory_Entry));
|
||||||
fat2GenericEntries:= LL_New(sizeof(TDirectory_Entry));
|
fat2GenericEntries:= LL_New(sizeof(TDirectory_Entry));
|
||||||
|
|
||||||
if LL_size(list) > 0 then begin //TODO
|
if LL_size(list) > 0 then begin //TODO
|
||||||
@ -340,6 +373,7 @@ begin
|
|||||||
|
|
||||||
kfree(puint32(list));
|
kfree(puint32(list));
|
||||||
kfree(puint32(entry));
|
kfree(puint32(entry));
|
||||||
|
kfree(dirElm);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//need to find out why having multiple dir stings isn't working, maybe the ls command? did I fix this?
|
//need to find out why having multiple dir stings isn't working, maybe the ls command? did I fix this?
|
||||||
@ -397,7 +431,7 @@ begin
|
|||||||
|
|
||||||
readDirectory:= directories;
|
readDirectory:= directories;
|
||||||
|
|
||||||
statusOut^:= status^;
|
statusOut:= status;
|
||||||
LL_Free(directoryStrings);
|
LL_Free(directoryStrings);
|
||||||
kfree(puint32(bootRecord));
|
kfree(puint32(bootRecord));
|
||||||
end;
|
end;
|
||||||
@ -616,7 +650,7 @@ end;
|
|||||||
function readFile(volume : PStorage_Volume; directory : pchar; fileName : pchar; fileExtension : pchar; buffer : puint32; bytecount : puint32) : uint32;
|
function readFile(volume : PStorage_Volume; directory : pchar; fileName : pchar; fileExtension : pchar; buffer : puint32; bytecount : puint32) : uint32;
|
||||||
var
|
var
|
||||||
bootRecord : PBootRecord;
|
bootRecord : PBootRecord;
|
||||||
directories : PLinkedListBase;
|
dirs : PLinkedListBase;
|
||||||
dir : PDirectory;
|
dir : PDirectory;
|
||||||
readbuffer : puint32;
|
readbuffer : puint32;
|
||||||
data : puint32;
|
data : puint32;
|
||||||
@ -627,42 +661,60 @@ var
|
|||||||
clusters : PLinkedListBase;
|
clusters : PLinkedListBase;
|
||||||
noClusters : uint32;
|
noClusters : uint32;
|
||||||
dataStart : uint32;
|
dataStart : uint32;
|
||||||
|
cleanFileName : byteArray8;
|
||||||
|
otherCleanFileName : byteArray8;
|
||||||
|
tempdir : PDirectory;
|
||||||
begin
|
begin
|
||||||
|
push_trace('readfile');
|
||||||
bootRecord := readBootRecord(volume);
|
bootRecord := readBootRecord(volume);
|
||||||
directories := readDirectory(volume, directory, statusOut);
|
dirs := readDirectory(volume, directory, statusOut);
|
||||||
datastart:= volume^.sectorStart + 1 + bootRecord^.FATSize + bootRecord^.rsvSectors;
|
datastart:= volume^.sectorStart + 1 + bootRecord^.FATSize + bootRecord^.rsvSectors;
|
||||||
|
|
||||||
for i:=0 to LL_Size(directories) -1 do begin
|
if LL_size(dirs) > 0 then begin
|
||||||
dir:= PDirectory(LL_Get(directories, i));
|
cleanFileName := cleanString(filename, statusOut);
|
||||||
if (dir^.fileName = fileName) and (dir^.fileExtension = fileextension) then begin
|
|
||||||
|
for i:=0 to LL_Size(dirs) -1 do begin
|
||||||
|
tempdir := PDirectory(LL_get(dirs, i));
|
||||||
|
otherCleanFileName := cleanString(tempdir^.filename, statusout); //TODO clean extension
|
||||||
|
|
||||||
|
if compareByteArray8(cleanFileName, otherCleanFileName) then begin
|
||||||
|
dir:=tempdir;
|
||||||
exists := true;
|
exists := true;
|
||||||
break;
|
statusOut^ := 0;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if exists = false then begin
|
if exists = false then begin
|
||||||
statusOut^ := 0; //TODO use right error codes
|
statusOut^ := 1; //TODO use right error codes
|
||||||
exit(0);
|
exit(1);
|
||||||
end else begin
|
end else begin
|
||||||
cluster := dir^.clusterlow;
|
cluster := uint32(dir^.clusterlow) or uint32(dir^.clusterhigh shl 16);
|
||||||
cluster := cluster or dir^.clusterhigh shl 16;
|
|
||||||
clusters := getFatChain(volume, cluster, bootRecord);
|
clusters := getFatChain(volume, cluster, bootRecord);
|
||||||
noClusters := LL_size(clusters);
|
noClusters := LL_size(clusters);
|
||||||
|
|
||||||
data := puint32(kalloc(noClusters * bootRecord^.spc * bootRecord^.sectorSize));
|
data := puint32(kalloc(noClusters * bootRecord^.spc * bootRecord^.sectorSize + bootRecord^.sectorSize));
|
||||||
memset(uint32(data), 0, noClusters * bootRecord^.spc * bootRecord^.sectorSize);
|
if data = puint32(0) then begin
|
||||||
|
push_trace('UNABLE TO ALLOCATE MEMORY');
|
||||||
|
end;
|
||||||
|
memset(uint32(data), 0, noClusters * bootRecord^.spc * bootRecord^.sectorSize + bootRecord^.sectorSize);
|
||||||
|
|
||||||
readbuffer := puint32(kalloc(bootRecord^.sectorSize));
|
readbuffer := puint32(kalloc(bootRecord^.sectorSize * 2));
|
||||||
memset(uint32(readbuffer), 0, bootRecord^.sectorSize);
|
if readbuffer = puint32(0) then begin
|
||||||
|
push_trace('UNABLE TO ALLOCATE MEMORY');
|
||||||
|
end;
|
||||||
|
memset(uint32(readbuffer), 0, bootRecord^.sectorSize * 2);
|
||||||
|
|
||||||
for i:=0 to noClusters * bootRecord^.spc do begin
|
for i:=0 to noClusters * bootRecord^.spc do begin
|
||||||
volume^.device^.readcallback(volume^.device, dataStart + (cluster + i), 1, readbuffer);
|
volume^.device^.readcallback(volume^.device, dataStart + ((cluster * bootRecord^.spc)+ i), 1, readbuffer);
|
||||||
memcpy(uint32(readbuffer), uint32(@data[i*bootRecord^.sectorSize]), bootRecord^.sectorSize)
|
memcpy(uint32(readbuffer), uint32(@data[i*bootRecord^.sectorSize div 4]), bootRecord^.sectorSize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
kfree(readbuffer);
|
kfree(readbuffer);
|
||||||
buffer := data;
|
buffer^ := uint32(data);
|
||||||
readFile := noClusters * bootRecord^.spc * bootRecord^.sectorSize;
|
bytecount^ := noClusters * bootRecord^.spc * bootRecord^.sectorSize + bootRecord^.sectorSize;//maybe need to spc
|
||||||
|
readFile:= statusOut^;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -461,7 +461,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function readFile(fileName : pchar; extension : pchar; buffer : puint32; byteCount : puint32) : puint32; //TODO add length param
|
function readFile(fileName : pchar; extension : pchar; buffer : puint32; byteCount : puint32) : puint32;
|
||||||
var
|
var
|
||||||
error : puint32;
|
error : puint32;
|
||||||
dirs : PLinkedListBase;
|
dirs : PLinkedListBase;
|
||||||
@ -471,38 +471,36 @@ var
|
|||||||
otherCleanFileName : pchar;
|
otherCleanFileName : pchar;
|
||||||
begin
|
begin
|
||||||
push_trace('storagemanagement.readfile');
|
push_trace('storagemanagement.readfile');
|
||||||
bytecount := puint32(kalloc(4));
|
//bytecount := puint32(kalloc(4));
|
||||||
|
//memset(uint32(bytecount), 0, 4);
|
||||||
error := puint32(kalloc(4));
|
error := puint32(kalloc(4));
|
||||||
readfile:= error;
|
readfile:= error;
|
||||||
|
|
||||||
cleanFileName := cleanString(filename);
|
// cleanFileName := cleanString(filename);
|
||||||
|
|
||||||
dirs := rootVolume^.filesystem^.readdirCallback(rootVolume, getWorkingDirectory(), error);
|
// dirs := rootVolume^.filesystem^.readdirCallback(rootVolume, getWorkingDirectory(), error);
|
||||||
|
|
||||||
for i:=0 to LL_Size(dirs) -1 do begin
|
// for i:=0 to LL_Size(dirs) -1 do begin
|
||||||
otherCleanFileName := cleanString(PDirectory_Entry(LL_get(dirs, i))^.filename); //TODO clean extension
|
// otherCleanFileName := cleanString(PDirectory_Entry(LL_get(dirs, i))^.filename); //TODO clean extension
|
||||||
writestringlnWND(otherCleanFileName, getTerminalHWND());
|
// writestringlnWND(otherCleanFileName, getTerminalHWND());
|
||||||
writestringlnWND(cleanFileName, getTerminalHWND());
|
// writestringlnWND(cleanFileName, getTerminalHWND());
|
||||||
|
|
||||||
if stringEquals(cleanFileName, otherCleanFileName) then begin
|
// if stringEquals(cleanFileName, otherCleanFileName) then begin
|
||||||
writestringlnWND('match found!', getTerminalHWND());
|
// writestringlnWND('match found!', getTerminalHWND());
|
||||||
|
|
||||||
exists := true;
|
// exists := true;
|
||||||
error^ := 0;
|
// error^ := 0;
|
||||||
end;
|
// end;
|
||||||
|
|
||||||
kfree(puint32(otherCleanFileName));
|
// kfree(puint32(otherCleanFileName));
|
||||||
end;
|
// end;
|
||||||
|
|
||||||
kfree(puint32(cleanFileName));
|
// kfree(puint32(cleanFileName));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
error^ := rootVolume^.filesystem^.readCallback(rootVolume, getWorkingDirectory(), fileName, extension, buffer, bytecount);
|
||||||
|
|
||||||
if exists = false then begin
|
|
||||||
// TODO error codes
|
|
||||||
error^ := 1;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
rootVolume^.filesystem^.readCallback(rootVolume, getWorkingDirectory(), fileName, extension, buffer, bytecount);
|
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
end.
|
end.
|
Loading…
x
Reference in New Issue
Block a user