diff --git a/osx.c b/osx.c index c3c24de..d3f7723 100644 --- a/osx.c +++ b/osx.c @@ -84,6 +84,7 @@ static int truncate(const char *path, __int64 size) } #define ftruncate(fd, size) _chsize_s(fd, size) +#define isatty(fd) _isatty(fd) #define fsync(fd) _commit(fd) static int flocking(FILE *fh, int mode, __int64 ofs, __int64 len) @@ -801,6 +802,15 @@ static int os_fadvise(lua_State *L) return os_result(L, ec, NULL); } +static int os_isatty(lua_State *L) +{ + luaL_Stream *stream = luaL_checkudata(L, 1, LUA_FILEHANDLE); + + int ec = isatty(fileno(stream->f)); + lua_pushboolean(L, ec != 0); + return 1; +} + /** * Commit any pending write to disk. * @@ -935,6 +945,7 @@ DF_OSXMOD_API int luaopen_osx(lua_State *L) { "setmode", os_setmode }, { "chsize", os_chsize }, { "fadvise", os_fadvise }, + { "isatty", os_isatty }, { "commit", os_commit }, { "locking", os_locking }, { NULL, NULL }