[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH v2] Pascal-RTL: Short Writes berücksichtigen
! Pascal-RTL: Do_Write muss die übergebenen Daten komplett schreiben,
fwrite kann allerdings Short Writes zurückgeben.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/modules/pas/lib/rtl/sysfile.inc | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/modules/pas/lib/rtl/sysfile.inc b/src/modules/pas/lib/rtl/sysfile.inc
index 5143ef8..e73fa5d 100644
--- a/src/modules/pas/lib/rtl/sysfile.inc
+++ b/src/modules/pas/lib/rtl/sysfile.inc
@@ -36,8 +36,21 @@ begin { TODO } end;
Function Do_Write(f: THandle; src: Pointer; len: TSize): TSize;
-begin
- Do_Write := c_fwrite(src, 1, len, f);
+var
+ ret: TSize;
+begin
+ Do_Write := 0;
+ while len > 0 do begin
+ ret := c_fwrite(src, 1, len, f);
+ if (ret = 0) or (ret > len) then begin
+ InOutRes := 101;
+ exit(0);
+ end;
+
+ Inc(Do_Write, ret);
+ Inc(src, ret);
+ Dec(len, ret);
+ end;
end;
Function Do_Read(f: THandle; dest: Pointer; len: TSize): TSize;
--
1.6.0.2