LibCore: Port File to Windows

Co-authored-by: Cameron Youell <cameronyouell@gmail.com>
This commit is contained in:
stasoid 2024-10-20 07:51:54 +05:00 committed by Andrew Kaster
parent f6430035e7
commit 6b73a2d8a4
Notes: github-actions[bot] 2024-10-20 16:19:04 +00:00

View file

@ -8,7 +8,15 @@
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#if !defined(AK_OS_WINDOWS)
# include <unistd.h>
#else
# include <WinSock2.h>
# define STDIN_FILENO _fileno(stdin)
# define STDOUT_FILENO _fileno(stdout)
# define STDERR_FILENO _fileno(stderr)
#endif
namespace Core { namespace Core {
@ -85,8 +93,14 @@ int File::open_mode_to_options(OpenMode mode)
flags |= O_EXCL; flags |= O_EXCL;
if (!has_flag(mode, OpenMode::KeepOnExec)) if (!has_flag(mode, OpenMode::KeepOnExec))
flags |= O_CLOEXEC; flags |= O_CLOEXEC;
if (has_flag(mode, OpenMode::Nonblocking)) if (has_flag(mode, OpenMode::Nonblocking)) {
#if !defined(AK_OS_WINDOWS)
flags |= O_NONBLOCK; 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. // 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 // Certain applications may not want this privledge, and for compability reasons, this is