hedgewars/uUtils.pas
changeset 11775 68f26b6a3a7d
parent 11748 eefa04b23c3b
child 11780 ee85798d6974
--- a/hedgewars/uUtils.pas	Fri Apr 29 00:56:04 2016 +0200
+++ b/hedgewars/uUtils.pas	Fri Apr 29 12:11:19 2016 +0200
@@ -70,6 +70,8 @@
 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
 
+function read1stLn(filePath: shortstring): shortstring;
+
 {$IFNDEF PAS2C}
 procedure Write(var f: textfile; s: shortstring);
 procedure WriteLn(var f: textfile; s: shortstring);
@@ -95,7 +97,7 @@
 
 
 implementation
-uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils, uPhysFSLayer;
+uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils, uPhysFSLayer, uDebug;
 
 {$IFDEF DEBUGFILE}
 var logFile: PFSFile;
@@ -511,6 +513,20 @@
     sanitizeCharForLog:= r
 end;
 
+function read1stLn(filePath: shortstring): shortstring;
+var f: pfsFile;
+begin
+    read1stLn:= '';
+    if pfsExists(filePath) then
+        begin
+        f:= pfsOpenRead(filePath);
+        if (not pfsEOF(f)) and allOK then
+            pfsReadLn(f, read1stLn);
+        pfsClose(f);
+        f:= nil;
+        end;
+end;
+
 procedure initModule(isNotPreview: boolean);
 {$IFDEF DEBUGFILE}
 var logfileBase: shortstring;