mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +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/File.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#if !defined(AK_OS_WINDOWS)
|
#if !defined(AK_OS_WINDOWS)
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#else
|
#else
|
||||||
# include <WinSock2.h>
|
# include <AK/Windows.h>
|
||||||
# define STDIN_FILENO _fileno(stdin)
|
|
||||||
# define STDOUT_FILENO _fileno(stdout)
|
|
||||||
# define STDERR_FILENO _fileno(stderr)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
|
@ -33,7 +33,11 @@
|
||||||
# include <utime.h>
|
# include <utime.h>
|
||||||
#else
|
#else
|
||||||
# include "SocketAddressWindows.h"
|
# include "SocketAddressWindows.h"
|
||||||
|
# include <io.h>
|
||||||
# define O_CLOEXEC O_NOINHERIT
|
# 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_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||||
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||||
using sighandler_t = void (*)(int);
|
using sighandler_t = void (*)(int);
|
||||||
|
|
|
@ -276,4 +276,9 @@ ErrorOr<void> set_close_on_exec(int handle, bool enabled)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<bool> isatty(int handle)
|
||||||
|
{
|
||||||
|
return GetFileType(to_handle(handle)) == FILE_TYPE_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue