blob: ff7b95cfd407050d5ef7dcbd6d2ea401bfcfcd9d (
plain)
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
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
/*=============================================================
**
** Source: pal_getusertempdirectoryw.c
**
** Purpose: Positive test the PAL_GetUserTempDirectoryW API.
** Call PAL_GetUserTempDirectoryW to retrieve the user
** temp directory.
**
**
**============================================================*/
#define UNICODE
#include <palsuite.h>
#define DIRECTORYLENGTH 1024
int __cdecl main(int argc, char *argv[])
{
int err;
DWORD dwFileAttribute;
DWORD cch = DIRECTORYLENGTH;
WCHAR wDirectoryName[DIRECTORYLENGTH];
//Initialize the PAL environment
err = PAL_Initialize(argc, argv);
if(0 != err)
{
ExitProcess(FAIL);
}
//retrive the user temp directory
err = PAL_GetUserTempDirectory(ddtInstallationDependentDirectory, wDirectoryName, &cch);
if(0 == err || 0 == strlen(convertC(wDirectoryName)))
{
Fail("Failed to call PAL_GetUserTempDirectoryW API!\n");
}
//retrive the attributes of a file or directory
dwFileAttribute = GetFileAttributesW(wDirectoryName);
//check if the retrived attribute indicates a directory
if( FILE_ATTRIBUTE_DIRECTORY != (FILE_ATTRIBUTE_DIRECTORY & dwFileAttribute))
{
Fail("PAL_GetUserTempDirectoryW API returned a non-directory name!\n");
}
printf ("PAL_GetUserTempDirectoryW returns %S\n", wDirectoryName);
PAL_Terminate();
return PASS;
}
|