Bladeren bron

SysInfo fixed small linux bugs

Exilon 5 jaren geleden
bovenliggende
commit
2e92c94716
2 gewijzigde bestanden met toevoegingen van 21 en 8 verwijderingen
  1. 19 6
      Quick.Commons.pas
  2. 2 2
      Quick.SysInfo.pas

+ 19 - 6
Quick.Commons.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.9
   Created     : 14/07/2017
-  Modified    : 10/11/2019
+  Modified    : 05/12/2019
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -851,9 +851,16 @@ function GetLoggedUserName : string;
     Result := GetEnvironmentVariable('USERNAME');
   end;
   {$ELSE}
+  var
+    plogin : PAnsiChar;
   begin
     {$IFDEF POSIX}
-    Result := string(getlogin);
+    try
+      plogin := getlogin;
+      Result := Copy(plogin,1,Length(Trim(plogin)));
+    except
+      Result := 'N/A';
+    end;
     {$ELSE}
     Result := 'N/A';
     {$ENDIF}
@@ -906,12 +913,18 @@ function GetComputerName : string;
     {$ELSE}
       {$IFDEF DELPHILINUX}
       var
-        puser : PAnsiChar;
+        phost : PAnsiChar;
       begin
-        //puser := '';
         try
-          if gethostname(puser,_SC_HOST_NAME_MAX) = 0 then Result := string(puser)
-            else Result := 'N/A';
+          if gethostname(phost,_SC_HOST_NAME_MAX) = 0 then
+          begin
+            {$IFDEF DEBUG}
+            Result := Copy(Trim(phost),1,Length(Trim(phost)));
+            {$ELSE}
+            Result := Copy(phost,1,Length(phost));
+            {$ENDIF}
+          end
+          else Result := 'N/A.';
         except
           Result := 'N/A';
         end;

+ 2 - 2
Quick.SysInfo.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.2
   Created     : 17/05/2018
-  Modified    : 14/09/2019
+  Modified    : 05/12/2019
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -109,7 +109,7 @@ begin
   fAppPath := TPath.GetDocumentsPath;
   {$ENDIf}
     {$IFDEF DELPHILINUX}
-    fUserName := String.Copy(GetLoggedUserName);
+    fUserName := GetLoggedUserName;
     {$ELSE}
     fUserName := Trim(GetLoggedUserName);
     {$ENDIF}