From 1bd3fca585b0088982e3d7fbfff43701db9fd01f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Jul 2019 14:25:45 +0200 Subject: [PATCH] AK: Shim open_with_path_length() for non-Serenity builds. This is pretty ugly but I don't want to *not* use open_with_path_length() so let's just shim it. --- AK/Platform.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AK/Platform.h b/AK/Platform.h index c75abaa69ac..bdf2512c8c7 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -24,4 +24,21 @@ #ifndef __serenity__ #define PAGE_SIZE sysconf(_SC_PAGESIZE) + +#include +#include +#include +#include +inline int open_with_path_length(const char* path, size_t path_length, int options, mode_t mode) +{ + auto* tmp = (char*)malloc(path_length + 1); + memcpy(tmp, path, path_length); + tmp[path_length] = '\0'; + int fd = open(tmp, options, mode); + int saved_errno = errno; + free(tmp); + errno = saved_errno; + return fd; +} #endif +