Get latest upstream changes from internal project
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <dirent.h> // readdir, opendir, closedir
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h> // realpath
|
||||
#include <unistd.h> // sysconf, readlink
|
||||
|
||||
// NOTE: DN_OSMem
|
||||
static DN_U32 DN_OS_MemConvertPageToOSFlags_(DN_U32 protect)
|
||||
@@ -241,6 +243,23 @@ DN_API DN_OSDiskSpace DN_OS_DiskSpace(DN_Str8 path)
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_API DN_OSMemoryInfo DN_OS_MemoryInfo()
|
||||
{
|
||||
DN_OSMemoryInfo result = {};
|
||||
#if defined(DN_PLATFORM_POSIX)
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
long pages = sysconf(_SC_PHYS_PAGES);
|
||||
long avail_pages = sysconf(_SC_AVPHYS_PAGES);
|
||||
if (page_size > 0 && pages > 0) {
|
||||
result.success = true;
|
||||
result.total_phys = DN_Cast(DN_U64) pages * DN_Cast(DN_U64) page_size;
|
||||
if (avail_pages > 0)
|
||||
result.avail_phys = DN_Cast(DN_U64) avail_pages * DN_Cast(DN_U64) page_size;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_API DN_Str8 DN_OS_ExePath(DN_Arena *arena)
|
||||
{
|
||||
DN_Str8 result = {};
|
||||
@@ -597,6 +616,23 @@ DN_API bool DN_OS_PathDelete(DN_Str8 path)
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_API DN_OSPathResult DN_OS_PathCanonicalise(DN_Arena *arena, DN_Str8 path, DN_ErrSink *error)
|
||||
{
|
||||
DN_OSPathResult result = {};
|
||||
DN_TcScratch scratch = DN_TcScratchBeginArena(&arena, 1);
|
||||
DN_Str8 path_cstr = DN_Str8FromStr8Arena(path, &scratch.arena); // Ensure null-terminated
|
||||
char *resolved = realpath(path_cstr.data, NULL);
|
||||
if (resolved != NULL) {
|
||||
result.success = true;
|
||||
result.path = DN_Str8FromCStr8Arena(resolved, arena);
|
||||
free(resolved); // realpath allocates with malloc
|
||||
} else {
|
||||
DN_ErrSinkAppendF(error, errno, "Failed to canonicalise path: %s", strerror(errno));
|
||||
}
|
||||
DN_TcScratchEnd(&scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
DN_API bool DN_OS_PathIsFile(DN_Str8 path)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -1277,14 +1313,20 @@ DN_API void DN_OS_ConditionVariableBroadcast(DN_OSConditionVariable *cv)
|
||||
DN_API DN_OSWindowMinimise DN_OS_WindowIsMinimised(DN_OSWindow *window)
|
||||
{
|
||||
(void)window;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
return DN_OSWindowMinimise_No;
|
||||
}
|
||||
|
||||
DN_API DN_OSWindowMaximise DN_OS_WindowIsMaximised(DN_OSWindow *window)
|
||||
{
|
||||
(void)window;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
return DN_OSWindowMaximise_No;
|
||||
}
|
||||
|
||||
@@ -1292,32 +1334,47 @@ DN_API void DN_OS_WindowSetTitle(DN_OSWindow *window, DN_Str8 title)
|
||||
{
|
||||
(void)window;
|
||||
(void)title;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
}
|
||||
|
||||
DN_API void DN_OS_WindowShow(DN_OSWindow *window, DN_OSWindowShow show)
|
||||
{
|
||||
(void)window;
|
||||
(void)show;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
}
|
||||
|
||||
DN_API void DN_OS_WindowBringToFront(DN_OSWindow *window)
|
||||
{
|
||||
(void)window;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
}
|
||||
|
||||
DN_API void DN_OS_WindowFocus(DN_OSWindow *window)
|
||||
{
|
||||
(void)window;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
}
|
||||
|
||||
DN_API bool DN_OS_WindowIsFocused(DN_OSWindow *window)
|
||||
{
|
||||
(void)window;
|
||||
#if defined(DN_PLATFORM_EMSCRIPTEN)
|
||||
#else
|
||||
DN_AssertInvalidCodePath;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user