2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/msvcrt/io/write.c
5 * PURPOSE: Writes to a file
6 * PROGRAMER: Boudewijn Dekker
11 #include <msvcrt/io.h>
12 #include <msvcrt/internal/file.h>
15 #include <msvcrt/msvcrtdbg.h>
19 size_t _write(int _fd, const void *_buf, size_t _nbyte)
25 DPRINT("_write(fd %d, buf %x, nbyte %d)\n", _fd, _buf, _nbyte);
26 if (__fileno_getmode(_fd) & O_TEXT)
29 tmp = (char*) malloc(BUFSIZE);
45 if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE, &wbyte, NULL))
52 result = in - (char*)_buf;
61 if (count == 0 || _nbyte == 0)
63 if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL))
68 if (wbyte < BUFSIZE - count)
70 result = in - (char*)_buf;
82 if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL))