summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-09 04:34:38 +0000
committerkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-09 04:34:38 +0000
commit5119192e2e28a273d49b6993e27ad34debae482a (patch)
treedb96777161187df666f7bb3a0348f83e6f9fc411
parenta026f14f322e02cce99a65389b1f5b3f6e6cf127 (diff)
downloadfpc-5119192e2e28a273d49b6993e27ad34debae482a.tar.gz
sinclairql: various file and directory handling improvements, based on patch by Norman Dunbar
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49149 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/sinclairql/sysdir.inc7
-rw-r--r--rtl/sinclairql/sysfile.inc19
2 files changed, 19 insertions, 7 deletions
diff --git a/rtl/sinclairql/sysdir.inc b/rtl/sinclairql/sysdir.inc
index e7661d7269..050416ab8a 100644
--- a/rtl/sinclairql/sysdir.inc
+++ b/rtl/sinclairql/sysdir.inc
@@ -24,6 +24,13 @@ end;
procedure do_rmdir(const s : rawbytestring);
begin
+ { Deleting a directory is as simple as deleting
+ a file. There must be no files in the directory
+ though. However, SMSQ seems to return zero for a file
+ or directory name that is not present. It should return
+ ERR_NF. (At least on RAM_/FLP_ or WIN_)
+ }
+ Error2InOutRes(io_delet(pchar(s)));
end;
diff --git a/rtl/sinclairql/sysfile.inc b/rtl/sinclairql/sysfile.inc
index 0d97debba7..1b87cac0ca 100644
--- a/rtl/sinclairql/sysfile.inc
+++ b/rtl/sinclairql/sysfile.inc
@@ -25,9 +25,10 @@ begin
Error2InOutRes(io_close(handle));
end;
-
+{ delete a file, given its name }
procedure do_erase(p : pchar; pchangeable: boolean);
begin
+ Error2InOutRes(io_delet(p));
end;
@@ -68,7 +69,7 @@ var
begin
do_filepos := 0;
res := fs_posre(handle, 0);
- if res < 0 then
+ if (res < 0) and (res <> ERR_EF) then
Error2InOutRes(res)
else
do_filepos := res;
@@ -80,14 +81,20 @@ var
res: longint;
begin
res := fs_posab(handle, pos);
- if res < 0 then
+ if (res < 0) and (res <> ERR_EF) then
Error2InOutRes(res);
end;
+{ The maximum length of a QL file is 2^31 - 64 bytes ($7FFFFFC0)
+ so the maximum offset is that, minus 1. ($7fffffBF) }
+
+const
+ MAX_QL_FILE_LENGTH = $7FFFFFBF;
+
function do_seekend(handle: longint): longint;
begin
- do_seek(handle, -1);
+ do_seek(handle, MAX_QL_FILE_LENGTH);
do_seekend := do_filepos(handle);
end;
@@ -168,9 +175,7 @@ begin
end;
{ rewrite (create a new file) }
- { FIX ME: this will just create a new file, actual overwriting
- seems to be a more complex endeavor... }
- if (flags and $1000)<>0 then openMode:=Q_OPEN_NEW;
+ if (flags and $1000)<>0 then openMode:=Q_OPEN_OVER;
res:=io_open(p,openMode);