Commit 516bb0ba authored by Robert van Herk's avatar Robert van Herk Committed by Alexandre Julliard

msvcrt: Fix file mode T (temporary file).

parent 342fcb61
......@@ -1281,10 +1281,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':
*open_flags |= MSVCRT__O_TEMPORARY;
break;
case 'T':
*open_flags |= MSVCRT__O_SHORT_LIVED;
break;
case '+':
case ' ':
break;
......
......@@ -434,6 +434,37 @@ static void test_asciimode2(void)
unlink("ascii2.tst");
}
static void test_filemodeT(void)
{
char DATA [] = {26, 't', 'e', 's' ,'t'};
char DATA2 [100];
char temppath[MAX_PATH];
char tempfile[MAX_PATH];
FILE* f;
size_t bytesWritten;
size_t bytesRead;
WIN32_FIND_DATA findData;
HANDLE h;
GetTempPath (MAX_PATH, temppath);
GetTempFileName (temppath, "", 0, tempfile);
f = fopen(tempfile, "w+bDT");
bytesWritten = fwrite(DATA, 1, sizeof(DATA), f);
rewind(f);
bytesRead = fread(DATA2, 1, sizeof(DATA2), f);
fclose(f);
ok (bytesRead == bytesWritten && bytesRead == sizeof(DATA),
"fopen file mode 'T' wrongly interpreted as 't'\n" );
h = FindFirstFile(tempfile, &findData);
ok (h == INVALID_HANDLE_VALUE, "file wasn't deleted when closed.\n" );
if (h != INVALID_HANDLE_VALUE) FindClose(h);
}
static WCHAR* AtoW( const char* p )
{
WCHAR* buffer;
......@@ -1628,6 +1659,7 @@ START_TEST(file)
test_fileops();
test_asciimode();
test_asciimode2();
test_filemodeT();
test_readmode(FALSE); /* binary mode */
test_readmode(TRUE); /* ascii mode */
test_readboundary();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment