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 +