From 6b73a2d8a49d94b017b4d4e9b9727ed2fb3c07ab Mon Sep 17 00:00:00 2001 From: stasoid Date: Sun, 20 Oct 2024 07:51:54 +0500 Subject: [PATCH] LibCore: Port `File` to Windows Co-authored-by: Cameron Youell --- Userland/Libraries/LibCore/File.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 9baaf7f6e28..27f36fdd401 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -8,7 +8,15 @@ #include #include #include -#include + +#if !defined(AK_OS_WINDOWS) +# include +#else +# include +# define STDIN_FILENO _fileno(stdin) +# define STDOUT_FILENO _fileno(stdout) +# define STDERR_FILENO _fileno(stderr) +#endif namespace Core { @@ -85,8 +93,14 @@ int File::open_mode_to_options(OpenMode mode) flags |= O_EXCL; if (!has_flag(mode, OpenMode::KeepOnExec)) flags |= O_CLOEXEC; - if (has_flag(mode, OpenMode::Nonblocking)) + if (has_flag(mode, OpenMode::Nonblocking)) { +#if !defined(AK_OS_WINDOWS) flags |= O_NONBLOCK; +#else + dbgln("Core::File::OpenMode::Nonblocking is not implemented"); + VERIFY_NOT_REACHED(); +#endif + } // Some open modes, like `ReadWrite` imply the ability to create the file if it doesn't exist. // Certain applications may not want this privledge, and for compability reasons, this is