Browse Source

+ Implemented RaiseLastOSError

michael 21 years ago
parent
commit
e31cf3e728
2 changed files with 30 additions and 1 deletions
  1. 8 1
      rtl/objpas/sysutils/osutilsh.inc
  2. 22 0
      rtl/objpas/sysutils/sysutils.inc

+ 8 - 1
rtl/objpas/sysutils/osutilsh.inc

@@ -15,6 +15,10 @@
 
 { OS handling utilities }
 
+{$ifdef HAS_OSERROR}
+Function GetLastOSError : Integer; 
+{$endif}
+Procedure RaiseLastOSError;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 {$IFDEF HAS_SLEEP}
 procedure Sleep(milliseconds: Cardinal);
@@ -23,7 +27,10 @@ function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integ
 
 {
   $Log$
-  Revision 1.4  2004-01-10 17:34:36  michael
+  Revision 1.5  2004-02-08 11:02:40  michael
+  + Implemented RaiseLastOSError
+
+  Revision 1.4  2004/01/10 17:34:36  michael
   + Implemented sleep() on Unix.
 
   Revision 1.3  2004/01/05 22:37:24  florian

+ 22 - 0
rtl/objpas/sysutils/sysutils.inc

@@ -248,7 +248,29 @@ begin
 {$endif VER1_0}
 end;
 
+{$IFDEF HAS_OSERROR}
+Procedure RaiseLastOSError;
 
+var
+  ECode: Cardinal;
+  E : EOSError;
+  
+begin
+  ECode := GetLastOSError;
+  If (ECode<>0) then
+    E:=EOSError.CreateFmt(SOSError, [ECode, SysErrorMessage(ECode)])
+  else
+    E:=EOSError.Create(SUnkOSError);
+  E.ErrorCode:=ECode;
+  Raise E;
+end;
+{$else}
+Procedure RaiseLastOSError;
+
+begin
+  Raise Exception.Create('RaiseLastOSError not implemented on this platform.');
+end;
+{$endif}
 Procedure AssertErrorHandler (Const Msg,FN : ShortString;LineNo:longint; TheAddr : pointer);
 Var
   S : String;