1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*=====================================================================
**
** Source: GetFileType.c (test 1)
**
** Purpose: Tests the PAL implementation of the GetFileType function.
**
**
**===================================================================*/
#include <palsuite.h>
const char* szTextFile = "text.txt";
int __cdecl main(int argc, char *argv[])
{
HANDLE hFile = NULL;
DWORD dwRc = 0;
if (0 != PAL_Initialize(argc,argv))
{
return FAIL;
}
/* test FILE_TYPE_UNKNOWN */
dwRc = GetFileType(hFile);
if (dwRc != FILE_TYPE_UNKNOWN)
{
Fail("GetFileType: ERROR -> Was expecting a return type of "
"FILE_TYPE_UNKNOWN but the function returned %ld.\n",
dwRc);
}
/* create a test file */
hFile = CreateFile(szTextFile,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
Fail("GetFileType: ERROR -> Unable to create file \"%s\".\n",
szTextFile);
}
dwRc = GetFileType(hFile);
if (CloseHandle(hFile) != TRUE)
{
Fail("GetFileType: ERROR -> Unable to close file \"%s\".\n",
szTextFile);
}
if (!DeleteFileA(szTextFile))
{
Fail("GetFileType: ERROR -> Unable to delete file \"%s\".\n",
szTextFile);
}
if (dwRc != FILE_TYPE_DISK)
{
Fail("GetFileType: ERROR -> Was expecting a return type of "
"FILE_TYPE_DISK but the function returned %ld.\n",
dwRc);
}
PAL_Terminate();
return PASS;
}
|