Author: akhaldi
Date: Sat May 17 10:35:35 2014
New Revision: 63321
URL:
http://svn.reactos.org/svn/reactos?rev=63321&view=rev
Log:
[CRT]
* Import _chsize_s().
* Update _chsize().
CORE-8080
Modified:
trunk/reactos/lib/sdk/crt/stdio/file.c
Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?r…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Sat May 17 10:35:35 2014
@@ -1198,15 +1198,17 @@
}
/*********************************************************************
- * _chsize (MSVCRT.@)
- */
-int CDECL _chsize(int fd, long size)
-{
- LONG cur, pos;
+ * _chsize_s (MSVCRT.@)
+ */
+int CDECL _chsize_s(int fd, __int64 size)
+{
+ __int64 cur, pos;
HANDLE handle;
BOOL ret = FALSE;
- TRACE("(fd=%d, size=%d)\n", fd, size);
+ TRACE("(fd=%d, size=%s)\n", fd, wine_dbgstr_longlong(size));
+
+ if (!MSVCRT_CHECK_PMT(size >= 0)) return EINVAL;
LOCK_FILES();
@@ -1214,10 +1216,10 @@
if (handle != INVALID_HANDLE_VALUE)
{
/* save the current file pointer */
- cur = _lseek(fd, 0, SEEK_CUR);
+ cur = _lseeki64(fd, 0, SEEK_CUR);
if (cur >= 0)
{
- pos = _lseek(fd, size, SEEK_SET);
+ pos = _lseeki64(fd, size, SEEK_SET);
if (pos >= 0)
{
ret = SetEndOfFile(handle);
@@ -1225,12 +1227,21 @@
}
/* restore the file pointer */
- _lseek(fd, cur, SEEK_SET);
+ _lseeki64(fd, cur, SEEK_SET);
}
}
UNLOCK_FILES();
- return ret ? 0 : -1;
+ return ret ? 0 : *_errno();
+}
+
+/*********************************************************************
+ * _chsize (MSVCRT.@)
+ */
+int CDECL _chsize(int fd, long size)
+{
+ /* _chsize_s returns errno on failure but _chsize should return -1 */
+ return _chsize_s( fd, size ) == 0 ? 0 : -1;
}
/*********************************************************************