From 45d5ae74c086b621a0f415ff9c34a1f6989d5221 Mon Sep 17 00:00:00 2001 From: Robert van Herk Date: Fri, 24 Feb 2012 22:09:39 +0100 Subject: Committer: Robert van Herk modified: dlls/msvcrt/file.c modified: dlls/msvcrt/tests/Makefile.in new file: dlls/msvcrt/tests/filemodeT.c Windows fopen has some fancy file modes 'T' and 'D'. Currently, wine wrongly interprets 'T' as 't'. They should be interpreted differently though: 't' is text file, and 'T' is temporary file. I've fixed this, and added a conformance test. --- dlls/msvcrt/file.c | 8 +++++- dlls/msvcrt/tests/Makefile.in | 1 + dlls/msvcrt/tests/filemodeT.c | 61 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletions(-) create mode 100644 dlls/msvcrt/tests/filemodeT.c diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index c15e33f..2933996 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1268,10 +1268,16 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st *open_flags |= MSVCRT__O_BINARY; *open_flags &= ~MSVCRT__O_TEXT; break; - case 'T': case 't': + case 't': *open_flags |= MSVCRT__O_TEXT; *open_flags &= ~MSVCRT__O_BINARY; break; + case 'D': + FIXME("Implement D flag (temporary file, i.e. delete on close)"); + break; + case 'T': + FIXME("Implement T flag (temporary file, i.e. delete on close, don't flush to disk if possible)"); + break; case '+': case ' ': break; diff --git a/dlls/msvcrt/tests/Makefile.in b/dlls/msvcrt/tests/Makefile.in index 2bb7990..84f500a 100644 --- a/dlls/msvcrt/tests/Makefile.in +++ b/dlls/msvcrt/tests/Makefile.in @@ -9,6 +9,7 @@ C_SRCS = \ dir.c \ environ.c \ file.c \ + filemodeT.c \ headers.c \ heap.c \ locale.c \ diff --git a/dlls/msvcrt/tests/filemodeT.c b/dlls/msvcrt/tests/filemodeT.c new file mode 100644 index 0000000..345dc39 --- /dev/null +++ b/dlls/msvcrt/tests/filemodeT.c @@ -0,0 +1,61 @@ +/* Conformance test for file mode T (temporary file). + * + * See http://msdn.microsoft.com/en-us/library/yeby3zcb%28v=vs.80%29.aspx + * + * 'T' means something else than 't': + * T = temporary + * t = translated mode + * + * Copyright 2012 Robert van Herk + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include + +START_TEST(filemodeT) +{ + char DATA [] = {26, 't', 'e', 's' ,'t'}; + char DATA2 [100]; + LPSTR temppath; + LPSTR tempfile; + FILE* f; + + temppath = malloc(MAX_PATH); + assert (GetTempPath (MAX_PATH, temppath)); + tempfile = malloc(MAX_PATH); + assert ( + GetTempFileName ( + temppath, + "", + 0, + tempfile + ) + ); + + f = fopen(tempfile, "w+bT"); + size_t bytesWritten = fwrite(DATA, 1, sizeof(DATA), f); + rewind(f); + size_t bytesRead = fread(f, 1, sizeof(DATA2), f); + fclose(f); + + ok (bytesRead == bytesWritten && bytesRead == sizeof(DATA), + "fopen file mode 'T' wrongly interpreted as 't'! Right interpretation is:\n\t'T' -> temporary\n\t't' -> translated.\n" + ); +} \ No newline at end of file -- 1.7.4.4