Piotr Caban : msvcrt: Added support for commit flag in fopen.
Alexandre Julliard
julliard at winehq.org
Fri Jan 18 12:07:36 CST 2013
Module: wine
Branch: master
Commit: 7f4e1c65b1b5697ce7e9b4198e2f72997d1d44b5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7f4e1c65b1b5697ce7e9b4198e2f72997d1d44b5
Author: Piotr Caban <piotr at codeweavers.com>
Date: Fri Jan 18 11:03:13 2013 +0100
msvcrt: Added support for commit flag in fopen.
---
dlls/msvcrt/file.c | 67 +++++++++++++++++++++++++++++---------------------
dlls/msvcrt/msvcrt.h | 3 ++
2 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index dedfa30..0df6a86 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -764,6 +764,34 @@ int CDECL MSVCRT__wunlink(const MSVCRT_wchar_t *path)
return -1;
}
+/*********************************************************************
+ * _commit (MSVCRT.@)
+ */
+int CDECL MSVCRT__commit(int fd)
+{
+ HANDLE hand = msvcrt_fdtoh(fd);
+
+ TRACE(":fd (%d) handle (%p)\n",fd,hand);
+ if (hand == INVALID_HANDLE_VALUE)
+ return -1;
+
+ if (!FlushFileBuffers(hand))
+ {
+ if (GetLastError() == ERROR_INVALID_HANDLE)
+ {
+ /* FlushFileBuffers fails for console handles
+ * so we ignore this error.
+ */
+ return 0;
+ }
+ TRACE(":failed-last error (%d)\n",GetLastError());
+ msvcrt_set_errno(GetLastError());
+ return -1;
+ }
+ TRACE(":ok\n");
+ return 0;
+}
+
/* flush_all_buffers calls MSVCRT_fflush which calls flush_all_buffers */
int CDECL MSVCRT_fflush(MSVCRT_FILE* file);
@@ -811,6 +839,9 @@ int CDECL MSVCRT_fflush(MSVCRT_FILE* file)
MSVCRT__lock_file(file);
res = msvcrt_flush_buffer(file);
+
+ if(!res && (file->_flag & MSVCRT__IOCOMMIT))
+ res = MSVCRT__commit(file->_file) ? MSVCRT_EOF : 0;
MSVCRT__unlock_file(file);
return res;
@@ -852,34 +883,6 @@ int CDECL MSVCRT__close(int fd)
}
/*********************************************************************
- * _commit (MSVCRT.@)
- */
-int CDECL MSVCRT__commit(int fd)
-{
- HANDLE hand = msvcrt_fdtoh(fd);
-
- TRACE(":fd (%d) handle (%p)\n",fd,hand);
- if (hand == INVALID_HANDLE_VALUE)
- return -1;
-
- if (!FlushFileBuffers(hand))
- {
- if (GetLastError() == ERROR_INVALID_HANDLE)
- {
- /* FlushFileBuffers fails for console handles
- * so we ignore this error.
- */
- return 0;
- }
- TRACE(":failed-last error (%d)\n",GetLastError());
- msvcrt_set_errno(GetLastError());
- return -1;
- }
- TRACE(":ok\n");
- return 0;
-}
-
-/*********************************************************************
* _dup2 (MSVCRT.@)
* NOTES
* MSDN isn't clear on this point, but the remarks for _pipe
@@ -1284,6 +1287,8 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st
return -1;
}
+ *stream_flags |= MSVCRT__commode;
+
while (*mode && *mode!=',')
switch (*mode++)
{
@@ -1301,6 +1306,12 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st
case 'T':
*open_flags |= MSVCRT__O_SHORT_LIVED;
break;
+ case 'c':
+ *stream_flags |= MSVCRT__IOCOMMIT;
+ break;
+ case 'n':
+ *stream_flags &= ~MSVCRT__IOCOMMIT;
+ break;
case '+':
case ' ':
case 'a':
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 9b88d32..4915309 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -238,6 +238,8 @@ extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **) DECLSP
MSVCRT_wchar_t *msvcrt_wstrdupa(const char *) DECLSPEC_HIDDEN;
+extern unsigned int MSVCRT__commode;
+
/* FIXME: This should be declared in new.h but it's not an extern "C" so
* it would not be much use anyway. Even for Winelib applications.
*/
@@ -713,6 +715,7 @@ struct MSVCRT__stat64 {
#define MSVCRT__IOERR 0x0020
#define MSVCRT__IOSTRG 0x0040
#define MSVCRT__IORW 0x0080
+#define MSVCRT__IOCOMMIT 0x4000
#define MSVCRT__S_IEXEC 0x0040
#define MSVCRT__S_IWRITE 0x0080
More information about the wine-cvs
mailing list