mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Support parsing of /etc/os-release (#804)
(cherry picked from commit 8b056faaa6)
This commit is contained in:
parent
217a1f1047
commit
9e2e2ee3d4
1 changed files with 34 additions and 5 deletions
|
|
@ -91,7 +91,7 @@ begin
|
|||
sl.LoadFromFile(FileName);
|
||||
Result := True;
|
||||
except
|
||||
on EFilerError do; // Bypass
|
||||
on EStreamError do sl.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -130,8 +130,8 @@ begin
|
|||
if Result <> EmptyStr then
|
||||
Result := TrimQuotes(Result)
|
||||
else
|
||||
Result := sl.Values['DISTRIB_ID'] +
|
||||
sl.Values['DISTRIB_RELEASE'] +
|
||||
Result := sl.Values['DISTRIB_ID'] + ' ' +
|
||||
sl.Values['DISTRIB_RELEASE'] + ' ' +
|
||||
sl.Values['DISTRIB_CODENAME'];
|
||||
end;
|
||||
finally
|
||||
|
|
@ -139,6 +139,31 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function GetOsFromOsRelease: String;
|
||||
var
|
||||
sl: TStringListEx;
|
||||
begin
|
||||
Result := EmptyStr;
|
||||
|
||||
if GetStringsFromFile('/etc/os-release', sl) then
|
||||
try
|
||||
if sl.Count > 0 then
|
||||
begin
|
||||
Result := sl.Values['PRETTY_NAME'];
|
||||
|
||||
if Result <> EmptyStr then
|
||||
Result := TrimQuotes(Result)
|
||||
else
|
||||
Result := sl.Values['NAME'] + ' ' +
|
||||
sl.Values['VERSION'] + ' ' +
|
||||
sl.Values['ID'];
|
||||
end;
|
||||
finally
|
||||
sl.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetOsFromProcVersion: String;
|
||||
var
|
||||
i: Integer;
|
||||
|
|
@ -446,11 +471,15 @@ begin
|
|||
OSVersion := GetMacOSXVersion;
|
||||
{$ENDIF}
|
||||
|
||||
// Try using linux systemd base.
|
||||
if OSVersion = EmptyStr then
|
||||
OSVersion := GetOsFromOsRelease;
|
||||
|
||||
// Other methods.
|
||||
if OSVersion = EmptyStr then
|
||||
OSVersion := GetOsFromIssue;
|
||||
if OSVersion = EmptyStr then
|
||||
OSVersion := GetOsFromProcVersion;
|
||||
if OSVersion = EmptyStr then
|
||||
OSVersion := GetOsFromIssue;
|
||||
|
||||
// Set default names.
|
||||
if OSVersion = EmptyStr then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue