|
@@ -33,7 +33,40 @@ end;
|
|
|
|
|
|
|
|
|
procedure do_rename(p1,p2 : pchar; p1changeable, p2changeable: boolean);
|
|
|
+var
|
|
|
+ chanId: longint;
|
|
|
+ res: longint;
|
|
|
begin
|
|
|
+ { To rename a QL file, it must exist and be opened. For WIN/FLP this
|
|
|
+ means open mode 0 (Q_OPEN) but for RAM this can be any of Q_OPEN,
|
|
|
+ Q_OPEN_NEW or Q_OPEN_OVER. }
|
|
|
+
|
|
|
+ { Does the file exist? }
|
|
|
+ chanId := io_open(p1, Q_OPEN_IN);
|
|
|
+ if chanId < 0 then
|
|
|
+ begin
|
|
|
+ InOutRes:=2; { File not found. }
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+
|
|
|
+ { Close and reopen in correct mode. }
|
|
|
+ io_close(chanId);
|
|
|
+
|
|
|
+ chanId := io_open(p1, Q_OPEN);
|
|
|
+ if chanId < 0 then
|
|
|
+ begin
|
|
|
+ Error2InOutRes(chanId);
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+
|
|
|
+ { Now, finally, we can rename. }
|
|
|
+ res := fs_rename(chanId,p2);
|
|
|
+
|
|
|
+ { Close the file. Never errors out. }
|
|
|
+ io_close(chanId);
|
|
|
+
|
|
|
+ if res < 0 then
|
|
|
+ Error2InOutRes(res);
|
|
|
end;
|
|
|
|
|
|
|