[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] Pascal-RTL: FirstFirst, FindNext, FindClose in sysutils



+ Pascal-RTL: FindFirst/Next/Close in sysutils sind jetzt nicht mehr nur
  Stubs, sondern Wrapper um die funktionsfaehigen Varianten aus dos.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/pas/lib/rtl/Makefile.all |    6 +++-
 src/modules/pas/lib/rtl/sysutils.pp  |   39 +++++++++++++++++++++++++++------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/modules/pas/lib/rtl/Makefile.all b/src/modules/pas/lib/rtl/Makefile.all
index 3694dad..87f73b3 100644
--- a/src/modules/pas/lib/rtl/Makefile.all
+++ b/src/modules/pas/lib/rtl/Makefile.all
@@ -9,12 +9,14 @@ echo 'PPC  objpas.pp' && \
 $LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/objpas.pp && \
 echo 'PPC  sysconst.pp' && \
 $LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/sysconst.pp && \
+echo 'PPC  dos.pp' && \
+$LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas ../dos/dos.pas && \
+echo 'PPC  sysutils.pp' && \
+$LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas sysutils.pp && \
 echo 'PPC  strutils.pp' && \
 $LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/strutils.pp && \
 echo 'PPC  math.pp' && \
 $LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/math.pp && \
-echo 'PPC  sysutils.pp' && \
-$LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas sysutils.pp && \
 echo 'PPC  rtlconsts.pp' && \
 $LOST_TOOLS_PPC -n  -Cn -CX -Ttyndur -Fu../units/ -FE../units/ -Iinclude/inc -Iinclude/i386 -Iinclude/objpas include/objpas/rtlconsts.pp && \
 echo 'PPC  types.pp' && \
diff --git a/src/modules/pas/lib/rtl/sysutils.pp b/src/modules/pas/lib/rtl/sysutils.pp
index 8009993..0a89d14 100644
--- a/src/modules/pas/lib/rtl/sysutils.pp
+++ b/src/modules/pas/lib/rtl/sysutils.pp
@@ -30,7 +30,7 @@ function IsLeapYear(year: word): boolean;
 {$I include/objpas/sysutils/sysutilh.inc}
 
 implementation
-uses sysconst;
+uses sysconst, dos;
 
 {$I include/objpas/sysutils/sysutils.inc}
 
@@ -277,19 +277,44 @@ begin
 end;
 
 function FindFirst(const path: AnsiString; attr: LongInt;out rslt: TSearchRec):LongInt;
+var
+    f: ^SearchRec;
 begin
-    Result := 0; // FIXME
-end;    
+    New(f);
+    rslt.FindHandle := THandle(f);
+    dos.FindFirst(path, attr, f^);
+
+    rslt.name := f^.name;
+    rslt.size := f^.size;
+    rslt.attr := f^.attr;
+    rslt.time := f^.time;
+
+    exit(DosError);
+end;
 
 function FindNext(var rslt: TSearchRec):LongInt;
+var
+    f: ^SearchRec;
 begin
-    Result := 0; // FIXME
-end;    
+    f := Pointer(rslt.FindHandle);
+    dos.FindNext(f^);
+
+    rslt.name := f^.name;
+    rslt.size := f^.size;
+    rslt.attr := f^.attr;
+    rslt.time := f^.time;
+
+    exit(DosError);
+end;
 
 procedure FindClose(var f: TSearchRec);
+var
+    srec: ^SearchRec;
 begin
-    // FIXME
-end;    
+    srec := Pointer(f.FindHandle);
+    dos.FindClose(srec^);
+    Dispose(srec);
+end;
 
 function FileGetDate(handle: LongInt):LongInt;
 begin
-- 
1.6.0.2