Compare commits
No commits in common. "f18176e3fae0d516a5591a48e0045ce5cb74d16d" and "347b57cae3a13c48bafb421fc52249b9ca5b3cec" have entirely different histories.
f18176e3fa
...
347b57cae3
4 changed files with 7 additions and 50 deletions
|
|
@ -47,7 +47,7 @@ type file = record
|
||||||
ateof:boolean;
|
ateof:boolean;
|
||||||
noecho:boolean; (* read chars are not echoed *)
|
noecho:boolean; (* read chars are not echoed *)
|
||||||
raw:boolean; (* turn off backspace processing on input, CR processing on output *)
|
raw:boolean; (* turn off backspace processing on input, CR processing on output *)
|
||||||
nointr:boolean); (* turn off keyboard interrupt character processing *)
|
nointr: boolean); (* turn off keyboard interrupt character processing *)
|
||||||
|
|
||||||
IODiskFile: (volumeid: integer;fileno: integer; filpos:integer; bufStart:integer;
|
IODiskFile: (volumeid: integer;fileno: integer; filpos:integer; bufStart:integer;
|
||||||
size:integer; sizeExtents:integer;
|
size:integer; sizeExtents:integer;
|
||||||
|
|
@ -480,9 +480,6 @@ end;
|
||||||
That means you cannot use pos to search inside a string
|
That means you cannot use pos to search inside a string
|
||||||
literal. Hopefully this is not something you want to do.
|
literal. Hopefully this is not something you want to do.
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(* TODO: UCSD-Pascal and TP3.0 specs say, searched string
|
|
||||||
is a string expression so cannot be var parameter *)
|
|
||||||
function pos(substr:string;var s:string):integer;
|
function pos(substr:string;var s:string):integer;
|
||||||
var substrlen:integer;
|
var substrlen:integer;
|
||||||
slen:integer;
|
slen:integer;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
(* Copyright 2021-2024 Sebastian Lederer. See the file LICENSE.md for details *)
|
(* Copyright 2021-2024 Sebastian Lederer. See the file LICENSE.md for details *)
|
||||||
{$H384}
|
|
||||||
{$S64}
|
|
||||||
program PascalCompiler;
|
program PascalCompiler;
|
||||||
{$R+}
|
{$R+}
|
||||||
{$!}{$ifdef FPC}uses math,crt;{$endif}
|
{$!}{$ifdef FPC}uses math,crt;{$endif}
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,7 @@ end;
|
||||||
procedure getScreenSize;
|
procedure getScreenSize;
|
||||||
var c:char;
|
var c:char;
|
||||||
begin
|
begin
|
||||||
(* empty keyboard buffer to make sure GetTermSize
|
(* empty keyboard buffer *)
|
||||||
can read the response from the terminal *)
|
|
||||||
while conavail do read(con, c);
|
while conavail do read(con, c);
|
||||||
|
|
||||||
GetTermSize(screenW, screenH);
|
GetTermSize(screenW, screenH);
|
||||||
|
|
@ -1662,10 +1661,11 @@ end;
|
||||||
|
|
||||||
procedure gotoLine(l:integer);
|
procedure gotoLine(l:integer);
|
||||||
begin
|
begin
|
||||||
|
if l < 1 then
|
||||||
|
l := 1
|
||||||
|
else
|
||||||
if l > lineCount then
|
if l > lineCount then
|
||||||
l := lineCount;
|
l := lineCount;
|
||||||
if l < 1 then
|
|
||||||
l := 1;
|
|
||||||
|
|
||||||
topY := l - (screenH div 2);
|
topY := l - (screenH div 2);
|
||||||
if topY < 1 then
|
if topY < 1 then
|
||||||
|
|
@ -1713,7 +1713,7 @@ var error:integer;
|
||||||
begin
|
begin
|
||||||
success := true;
|
success := true;
|
||||||
if isModified then
|
if isModified then
|
||||||
writeFile(success);
|
save;
|
||||||
if success then
|
if success then
|
||||||
begin
|
begin
|
||||||
if isAsmFile(filename) then
|
if isAsmFile(filename) then
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ def listvolumes(img):
|
||||||
return firstvolume
|
return firstvolume
|
||||||
|
|
||||||
|
|
||||||
def listdir(img, part, verbose=False, deleted=False):
|
def listdir(img, part, verbose=False):
|
||||||
print("Directory of {}:".format(part.name))
|
print("Directory of {}:".format(part.name))
|
||||||
slotno = 0
|
slotno = 0
|
||||||
done = False
|
done = False
|
||||||
|
|
@ -247,8 +247,6 @@ def listdir(img, part, verbose=False, deleted=False):
|
||||||
slot = getdirslot(img, part, slotno)
|
slot = getdirslot(img, part, slotno)
|
||||||
if (slot.flags & SlotFirst):
|
if (slot.flags & SlotFirst):
|
||||||
print(slot.name, slot.sizeBytes, slotno)
|
print(slot.name, slot.sizeBytes, slotno)
|
||||||
elif deleted and (slot.flags & SlotDeleted):
|
|
||||||
print(slot.name, slot.sizeBytes, slotno, slot.generation)
|
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print(flags2str(slot.flags))
|
print(flags2str(slot.flags))
|
||||||
|
|
@ -274,21 +272,6 @@ def findfile(img, part, name):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def finddeleted(img, part, name, gen):
|
|
||||||
slotno = 0
|
|
||||||
done = False
|
|
||||||
while not done:
|
|
||||||
slot = getdirslot(img, part, slotno)
|
|
||||||
if slot.flags & SlotDeleted:
|
|
||||||
if slot.name == name and slot.generation == gen:
|
|
||||||
return slotno
|
|
||||||
slotno += 1
|
|
||||||
if (slot.flags & SlotEndScan) or (slotno >= part.dirSize):
|
|
||||||
done = True
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def readfile(img, part, slotno):
|
def readfile(img, part, slotno):
|
||||||
pos = part.startBlock * 512 + slotno * part.extentSize
|
pos = part.startBlock * 512 + slotno * part.extentSize
|
||||||
dirslot = getdirslot(img, part, slotno)
|
dirslot = getdirslot(img, part, slotno)
|
||||||
|
|
@ -334,24 +317,6 @@ def readfromimg(img, pathname,outfilepath):
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
def recoverfromimg(img, pathname, gen, outfilepath):
|
|
||||||
vol, filename = parsepath(img, pathname)
|
|
||||||
if vol is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
listdir(img, vol, deleted=True)
|
|
||||||
|
|
||||||
slotno = finddeleted(img, vol, filename, gen)
|
|
||||||
if slotno is None:
|
|
||||||
print("File", filename,"not found with generation no", gen)
|
|
||||||
return
|
|
||||||
|
|
||||||
data = readfile(img, vol, slotno)
|
|
||||||
|
|
||||||
with open(outfilepath, "wb") as f:
|
|
||||||
f.write(data)
|
|
||||||
|
|
||||||
|
|
||||||
def writetoimg(img, pathname, infilepath):
|
def writetoimg(img, pathname, infilepath):
|
||||||
vol, filename = parsepath(img, pathname)
|
vol, filename = parsepath(img, pathname)
|
||||||
if vol is None:
|
if vol is None:
|
||||||
|
|
@ -590,9 +555,6 @@ if __name__ == "__main__":
|
||||||
if sys.argv[1] == "get":
|
if sys.argv[1] == "get":
|
||||||
f = open(sys.argv[2], "rb")
|
f = open(sys.argv[2], "rb")
|
||||||
readfromimg(f, sys.argv[3], sys.argv[4])
|
readfromimg(f, sys.argv[3], sys.argv[4])
|
||||||
elif sys.argv[1] == "recover":
|
|
||||||
f = open(sys.argv[2], "rb")
|
|
||||||
recoverfromimg(f, sys.argv[3], int(sys.argv[4]), sys.argv[5])
|
|
||||||
elif sys.argv[1] == "put":
|
elif sys.argv[1] == "put":
|
||||||
imgfile = open(sys.argv[2], "r+b")
|
imgfile = open(sys.argv[2], "r+b")
|
||||||
infilepath = sys.argv[3]
|
infilepath = sys.argv[3]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue