mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibCore: Implement System::isatty on Windows
Also fixes a bug introduced in 642b7b6a5e
: Core::System functions
expect a handle now, so we have to use _get_osfhandle in STD*_FILENO.
This commit is contained in:
parent
1f8e7c3cca
commit
c55ba17d66
3 changed files with 10 additions and 5 deletions
|
@ -7,15 +7,11 @@
|
|||
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <fcntl.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)
|
||||
# include <AK/Windows.h>
|
||||
#endif
|
||||
|
||||
namespace Core {
|
||||
|
|
|
@ -33,7 +33,11 @@
|
|||
# include <utime.h>
|
||||
#else
|
||||
# include "SocketAddressWindows.h"
|
||||
# include <io.h>
|
||||
# define O_CLOEXEC O_NOINHERIT
|
||||
# define STDIN_FILENO _get_osfhandle(_fileno(stdin))
|
||||
# define STDOUT_FILENO _get_osfhandle(_fileno(stdout))
|
||||
# define STDERR_FILENO _get_osfhandle(_fileno(stderr))
|
||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||
using sighandler_t = void (*)(int);
|
||||
|
|
|
@ -276,4 +276,9 @@ ErrorOr<void> set_close_on_exec(int handle, bool enabled)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<bool> isatty(int handle)
|
||||
{
|
||||
return GetFileType(to_handle(handle)) == FILE_TYPE_CHAR;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue