-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from matyalatte/add_os_functions
Add GetOSVersion(), GetOSProductName(), GetRealPath(), and PathExists()
- Loading branch information
Showing
13 changed files
with
684 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ docs/latex | |
# coverage report | ||
coverage-report | ||
*.log | ||
|
||
# vscode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Examples of Return Values | ||
|
||
## envuGetOS* functions | ||
|
||
Examples of return values for envuGetOS(), envuGetOSVersion(), and envuGetOSProductName(). | ||
|
||
| OS | Version | Product Name | | ||
| -- | -- | -- | | ||
| Darwin | 19.5.0 | Mac OS X 10.15.5 | | ||
| Windows | 10.0.19045 | Microsoft Windows 10 Home | | ||
| Linux | 5.15.0 | Ubuntu 20.04.6 LTS | | ||
| Linux | 6.1.92 | Alpine Linux v3.18 | | ||
| FreeBSD | 14.0 | FreeBSD 14.0 | | ||
| NetBSD | 9.3 | NetBSD 9.3 | | ||
| OpenBSD | 7.4 | OpenBSD 7.4 | | ||
| SunOS | 5.11 | OpenIndiana Hipster 2024.04 | | ||
| Haiku | 1 | Haiku R1/beta4 | | ||
|
||
## envuGetFullPath | ||
|
||
Examples of input paths and return values for envuGetFullPath() | ||
|
||
### Windows | ||
|
||
| Input | Return | | ||
| -- | -- | | ||
| "C:\usr\lib\." | "C:\usr\lib" | | ||
| "C:\usr\lib\.." | "C:\usr" | | ||
| "C:\usr\.\lib" | "C:\usr\lib" | | ||
| "C:\usr\..\lib" | "C:\lib" | | ||
| "C:\." | "C:\" | | ||
| "C:\.." | "C:\" | | ||
| "C:\usr\lib\" | "C:\usr\lib" | | ||
| "usr" | "C:\path\to\cwd\usr" | | ||
| "." | "C:\path\to\cwd" | | ||
| "" | "C:\path\to\cwd" | | ||
| NULL | NULL | | ||
|
||
### Linux/Unix | ||
|
||
| Input | Return | | ||
| -- | -- | | ||
| "/usr/lib" | "/usr/lib" | | ||
| "/usr/lib" | "/usr" | | ||
| "/usr/./lib" | "/usr/lib" | | ||
| "/usr/../lib" | "/lib" | | ||
| "/." | "/" | | ||
| "/.." | "/" | | ||
| "/usr/lib/" | "/usr/lib" | | ||
| "usr" | "/path/to/cwd/usr" | | ||
| "." | "/path/to/cwd" | | ||
| "" | "/path/to/cwd" | | ||
| NULL | NULL | | ||
|
||
## envuGetDirectory | ||
|
||
Examples of input paths and return values for envuGetDirecotry() | ||
|
||
| Input | Return | | ||
| -- | -- | | ||
| "/usr/lib" | "/usr" | | ||
| "/usr/" | "/" | | ||
| "usr" | "." | | ||
| "usr/" | "." | | ||
| "/" | "/" | | ||
| "." | "." | | ||
| ".." | "." | | ||
| "" | "." | | ||
| NULL | NULL | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <kernel/image.h> | ||
#include <String.h> | ||
#include <Path.h> | ||
#include <FindDirectory.h> | ||
#include <AppFileInfo.h> | ||
#include "env_utils_priv.h" | ||
|
||
// Use a method from SysInfoView::_GetABIVersion | ||
// https://cgit.haiku-os.org/haiku/tree/src/apps/aboutsystem/AboutSystem.cpp | ||
char *getOSVersionHaiku() { | ||
BString abiVersion; | ||
|
||
// the version is stored in the BEOS:APP_VERSION attribute of libbe.so | ||
BPath path; | ||
if (find_directory(B_BEOS_LIB_DIRECTORY, &path) == B_OK) { | ||
path.Append("libbe.so"); | ||
|
||
BAppFileInfo appFileInfo; | ||
version_info versionInfo; | ||
BFile file; | ||
if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK | ||
&& appFileInfo.SetTo(&file) == B_OK | ||
&& appFileInfo.GetVersionInfo(&versionInfo, | ||
B_APP_VERSION_KIND) == B_OK | ||
&& versionInfo.short_info[0] != '\0') | ||
abiVersion = versionInfo.short_info; | ||
} | ||
|
||
if (abiVersion.IsEmpty()) | ||
abiVersion = "Unknown"; | ||
|
||
return AllocStrWithConst(abiVersion.String()); | ||
} |
Oops, something went wrong.