2002-04-11 23:49:23 +02:00
|
|
|
/*
|
2006-12-03 22:38:21 +01:00
|
|
|
* Unit test suite for various Path and Directory Functions
|
2002-04-11 23:49:23 +02:00
|
|
|
*
|
|
|
|
* Copyright 2002 Geoffrey Hausheer
|
2006-12-03 22:38:21 +01:00
|
|
|
* Copyright 2006 Detlef Riekenberg
|
2002-04-11 23:49:23 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-04-11 23:49:23 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-04-11 23:49:23 +02:00
|
|
|
#include <stdio.h>
|
2013-07-04 06:42:27 +02:00
|
|
|
#include <assert.h>
|
2002-04-11 23:49:23 +02:00
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-04-11 23:49:23 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
2002-12-11 01:16:31 +01:00
|
|
|
#include "winnls.h"
|
2002-04-11 23:49:23 +02:00
|
|
|
|
|
|
|
#define HAS_TRAIL_SLASH_A(string) (string[lstrlenA(string)-1]=='\\')
|
|
|
|
|
|
|
|
#define LONGFILE "Long File test.path"
|
|
|
|
#define SHORTFILE "pathtest.pth"
|
|
|
|
#define SHORTDIR "shortdir"
|
|
|
|
#define LONGDIR "Long Directory"
|
|
|
|
#define NONFILE_SHORT "noexist.pth"
|
2005-02-10 20:19:35 +01:00
|
|
|
#define NONFILE_LONG "NonExistent File"
|
2002-04-11 23:49:23 +02:00
|
|
|
#define NONDIR_SHORT "notadir"
|
2005-02-10 20:19:35 +01:00
|
|
|
#define NONDIR_LONG "NonExistent Directory"
|
2002-04-11 23:49:23 +02:00
|
|
|
|
2002-07-16 03:19:41 +02:00
|
|
|
#define NOT_A_VALID_DRIVE '@'
|
|
|
|
|
2013-09-06 16:39:48 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
#define ARCH "x86"
|
|
|
|
#elif defined __x86_64__
|
|
|
|
#define ARCH "amd64"
|
|
|
|
#else
|
|
|
|
#define ARCH "none"
|
|
|
|
#endif
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* the following characters don't work well with GetFullPathNameA
|
|
|
|
in Win98. I don't know if this is a FAT thing, or if it is an OS thing
|
|
|
|
but I don't test these characters now.
|
|
|
|
NOTE: Win2k allows GetFullPathNameA to work with them though
|
2002-12-11 01:16:31 +01:00
|
|
|
|<>"
|
2002-04-11 23:49:23 +02:00
|
|
|
*/
|
2002-12-11 01:16:31 +01:00
|
|
|
static const CHAR funny_chars[]="!@#$%^&*()=+{}[],?'`";
|
|
|
|
static const CHAR is_char_ok[] ="11111110111111111011";
|
2002-05-06 22:13:16 +02:00
|
|
|
|
|
|
|
static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR,LPSTR,DWORD);
|
2006-09-29 09:21:31 +02:00
|
|
|
static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD);
|
2002-04-11 23:49:23 +02:00
|
|
|
|
2007-04-25 09:41:11 +02:00
|
|
|
/* Present in Win2003+ */
|
|
|
|
static BOOL (WINAPI *pNeedCurrentDirectoryForExePathA)(LPCSTR);
|
|
|
|
static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR);
|
|
|
|
|
2009-12-21 21:00:38 +01:00
|
|
|
static DWORD (WINAPI *pSearchPathA)(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*);
|
|
|
|
static DWORD (WINAPI *pSearchPathW)(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,LPWSTR,LPWSTR*);
|
|
|
|
|
2013-09-06 16:39:48 +02:00
|
|
|
static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
|
|
|
|
static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
|
|
|
|
static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
|
|
|
|
static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *);
|
|
|
|
static void (WINAPI *pReleaseActCtx)(HANDLE);
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* a structure to deal with wine todos somewhat cleanly */
|
|
|
|
typedef struct {
|
|
|
|
DWORD shortlen;
|
|
|
|
DWORD shorterror;
|
|
|
|
DWORD s2llen;
|
|
|
|
DWORD s2lerror;
|
|
|
|
DWORD longlen;
|
|
|
|
DWORD longerror;
|
|
|
|
} SLpassfail;
|
|
|
|
|
|
|
|
/* function that tests GetFullPathNameA, GetShortPathNameA,GetLongPathNameA */
|
2008-03-17 21:51:39 +01:00
|
|
|
/* NOTE: the passfail structure is used to allow customizable todo checking
|
2002-04-11 23:49:23 +02:00
|
|
|
for wine. It is not very pretty, but it sure beats duplicating this
|
|
|
|
function lots of times
|
|
|
|
*/
|
2005-05-31 11:30:45 +02:00
|
|
|
static void test_ValidPathA(const CHAR *curdir, const CHAR *subdir, const CHAR *filename,
|
|
|
|
CHAR *shortstr, SLpassfail *passfail, const CHAR *errstr)
|
|
|
|
{
|
2002-04-11 23:49:23 +02:00
|
|
|
CHAR tmpstr[MAX_PATH],
|
|
|
|
fullpath[MAX_PATH], /*full path to the file (not short/long) */
|
|
|
|
subpath[MAX_PATH], /*relative path to the file */
|
2008-03-17 21:51:39 +01:00
|
|
|
fullpathshort[MAX_PATH], /*absolute path to the file (short format) */
|
2002-04-11 23:49:23 +02:00
|
|
|
fullpathlong[MAX_PATH], /*absolute path to the file (long format) */
|
|
|
|
curdirshort[MAX_PATH], /*absolute path to the current dir (short) */
|
|
|
|
curdirlong[MAX_PATH]; /*absolute path to the current dir (long) */
|
|
|
|
LPSTR strptr; /*ptr to the filename portion of the path */
|
|
|
|
DWORD len;
|
|
|
|
/* if passfail is NULL, we can perform all checks within this function,
|
|
|
|
otherwise, we will return the relevant data in the passfail struct, so
|
|
|
|
we must initialize it first
|
|
|
|
*/
|
|
|
|
if(passfail!=NULL) {
|
|
|
|
passfail->shortlen=-1;passfail->s2llen=-1;passfail->longlen=-1;
|
|
|
|
passfail->shorterror=0;passfail->s2lerror=0;passfail->longerror=0;
|
|
|
|
}
|
|
|
|
/* GetLongPathNameA is only supported on Win2k+ and Win98+ */
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
|
|
|
ok((len=pGetLongPathNameA(curdir,curdirlong,MAX_PATH)),
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
/*GetLongPathNameA can return a trailing '\\' but shouldn't do so here */
|
|
|
|
ok(! HAS_TRAIL_SLASH_A(curdirlong),
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA should not have a trailing \\\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
ok((len=GetShortPathNameA(curdir,curdirshort,MAX_PATH)),
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetShortPathNameA failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
/*GetShortPathNameA can return a trailing '\\' but shouldn't do so here */
|
|
|
|
ok(! HAS_TRAIL_SLASH_A(curdirshort),
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetShortPathNameA should not have a trailing \\\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
/* build relative and absolute paths from inputs */
|
|
|
|
if(lstrlenA(subdir)) {
|
|
|
|
sprintf(subpath,"%s\\%s",subdir,filename);
|
|
|
|
} else {
|
|
|
|
lstrcpyA(subpath,filename);
|
|
|
|
}
|
|
|
|
sprintf(fullpath,"%s\\%s",curdir,subpath);
|
|
|
|
sprintf(fullpathshort,"%s\\%s",curdirshort,subpath);
|
|
|
|
sprintf(fullpathlong,"%s\\%s",curdirlong,subpath);
|
|
|
|
/* Test GetFullPathNameA functionality */
|
|
|
|
len=GetFullPathNameA(subpath,MAX_PATH,tmpstr,&strptr);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len, "GetFullPathNameA failed for: '%s'\n",subpath);
|
2002-04-11 23:49:23 +02:00
|
|
|
if(HAS_TRAIL_SLASH_A(subpath)) {
|
2004-01-15 02:48:44 +01:00
|
|
|
ok(strptr==NULL,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetFullPathNameA should not return a filename ptr\n",errstr);
|
2004-01-15 02:48:44 +01:00
|
|
|
ok(lstrcmpiA(fullpath,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
2004-01-15 02:48:44 +01:00
|
|
|
errstr,tmpstr,fullpath);
|
2002-06-01 01:06:46 +02:00
|
|
|
} else {
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(lstrcmpiA(strptr,filename)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,strptr,filename);
|
|
|
|
ok(lstrcmpiA(fullpath,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetFullPathNameA returned '%s' instead of '%s'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,tmpstr,fullpath);
|
|
|
|
}
|
|
|
|
/* Test GetShortPathNameA functionality */
|
|
|
|
SetLastError(0);
|
|
|
|
len=GetShortPathNameA(fullpathshort,shortstr,MAX_PATH);
|
|
|
|
if(passfail==NULL) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len, "%s: GetShortPathNameA failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
} else {
|
|
|
|
passfail->shortlen=len;
|
|
|
|
passfail->shorterror=GetLastError();
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Test GetLongPathNameA functionality
|
2002-04-11 23:49:23 +02:00
|
|
|
We test both conversion from GetFullPathNameA and from GetShortPathNameA
|
|
|
|
*/
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-01-15 01:20:46 +01:00
|
|
|
if(len!=0) {
|
2002-04-11 23:49:23 +02:00
|
|
|
SetLastError(0);
|
2002-05-06 22:13:16 +02:00
|
|
|
len=pGetLongPathNameA(shortstr,tmpstr,MAX_PATH);
|
2002-04-11 23:49:23 +02:00
|
|
|
if(passfail==NULL) {
|
2002-06-01 01:06:46 +02:00
|
|
|
ok(len,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA failed during Short->Long conversion\n", errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,tmpstr,fullpathlong);
|
|
|
|
} else {
|
|
|
|
passfail->s2llen=len;
|
|
|
|
passfail->s2lerror=GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(0);
|
2002-05-06 22:13:16 +02:00
|
|
|
len=pGetLongPathNameA(fullpath,tmpstr,MAX_PATH);
|
2002-04-11 23:49:23 +02:00
|
|
|
if(passfail==NULL) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len, "%s: GetLongPathNameA failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
if(HAS_TRAIL_SLASH_A(fullpath)) {
|
2004-01-15 01:20:46 +01:00
|
|
|
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,tmpstr,fullpathlong);
|
|
|
|
} else {
|
|
|
|
ok(lstrcmpiA(fullpathlong,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: GetLongPathNameA returned '%s' instead of '%s'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,tmpstr,fullpathlong);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
passfail->longlen=len;
|
|
|
|
passfail->longerror=GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* split path into leading directory, and 8.3 filename */
|
|
|
|
static void test_SplitShortPathA(CHAR *path,CHAR *dir,CHAR *eight,CHAR *three) {
|
2013-10-24 00:40:23 +02:00
|
|
|
BOOL done = FALSE, error = FALSE;
|
2002-12-18 03:22:51 +01:00
|
|
|
int ext,fil;
|
|
|
|
int len,i;
|
2002-04-11 23:49:23 +02:00
|
|
|
len=lstrlenA(path);
|
2013-10-24 00:40:23 +02:00
|
|
|
ext=len;
|
|
|
|
fil=len;
|
2003-06-18 05:30:39 +02:00
|
|
|
/* walk backwards over path looking for '.' or '\\' separators */
|
2002-04-11 23:49:23 +02:00
|
|
|
for(i=len-1;(i>=0) && (!done);i--) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if(path[i]=='.')
|
2013-10-24 00:40:23 +02:00
|
|
|
if(ext!=len) error=TRUE; else ext=i;
|
2002-04-11 23:49:23 +02:00
|
|
|
else if(path[i]=='\\') {
|
|
|
|
if(i==len-1) {
|
2013-10-24 00:40:23 +02:00
|
|
|
error=TRUE;
|
2002-04-11 23:49:23 +02:00
|
|
|
} else {
|
|
|
|
fil=i;
|
2013-10-24 00:40:23 +02:00
|
|
|
done=TRUE;
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check that we didn't find a trailing '\\' or multiple '.' */
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(!error,"Illegal file found in 8.3 path '%s'\n",path);
|
2003-05-13 02:41:57 +02:00
|
|
|
/* Separate dir, root, and extension */
|
2002-04-11 23:49:23 +02:00
|
|
|
if(ext!=len) lstrcpyA(three,path+ext+1); else lstrcpyA(three,"");
|
|
|
|
if(fil!=len) {
|
|
|
|
lstrcpynA(eight,path+fil+1,ext-fil);
|
|
|
|
lstrcpynA(dir,path,fil+1);
|
|
|
|
} else {
|
|
|
|
lstrcpynA(eight,path,ext+1);
|
|
|
|
lstrcpyA(dir,"");
|
|
|
|
}
|
|
|
|
/* Validate that root and extension really are 8.3 */
|
|
|
|
ok(lstrlenA(eight)<=8 && lstrlenA(three)<=3,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNAmeA did not return an 8.3 path\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that GetShortPathNameA returns a valid 8.3 path */
|
2005-05-31 11:30:45 +02:00
|
|
|
static void test_LongtoShortA(CHAR *teststr,const CHAR *goodstr,
|
|
|
|
const CHAR *ext,const CHAR *errstr) {
|
2002-04-11 23:49:23 +02:00
|
|
|
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
|
|
|
|
|
|
|
|
test_SplitShortPathA(teststr,dir,eight,three);
|
|
|
|
ok(lstrcmpiA(dir,goodstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA returned '%s' instead of '%s'\n",dir,goodstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(lstrcmpiA(three,ext)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA returned '%s' with incorrect extension\n",three);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test that Get(Short|Long|Full)PathNameA work correctly with interesting
|
|
|
|
characters in the filename.
|
|
|
|
'valid' indicates whether this would be an allowed filename
|
2004-01-15 01:20:46 +01:00
|
|
|
'todo' indicates that wine doesn't get this right yet.
|
2005-02-10 20:19:35 +01:00
|
|
|
NOTE: We always call this routine with a nonexistent filename, so
|
2002-04-11 23:49:23 +02:00
|
|
|
Get(Short|Long)PathNameA should never pass, but GetFullPathNameA
|
|
|
|
should.
|
|
|
|
*/
|
2004-05-14 06:55:28 +02:00
|
|
|
static void test_FunnyChars(CHAR *curdir,CHAR *curdir_short,CHAR *filename, INT valid,CHAR *errstr)
|
2004-04-27 04:27:47 +02:00
|
|
|
{
|
2002-12-11 01:16:31 +01:00
|
|
|
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
|
2002-04-11 23:49:23 +02:00
|
|
|
SLpassfail passfail;
|
|
|
|
|
|
|
|
test_ValidPathA(curdir,"",filename,tmpstr,&passfail,errstr);
|
|
|
|
if(valid) {
|
2004-05-14 06:55:28 +02:00
|
|
|
sprintf(tmpstr1,"%s\\%s",curdir_short,filename);
|
2002-12-11 01:16:31 +01:00
|
|
|
ok((passfail.shortlen==0 &&
|
2003-05-14 01:40:51 +02:00
|
|
|
(passfail.shorterror==ERROR_FILE_NOT_FOUND || passfail.shorterror==ERROR_PATH_NOT_FOUND || !passfail.shorterror)) ||
|
2002-12-11 01:16:31 +01:00
|
|
|
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
2006-10-10 01:06:48 +02:00
|
|
|
"%s: GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
errstr,passfail.shortlen,passfail.shorterror,tmpstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
} else {
|
2002-12-11 01:16:31 +01:00
|
|
|
ok(passfail.shortlen==0 &&
|
2003-05-14 01:40:51 +02:00
|
|
|
(passfail.shorterror==ERROR_INVALID_NAME || passfail.shorterror==ERROR_FILE_NOT_FOUND || !passfail.shorterror),
|
2006-10-10 01:06:48 +02:00
|
|
|
"%s: GetShortPathA should have failed len=%d, error=%d\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
errstr,passfail.shortlen,passfail.shorterror);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
if(valid) {
|
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"%s: GetLongPathA returned %d and not %d\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr,passfail.longerror,ERROR_FILE_NOT_FOUND);
|
|
|
|
} else {
|
|
|
|
ok(passfail.longerror==ERROR_INVALID_NAME ||
|
|
|
|
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"%s: GetLongPathA returned %d and not %d or %d'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr, passfail.longerror,ERROR_INVALID_NAME,ERROR_FILE_NOT_FOUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Routine to test that SetCurrentDirectory behaves as expected. */
|
|
|
|
static void test_setdir(CHAR *olddir,CHAR *newdir,
|
2005-05-31 11:30:45 +02:00
|
|
|
CHAR *cmprstr, INT pass, const CHAR *errstr)
|
2002-04-11 23:49:23 +02:00
|
|
|
{
|
|
|
|
CHAR tmppath[MAX_PATH], *dirptr;
|
|
|
|
DWORD val,len,chklen;
|
|
|
|
|
|
|
|
val=SetCurrentDirectoryA(newdir);
|
|
|
|
len=GetCurrentDirectoryA(MAX_PATH,tmppath);
|
|
|
|
/* if 'pass' then the SetDirectoryA was supposed to pass */
|
|
|
|
if(pass) {
|
|
|
|
dirptr=(cmprstr==NULL) ? newdir : cmprstr;
|
|
|
|
chklen=lstrlenA(dirptr);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(val,"%s: SetCurrentDirectoryA failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(len==chklen,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr);
|
|
|
|
ok(lstrcmpiA(dirptr,tmppath)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: SetCurrentDirectory did not change the directory, though it passed\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr);
|
|
|
|
ok(SetCurrentDirectoryA(olddir),
|
2014-02-07 22:42:49 +01:00
|
|
|
"%s: Couldn't set directory to its original value\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
} else {
|
|
|
|
/* else thest that it fails correctly */
|
|
|
|
chklen=lstrlenA(olddir);
|
|
|
|
ok(val==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: SetCurrentDirectoryA passed when it should have failed\n",errstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(len==chklen,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: SetCurrentDirectory changed the directory, though it failed\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr);
|
|
|
|
ok(lstrcmpiA(olddir,tmppath)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"%s: SetCurrentDirectory changed the directory, though it failed\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
errstr);
|
|
|
|
}
|
|
|
|
}
|
2002-07-16 03:19:41 +02:00
|
|
|
static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
|
2002-04-11 23:49:23 +02:00
|
|
|
{
|
|
|
|
CHAR tmppath[MAX_PATH], /*path to TEMP */
|
|
|
|
tmpstr[MAX_PATH],
|
2010-10-17 01:51:54 +02:00
|
|
|
tmpstr1[MAX_PATH],
|
|
|
|
invalid_dir[MAX_PATH];
|
|
|
|
|
2002-07-16 03:19:41 +02:00
|
|
|
DWORD len,len1,drives;
|
2002-04-11 23:49:23 +02:00
|
|
|
INT id;
|
|
|
|
HANDLE hndl;
|
2005-10-26 12:08:20 +02:00
|
|
|
BOOL bRes;
|
2010-10-17 01:51:54 +02:00
|
|
|
UINT unique;
|
2002-04-11 23:49:23 +02:00
|
|
|
|
2002-07-16 03:19:41 +02:00
|
|
|
*curDrive = *otherDrive = NOT_A_VALID_DRIVE;
|
|
|
|
|
|
|
|
/* Get the current drive letter */
|
|
|
|
if( GetCurrentDirectoryA( MAX_PATH, tmpstr))
|
|
|
|
*curDrive = tmpstr[0];
|
|
|
|
else
|
|
|
|
trace( "Unable to discover current drive, some tests will not be conducted.\n");
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Test GetTempPathA */
|
|
|
|
len=GetTempPathA(MAX_PATH,tmppath);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len!=0 && len < MAX_PATH,"GetTempPathA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(HAS_TRAIL_SLASH_A(tmppath),
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetTempPathA returned a path that did not end in '\\'\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
lstrcpyA(tmpstr,"aaaaaaaa");
|
|
|
|
len1=GetTempPathA(len,tmpstr);
|
2009-01-29 22:07:50 +01:00
|
|
|
ok(len1==len+1 || broken(len1 == len), /* WinME */
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetTempPathA should return string length %d instead of %d\n",len+1,len1);
|
2002-08-29 00:25:56 +02:00
|
|
|
|
2010-10-17 01:51:54 +02:00
|
|
|
/* Test GetTmpFileNameA */
|
2004-02-06 06:24:34 +01:00
|
|
|
ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
|
2002-12-11 01:16:31 +01:00
|
|
|
sprintf(tmpstr,"pat%.4x.tmp",id & 0xffff);
|
|
|
|
sprintf(tmpstr1,"pat%x.tmp",id & 0xffff);
|
|
|
|
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
|
|
|
|
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
|
2005-11-12 20:09:06 +01:00
|
|
|
"GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
newdir,tmpstr,tmpstr1,id);
|
2006-05-15 16:25:46 +02:00
|
|
|
ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-05-17 05:40:46 +02:00
|
|
|
id=GetTempFileNameA(tmppath,NULL,0,newdir);
|
|
|
|
/* Windows 95, 98 return 0==id, while Windows 2000, XP return 0!=id */
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
sprintf(tmpstr,"%.4x.tmp",id & 0xffff);
|
|
|
|
sprintf(tmpstr1,"%x.tmp",id & 0xffff);
|
|
|
|
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
|
|
|
|
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
|
|
|
|
"GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
|
|
|
|
newdir,tmpstr,tmpstr1,id);
|
|
|
|
ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
|
|
|
|
}
|
2005-11-12 20:09:06 +01:00
|
|
|
|
2010-10-17 01:51:54 +02:00
|
|
|
for(unique=0;unique<3;unique++) {
|
2010-11-02 13:03:16 +01:00
|
|
|
/* Nonexistent path */
|
2010-11-10 01:19:48 +01:00
|
|
|
sprintf(invalid_dir, "%s\\%s",tmppath,"non_existent_dir_1jwj3y32nb3");
|
2010-10-17 01:51:54 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!GetTempFileNameA(invalid_dir,"tfn",unique,newdir),"GetTempFileNameA should have failed\n");
|
|
|
|
ok(GetLastError()==ERROR_DIRECTORY || broken(GetLastError()==ERROR_PATH_NOT_FOUND)/*win98*/,
|
|
|
|
"got %d, expected ERROR_DIRECTORY\n", GetLastError());
|
|
|
|
|
|
|
|
/* Check return value for unique !=0 */
|
|
|
|
if(unique) {
|
|
|
|
ok((GetTempFileNameA(tmppath,"tfn",unique,newdir) == unique),"GetTempFileNameA unexpectedly failed\n");
|
|
|
|
/* if unique != 0, the actual temp files are not created: */
|
|
|
|
ok(!DeleteFileA(newdir) && GetLastError() == ERROR_FILE_NOT_FOUND,"Deleted a file that shouldn't exist!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 03:19:41 +02:00
|
|
|
/* Find first valid drive letter that is neither newdir[0] nor curDrive */
|
|
|
|
drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A'));
|
|
|
|
if( *curDrive != NOT_A_VALID_DRIVE)
|
|
|
|
drives &= ~(1<<(*curDrive-'A'));
|
|
|
|
if( drives)
|
|
|
|
for( *otherDrive='A'; (drives & 1) == 0; drives>>=1, (*otherDrive)++);
|
|
|
|
else
|
|
|
|
trace( "Could not find alternative drive, some tests will not be conducted.\n");
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Do some CreateDirectoryA tests */
|
|
|
|
/* It would be nice to do test the SECURITY_ATTRIBUTES, but I don't
|
|
|
|
really understand how they work.
|
|
|
|
More formal tests should be done along with CreateFile tests
|
|
|
|
*/
|
2006-05-15 16:25:46 +02:00
|
|
|
ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(CreateDirectoryA(newdir,NULL)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"CreateDirectoryA succeeded even though a file of the same name exists\n");
|
|
|
|
ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
|
|
|
|
ok(CreateDirectoryA(newdir,NULL),"CreateDirectoryA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Create some files to test other functions. Note, we will test CreateFileA
|
|
|
|
at some later point
|
|
|
|
*/
|
|
|
|
sprintf(tmpstr,"%s\\%s",newdir,SHORTDIR);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(CreateDirectoryA(tmpstr,NULL),"CreateDirectoryA failed\n");
|
2009-02-03 15:21:47 +01:00
|
|
|
sprintf(tmpstr,"%c:", *curDrive);
|
|
|
|
bRes = CreateDirectoryA(tmpstr,NULL);
|
|
|
|
ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED ||
|
2005-11-10 12:16:20 +01:00
|
|
|
GetLastError() == ERROR_ALREADY_EXISTS),
|
2009-02-03 15:21:47 +01:00
|
|
|
"CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
|
|
|
|
sprintf(tmpstr,"%c:\\", *curDrive);
|
|
|
|
bRes = CreateDirectoryA(tmpstr,NULL);
|
2005-11-10 12:16:20 +01:00
|
|
|
ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED ||
|
|
|
|
GetLastError() == ERROR_ALREADY_EXISTS),
|
2009-02-03 15:21:47 +01:00
|
|
|
"CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,SHORTFILE);
|
|
|
|
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
2003-01-15 00:43:41 +01:00
|
|
|
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
|
|
|
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,LONGFILE);
|
|
|
|
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
2003-01-15 00:43:41 +01:00
|
|
|
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
|
|
|
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,SHORTFILE);
|
|
|
|
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
2003-01-15 00:43:41 +01:00
|
|
|
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
|
|
|
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,LONGDIR,LONGFILE);
|
|
|
|
hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
|
2003-01-15 00:43:41 +01:00
|
|
|
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
|
|
|
|
ok(CloseHandle(hndl),"CloseHandle failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test GetCurrentDirectory & SetCurrentDirectory */
|
|
|
|
static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
|
|
|
|
{
|
|
|
|
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH];
|
2010-02-01 13:22:41 +01:00
|
|
|
char *buffer;
|
2002-04-11 23:49:23 +02:00
|
|
|
DWORD len,len1;
|
|
|
|
/* Save the original directory, so that we can return to it at the end
|
|
|
|
of the test
|
|
|
|
*/
|
|
|
|
len=GetCurrentDirectoryA(MAX_PATH,origdir);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len!=0 && len < MAX_PATH,"GetCurrentDirectoryA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Make sure that CetCurrentDirectoryA doesn't overwrite the buffer when the
|
|
|
|
buffer size is too small to hold the current directory
|
|
|
|
*/
|
|
|
|
lstrcpyA(tmpstr,"aaaaaaa");
|
|
|
|
len1=GetCurrentDirectoryA(len,tmpstr);
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(len1==len+1, "GetCurrentDirectoryA returned %d instead of %d\n",len1,len+1);
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(lstrcmpiA(tmpstr,"aaaaaaa")==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetCurrentDirectoryA should not have modified the buffer\n");
|
2010-02-01 13:22:41 +01:00
|
|
|
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, 2 * 65536 );
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
strcpy( buffer, "foo" );
|
|
|
|
len = GetCurrentDirectoryA( 32767, buffer );
|
|
|
|
ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
|
|
|
|
if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
strcpy( buffer, "foo" );
|
|
|
|
len = GetCurrentDirectoryA( 32768, buffer );
|
|
|
|
ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
|
|
|
|
if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
strcpy( buffer, "foo" );
|
|
|
|
len = GetCurrentDirectoryA( 65535, buffer );
|
|
|
|
ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4, win2k, xp */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
|
|
|
|
if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
strcpy( buffer, "foo" );
|
|
|
|
len = GetCurrentDirectoryA( 65536, buffer );
|
|
|
|
ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
|
|
|
|
if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
strcpy( buffer, "foo" );
|
|
|
|
len = GetCurrentDirectoryA( 2 * 65536, buffer );
|
|
|
|
ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
|
|
|
|
if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
|
2010-02-10 12:11:53 +01:00
|
|
|
/* Check for crash prevention on swapped args. Crashes all but Win9x.
|
|
|
|
*/
|
|
|
|
if (0)
|
|
|
|
{
|
2011-02-10 22:27:59 +01:00
|
|
|
GetCurrentDirectoryA( 42, (LPSTR)(MAX_PATH + 42) );
|
2010-02-10 12:11:53 +01:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* SetCurrentDirectoryA shouldn't care whether the string has a
|
2002-04-11 23:49:23 +02:00
|
|
|
trailing '\\' or not
|
|
|
|
*/
|
|
|
|
sprintf(tmpstr,"%s\\",newdir);
|
|
|
|
test_setdir(origdir,tmpstr,newdir,1,"check 1");
|
|
|
|
test_setdir(origdir,newdir,NULL,1,"check 2");
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Set the directory to the working area. We just tested that this works,
|
2002-04-11 23:49:23 +02:00
|
|
|
so why check it again.
|
|
|
|
*/
|
|
|
|
SetCurrentDirectoryA(newdir);
|
2005-02-10 20:19:35 +01:00
|
|
|
/* Check that SetCurrentDirectory fails when a nonexistent dir is specified */
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_SHORT);
|
|
|
|
test_setdir(newdir,tmpstr,NULL,0,"check 3");
|
2005-02-10 20:19:35 +01:00
|
|
|
/* Check that SetCurrentDirectory fails for a nonexistent lond directory */
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,NONDIR_LONG);
|
|
|
|
test_setdir(newdir,tmpstr,NULL,0,"check 4");
|
|
|
|
/* Check that SetCurrentDirectory passes with a long directory */
|
|
|
|
sprintf(tmpstr,"%s\\%s",newdir,LONGDIR);
|
|
|
|
test_setdir(newdir,tmpstr,NULL,1,"check 5");
|
|
|
|
/* Check that SetCurrentDirectory passes with a short relative directory */
|
|
|
|
sprintf(tmpstr,"%s",SHORTDIR);
|
|
|
|
sprintf(tmpstr1,"%s\\%s",newdir,SHORTDIR);
|
|
|
|
test_setdir(newdir,tmpstr,tmpstr1,1,"check 6");
|
|
|
|
/* starting with a '.' */
|
|
|
|
sprintf(tmpstr,".\\%s",SHORTDIR);
|
|
|
|
test_setdir(newdir,tmpstr,tmpstr1,1,"check 7");
|
|
|
|
/* Check that SetCurrentDirectory passes with a short relative directory */
|
|
|
|
sprintf(tmpstr,"%s",LONGDIR);
|
|
|
|
sprintf(tmpstr1,"%s\\%s",newdir,LONGDIR);
|
|
|
|
test_setdir(newdir,tmpstr,tmpstr1,1,"check 8");
|
|
|
|
/* starting with a '.' */
|
|
|
|
sprintf(tmpstr,".\\%s",LONGDIR);
|
|
|
|
test_setdir(newdir,tmpstr,tmpstr1,1,"check 9");
|
2008-09-21 12:41:36 +02:00
|
|
|
/* change to root without a trailing backslash. The function call succeeds
|
|
|
|
but the directory is not changed.
|
|
|
|
*/
|
2009-01-27 14:49:47 +01:00
|
|
|
sprintf(tmpstr, "%c:", newdir[0]);
|
2008-09-21 12:41:36 +02:00
|
|
|
test_setdir(newdir,tmpstr,newdir,1,"check 10");
|
|
|
|
/* works however with a trailing backslash */
|
2009-01-27 14:49:47 +01:00
|
|
|
sprintf(tmpstr, "%c:\\", newdir[0]);
|
2008-09-21 12:41:36 +02:00
|
|
|
test_setdir(newdir,tmpstr,NULL,1,"check 11");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup the mess we made while executing these tests */
|
|
|
|
static void test_CleanupPathA(CHAR *origdir, CHAR *curdir)
|
|
|
|
{
|
|
|
|
CHAR tmpstr[MAX_PATH];
|
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,LONGFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(DeleteFileA(tmpstr),"DeleteFileA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s",curdir,SHORTDIR);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s",curdir,LONGDIR);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(RemoveDirectoryA(tmpstr),"RemoveDirectoryA failed\n");
|
|
|
|
ok(SetCurrentDirectoryA(origdir),"SetCurrentDirectoryA failed\n");
|
|
|
|
ok(RemoveDirectoryA(curdir),"RemoveDirectoryA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
2010-10-28 05:58:55 +02:00
|
|
|
/* test that short path name functions work regardless of case */
|
|
|
|
static void test_ShortPathCase(const char *tmpdir, const char *dirname,
|
|
|
|
const char *filename)
|
|
|
|
{
|
|
|
|
char buf[MAX_PATH], shortbuf[MAX_PATH];
|
|
|
|
HANDLE hndl;
|
2013-07-04 06:42:27 +02:00
|
|
|
size_t i;
|
2010-10-28 05:58:55 +02:00
|
|
|
|
2013-07-04 06:42:27 +02:00
|
|
|
assert(strlen(tmpdir) + strlen(dirname) + strlen(filename) + 2 < sizeof(buf));
|
|
|
|
sprintf(buf,"%s\\%s\\%s",tmpdir,dirname,filename);
|
2010-10-28 05:58:55 +02:00
|
|
|
GetShortPathNameA(buf,shortbuf,sizeof(shortbuf));
|
|
|
|
hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
|
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%d)\n",GetLastError());
|
|
|
|
CloseHandle(hndl);
|
|
|
|
/* Now for the real test */
|
|
|
|
for(i=0;i<strlen(shortbuf);i++)
|
|
|
|
if (i % 2)
|
2010-10-29 01:57:48 +02:00
|
|
|
shortbuf[i] = tolower(shortbuf[i]);
|
2010-10-28 05:58:55 +02:00
|
|
|
hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
|
|
|
|
ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%d)\n",GetLastError());
|
|
|
|
CloseHandle(hndl);
|
|
|
|
}
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* This routine will test Get(Full|Short|Long)PathNameA */
|
2002-07-16 03:19:41 +02:00
|
|
|
static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
|
2002-04-11 23:49:23 +02:00
|
|
|
{
|
|
|
|
CHAR curdir_short[MAX_PATH],
|
|
|
|
longdir_short[MAX_PATH];
|
2002-12-11 01:16:31 +01:00
|
|
|
CHAR tmpstr[MAX_PATH],tmpstr1[MAX_PATH],tmpstr2[MAX_PATH];
|
2002-07-05 03:22:28 +02:00
|
|
|
LPSTR strptr; /*ptr to the filename portion of the path */
|
2002-04-11 23:49:23 +02:00
|
|
|
DWORD len;
|
|
|
|
INT i;
|
|
|
|
CHAR dir[MAX_PATH],eight[MAX_PATH],three[MAX_PATH];
|
|
|
|
SLpassfail passfail;
|
|
|
|
|
|
|
|
/* Get the short form of the current directory */
|
|
|
|
ok((len=GetShortPathNameA(curdir,curdir_short,MAX_PATH)),
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(!HAS_TRAIL_SLASH_A(curdir_short),
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA should not have a trailing \\\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Get the short form of the absolute-path to LONGDIR */
|
|
|
|
sprintf(tmpstr,"%s\\%s",curdir_short,LONGDIR);
|
|
|
|
ok((len=GetShortPathNameA(tmpstr,longdir_short,MAX_PATH)),
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(lstrcmpiA(longdir_short+(len-1),"\\")!=0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA should not have a trailing \\\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
if (pGetLongPathNameA) {
|
2003-11-18 21:39:34 +01:00
|
|
|
DWORD rc1,rc2;
|
2002-12-11 01:16:31 +01:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,LONGDIR,LONGFILE);
|
2003-11-18 21:39:34 +01:00
|
|
|
rc1=(*pGetLongPathNameA)(tmpstr,NULL,0);
|
|
|
|
rc2=(*pGetLongPathNameA)(curdir,NULL,0);
|
|
|
|
ok((rc1-strlen(tmpstr))==(rc2-strlen(curdir)),
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathNameA: wrong return code, %d instead of %d\n",
|
2006-06-13 13:57:12 +02:00
|
|
|
rc1, lstrlenA(tmpstr)+1);
|
2003-05-14 00:30:38 +02:00
|
|
|
|
2004-01-15 01:20:46 +01:00
|
|
|
sprintf(dir,"%c:",curDrive);
|
|
|
|
rc1=(*pGetLongPathNameA)(dir,tmpstr,sizeof(tmpstr));
|
|
|
|
ok(strcmp(dir,tmpstr)==0,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathNameA: returned '%s' instead of '%s' (rc=%d)\n",
|
2004-01-15 01:20:46 +01:00
|
|
|
tmpstr,dir,rc1);
|
2002-12-11 01:16:31 +01:00
|
|
|
}
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Check the cases where both file and directory exist first */
|
|
|
|
/* Start with a 8.3 directory, 8.3 filename */
|
|
|
|
test_ValidPathA(curdir,SHORTDIR,SHORTFILE,tmpstr,NULL,"test1");
|
|
|
|
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Now try a 8.3 directory, long file name */
|
|
|
|
test_ValidPathA(curdir,SHORTDIR,LONGFILE,tmpstr,NULL,"test2");
|
|
|
|
sprintf(tmpstr1,"%s\\%s",curdir_short,SHORTDIR);
|
|
|
|
test_LongtoShortA(tmpstr,tmpstr1,"PAT","test2");
|
|
|
|
/* Next is a long directory, 8.3 file */
|
|
|
|
test_ValidPathA(curdir,LONGDIR,SHORTFILE,tmpstr,NULL,"test3");
|
|
|
|
sprintf(tmpstr1,"%s\\%s",longdir_short,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA returned '%s' instead of '%s'\n",tmpstr,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
/*Lastly a long directory, long file */
|
|
|
|
test_ValidPathA(curdir,LONGDIR,LONGFILE,tmpstr,NULL,"test4");
|
|
|
|
test_LongtoShortA(tmpstr,longdir_short,"PAT","test4");
|
|
|
|
|
2002-09-06 21:46:27 +02:00
|
|
|
/* Now check all of the invalid file w/ valid directory combinations */
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Start with a 8.3 directory, 8.3 filename */
|
|
|
|
test_ValidPathA(curdir,SHORTDIR,NONFILE_SHORT,tmpstr,&passfail,"test5");
|
2002-12-11 01:16:31 +01:00
|
|
|
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,SHORTDIR,NONFILE_SHORT);
|
|
|
|
ok((passfail.shortlen==0 &&
|
|
|
|
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
|
|
|
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
passfail.shortlen,passfail.shorterror,tmpstr);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
/* Now try a 8.3 directory, long file name */
|
|
|
|
test_ValidPathA(curdir,SHORTDIR,NONFILE_LONG,tmpstr,&passfail,"test6");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-12-11 01:16:31 +01:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
/* Next is a long directory, 8.3 file */
|
|
|
|
test_ValidPathA(curdir,LONGDIR,NONFILE_SHORT,tmpstr,&passfail,"test7");
|
2002-12-11 01:16:31 +01:00
|
|
|
sprintf(tmpstr2,"%s\\%s",curdir_short,LONGDIR);
|
|
|
|
GetShortPathNameA(tmpstr2,tmpstr1,MAX_PATH);
|
|
|
|
strcat(tmpstr1,"\\" NONFILE_SHORT);
|
|
|
|
ok((passfail.shortlen==0 &&
|
|
|
|
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
|
|
|
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
passfail.shortlen,passfail.shorterror,tmpstr);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
/*Lastly a long directory, long file */
|
|
|
|
test_ValidPathA(curdir,LONGDIR,NONFILE_LONG,tmpstr,&passfail,"test8");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-12-11 01:16:31 +01:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetlongPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
/* Now try again with directories that don't exist */
|
|
|
|
/* 8.3 directory, 8.3 filename */
|
|
|
|
test_ValidPathA(curdir,NONDIR_SHORT,SHORTFILE,tmpstr,&passfail,"test9");
|
2002-12-11 01:16:31 +01:00
|
|
|
sprintf(tmpstr1,"%s\\%s\\%s",curdir_short,NONDIR_SHORT,SHORTFILE);
|
|
|
|
ok((passfail.shortlen==0 &&
|
|
|
|
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
|
|
|
(passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
passfail.shortlen,passfail.shorterror,tmpstr);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
|
|
|
/* Now try a 8.3 directory, long file name */
|
|
|
|
test_ValidPathA(curdir,NONDIR_SHORT,LONGFILE,tmpstr,&passfail,"test10");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.shorterror);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
|
|
|
/* Next is a long directory, 8.3 file */
|
|
|
|
test_ValidPathA(curdir,NONDIR_LONG,SHORTFILE,tmpstr,&passfail,"test11");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.shorterror);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
|
|
|
/*Lastly a long directory, long file */
|
|
|
|
test_ValidPathA(curdir,NONDIR_LONG,LONGFILE,tmpstr,&passfail,"test12");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.shorterror);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
|
|
|
/* Next try directories ending with '\\' */
|
|
|
|
/* Existing Directories */
|
|
|
|
sprintf(tmpstr,"%s\\",SHORTDIR);
|
|
|
|
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test13");
|
|
|
|
sprintf(tmpstr,"%s\\",LONGDIR);
|
|
|
|
test_ValidPathA(curdir,"",tmpstr,tmpstr1,NULL,"test14");
|
2005-02-10 20:19:35 +01:00
|
|
|
/* Nonexistent directories */
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr,"%s\\",NONDIR_SHORT);
|
|
|
|
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test15");
|
2004-05-14 06:55:28 +02:00
|
|
|
sprintf(tmpstr2,"%s\\%s",curdir_short,tmpstr);
|
2002-12-11 01:16:31 +01:00
|
|
|
ok((passfail.shortlen==0 &&
|
|
|
|
(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
|
|
|
|
(passfail.shortlen==strlen(tmpstr2) && lstrcmpiA(tmpstr1,tmpstr2)==0),
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
|
2002-12-11 01:16:31 +01:00
|
|
|
passfail.shortlen,passfail.shorterror,tmpstr);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_FILE_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
|
|
|
sprintf(tmpstr,"%s\\",NONDIR_LONG);
|
|
|
|
test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test16");
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.shortlen==0,"GetShortPathNameA passed when it shouldn't have\n");
|
2002-12-11 01:16:31 +01:00
|
|
|
ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
|
2003-05-14 01:40:51 +02:00
|
|
|
passfail.shorterror==ERROR_FILE_NOT_FOUND ||
|
|
|
|
!passfail.shorterror,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetShortPathA returned %d and not 'ERROR_FILE_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.shorterror);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(passfail.longlen==0,"GetLongPathNameA passed when it shouldn't have\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
ok(passfail.longerror==ERROR_FILE_NOT_FOUND,
|
2006-10-10 01:06:48 +02:00
|
|
|
"GetLongPathA returned %d and not 'ERROR_FILE_NOT_FOUND'\n",
|
2002-04-11 23:49:23 +02:00
|
|
|
passfail.longerror);
|
|
|
|
}
|
2002-07-05 03:22:28 +02:00
|
|
|
/* Test GetFullPathNameA with drive letters */
|
2002-07-16 03:19:41 +02:00
|
|
|
if( curDrive != NOT_A_VALID_DRIVE) {
|
2003-05-14 00:30:38 +02:00
|
|
|
sprintf(tmpstr,"%c:",curdir[0]);
|
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr2,&strptr),
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA(%c:) failed\n", curdir[0]);
|
2003-05-14 00:30:38 +02:00
|
|
|
GetCurrentDirectoryA(MAX_PATH,tmpstr);
|
|
|
|
sprintf(tmpstr1,"%s\\",tmpstr);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr2)==0 || lstrcmpiA(tmpstr1,tmpstr2)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA(%c:) returned '%s' instead of '%s' or '%s'\n",
|
2003-05-14 00:30:38 +02:00
|
|
|
curdir[0],tmpstr2,tmpstr,tmpstr1);
|
|
|
|
|
2002-07-16 03:19:41 +02:00
|
|
|
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
2002-07-16 03:19:41 +02:00
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-16 03:19:41 +02:00
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2002-07-16 03:19:41 +02:00
|
|
|
}
|
2002-07-05 03:22:28 +02:00
|
|
|
/* Without a leading slash, insert the current directory if on the current drive */
|
|
|
|
sprintf(tmpstr,"%c:%s\\%s",curdir[0],SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
2002-07-05 03:22:28 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-05 03:22:28 +02:00
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2002-07-05 03:22:28 +02:00
|
|
|
/* Otherwise insert the missing leading slash */
|
2002-07-16 03:19:41 +02:00
|
|
|
if( otherDrive != NOT_A_VALID_DRIVE) {
|
2008-02-27 12:58:40 +01:00
|
|
|
/* FIXME: this test assumes that current directory on other drive is root */
|
2002-07-16 03:19:41 +02:00
|
|
|
sprintf(tmpstr,"%c:%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed for %s\n", tmpstr);
|
2002-07-16 03:19:41 +02:00
|
|
|
sprintf(tmpstr,"%c:\\%s\\%s",otherDrive,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-16 03:19:41 +02:00
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2002-07-16 03:19:41 +02:00
|
|
|
}
|
2002-07-05 03:22:28 +02:00
|
|
|
/* Xilinx tools like to mix Unix and DOS formats, which Windows handles fine.
|
|
|
|
So test for them. */
|
2002-07-16 03:19:41 +02:00
|
|
|
if( curDrive != NOT_A_VALID_DRIVE) {
|
|
|
|
sprintf(tmpstr,"%c:/%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
2002-07-16 03:19:41 +02:00
|
|
|
sprintf(tmpstr,"%c:\\%s\\%s",curDrive,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-16 03:19:41 +02:00
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2002-07-16 03:19:41 +02:00
|
|
|
}
|
2002-07-05 03:22:28 +02:00
|
|
|
/**/
|
|
|
|
sprintf(tmpstr,"%c:%s/%s",curdir[0],SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
2002-07-05 03:22:28 +02:00
|
|
|
sprintf(tmpstr,"%s\\%s\\%s",curdir,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-05 03:22:28 +02:00
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2004-06-02 02:36:36 +02:00
|
|
|
/* Windows will insert a drive letter in front of an absolute UNIX path */
|
2002-07-05 03:22:28 +02:00
|
|
|
sprintf(tmpstr,"/%s/%s",SHORTDIR,SHORTFILE);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetFullPathNameA(tmpstr,MAX_PATH,tmpstr1,&strptr),"GetFullPathNameA failed\n");
|
2004-06-02 02:36:36 +02:00
|
|
|
sprintf(tmpstr,"%c:\\%s\\%s",*tmpstr1,SHORTDIR,SHORTFILE);
|
|
|
|
ok(lstrcmpiA(tmpstr,tmpstr1)==0,
|
|
|
|
"GetFullPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-07-05 03:22:28 +02:00
|
|
|
/* This passes in Wine because it still contains the pointer from the previous test */
|
|
|
|
ok(lstrcmpiA(SHORTFILE,strptr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetFullPathNameA returned part '%s' instead of '%s'\n",strptr,SHORTFILE);
|
2002-07-05 03:22:28 +02:00
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
/* Now try some relative paths */
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetShortPathNameA(LONGDIR,tmpstr,MAX_PATH),"GetShortPathNameA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
test_SplitShortPathA(tmpstr,dir,eight,three);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(pGetLongPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetLongPathNameA failed\n");
|
2004-01-15 01:20:46 +01:00
|
|
|
ok(lstrcmpiA(tmpstr1,LONGDIR)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,LONGDIR);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
sprintf(tmpstr,".\\%s",LONGDIR);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(GetShortPathNameA(tmpstr,tmpstr1,MAX_PATH),"GetShortPathNameA failed\n");
|
2002-04-11 23:49:23 +02:00
|
|
|
test_SplitShortPathA(tmpstr1,dir,eight,three);
|
2002-12-11 01:16:31 +01:00
|
|
|
ok(lstrcmpiA(dir,".")==0 || dir[0]=='\0',
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetShortPathNameA did not keep relative directory [%s]\n",tmpstr1);
|
2002-05-06 22:13:16 +02:00
|
|
|
if(pGetLongPathNameA) {
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(pGetLongPathNameA(tmpstr1,tmpstr1,MAX_PATH),"GetLongPathNameA failed %s\n",
|
2004-01-15 01:20:46 +01:00
|
|
|
tmpstr);
|
|
|
|
ok(lstrcmpiA(tmpstr1,tmpstr)==0,
|
2004-02-06 06:24:34 +01:00
|
|
|
"GetLongPathNameA returned '%s' instead of '%s'\n",tmpstr1,tmpstr);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
/* Check out Get*PathNameA on some funny characters */
|
|
|
|
for(i=0;i<lstrlenA(funny_chars);i++) {
|
2004-04-27 04:27:47 +02:00
|
|
|
INT valid;
|
2002-04-11 23:49:23 +02:00
|
|
|
valid=(is_char_ok[i]=='0') ? 0 : 1;
|
|
|
|
sprintf(tmpstr1,"check%d-1",i);
|
|
|
|
sprintf(tmpstr,"file%c000.ext",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-2",i);
|
|
|
|
sprintf(tmpstr,"file000.e%ct",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-3",i);
|
|
|
|
sprintf(tmpstr,"%cfile000.ext",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-4",i);
|
|
|
|
sprintf(tmpstr,"file000%c.ext",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-5",i);
|
|
|
|
sprintf(tmpstr,"Long %c File",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-6",i);
|
|
|
|
sprintf(tmpstr,"%c Long File",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
sprintf(tmpstr1,"check%d-7",i);
|
|
|
|
sprintf(tmpstr,"Long File %c",funny_chars[i]);
|
2004-05-14 06:55:28 +02:00
|
|
|
test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
2010-10-28 05:58:55 +02:00
|
|
|
/* Now try it on mixed case short names */
|
|
|
|
test_ShortPathCase(curdir,SHORTDIR,LONGFILE);
|
|
|
|
test_ShortPathCase(curdir,LONGDIR,SHORTFILE);
|
|
|
|
test_ShortPathCase(curdir,LONGDIR,LONGFILE);
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
static void test_GetTempPathA(char* tmp_dir)
|
2002-08-27 03:56:08 +02:00
|
|
|
{
|
2002-12-11 01:16:31 +01:00
|
|
|
DWORD len, len_with_null;
|
2002-08-27 03:56:08 +02:00
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
len_with_null = strlen(tmp_dir) + 1;
|
|
|
|
|
2002-08-27 03:56:08 +02:00
|
|
|
lstrcpyA(buf, "foo");
|
|
|
|
len = GetTempPathA(MAX_PATH, buf);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(len <= MAX_PATH, "should fit into MAX_PATH\n");
|
|
|
|
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
|
|
|
|
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
2002-08-27 03:56:08 +02:00
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
/* Some versions of Windows touch the buffer, some don't so we don't
|
2008-03-17 21:51:39 +01:00
|
|
|
* test that. Also, NT sometimes exaggerates the required buffer size
|
2002-12-11 01:16:31 +01:00
|
|
|
* so we cannot test for an exact match. Finally, the
|
|
|
|
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
|
|
|
|
* For instance in some cases Win98 returns len_with_null - 1 instead
|
|
|
|
* of len_with_null.
|
2002-08-27 03:56:08 +02:00
|
|
|
*/
|
|
|
|
len = GetTempPathA(1, buf);
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
len = GetTempPathA(0, NULL);
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
/* The call above gave us the buffer size that Windows thinks is needed
|
|
|
|
* so the next call should work
|
|
|
|
*/
|
2002-08-27 03:56:08 +02:00
|
|
|
lstrcpyA(buf, "foo");
|
2002-12-11 01:16:31 +01:00
|
|
|
len = GetTempPathA(len, buf);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
|
|
|
|
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
2015-02-24 02:41:32 +01:00
|
|
|
|
|
|
|
memset(buf, 'a', sizeof(buf));
|
|
|
|
len = GetTempPathA(sizeof(buf), buf);
|
|
|
|
ok(lstrcmpiA(buf, tmp_dir) == 0, "expected [%s], got [%s]\n",tmp_dir,buf);
|
|
|
|
ok(len == strlen(buf), "returned length should be equal to the length of string\n");
|
|
|
|
/* The rest of the buffer remains untouched */
|
|
|
|
for(len++; len < sizeof(buf); len++)
|
|
|
|
ok(buf[len] == 'a', "expected 'a' at [%d], got 0x%x\n", len, buf[len]);
|
2002-08-27 03:56:08 +02:00
|
|
|
}
|
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
static void test_GetTempPathW(char* tmp_dir)
|
2002-08-27 03:56:08 +02:00
|
|
|
{
|
2002-12-11 01:16:31 +01:00
|
|
|
DWORD len, len_with_null;
|
2002-08-27 03:56:08 +02:00
|
|
|
WCHAR buf[MAX_PATH];
|
2002-12-11 01:16:31 +01:00
|
|
|
WCHAR tmp_dirW[MAX_PATH];
|
2002-08-27 03:56:08 +02:00
|
|
|
static const WCHAR fooW[] = {'f','o','o',0};
|
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
MultiByteToWideChar(CP_ACP,0,tmp_dir,-1,tmp_dirW,sizeof(tmp_dirW)/sizeof(*tmp_dirW));
|
|
|
|
len_with_null = lstrlenW(tmp_dirW) + 1;
|
|
|
|
|
|
|
|
/* This one is different from ANSI version: ANSI version doesn't
|
|
|
|
* touch the buffer, unicode version usually truncates the buffer
|
2008-04-03 19:10:30 +02:00
|
|
|
* to zero size. NT still exaggerates the required buffer size
|
2002-12-11 01:16:31 +01:00
|
|
|
* sometimes so we cannot test for an exact match. Finally, the
|
|
|
|
* 'len_with_null - 1' case is so buggy on Windows it's not testable.
|
|
|
|
* For instance on NT4 it will sometimes return a path without the
|
|
|
|
* trailing '\\' and sometimes return an error.
|
|
|
|
*/
|
|
|
|
|
2002-08-27 03:56:08 +02:00
|
|
|
lstrcpyW(buf, fooW);
|
|
|
|
len = GetTempPathW(MAX_PATH, buf);
|
2009-05-18 11:24:42 +02:00
|
|
|
if (len == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("GetTempPathW is not available\n");
|
2002-12-11 01:16:31 +01:00
|
|
|
return;
|
2009-05-18 11:24:42 +02:00
|
|
|
}
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
|
|
|
|
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
lstrcpyW(buf, fooW);
|
|
|
|
len = GetTempPathW(1, buf);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(buf[0] == 0, "unicode version should truncate the buffer to zero size\n");
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
2002-12-11 01:16:31 +01:00
|
|
|
len = GetTempPathW(0, NULL);
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
lstrcpyW(buf, fooW);
|
2002-12-11 01:16:31 +01:00
|
|
|
len = GetTempPathW(len, buf);
|
2004-02-06 06:24:34 +01:00
|
|
|
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
|
|
|
|
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
2015-02-24 02:41:32 +01:00
|
|
|
|
|
|
|
for(len = 0; len < sizeof(buf) / sizeof(buf[0]); len++)
|
|
|
|
buf[len] = 'a';
|
|
|
|
len = GetTempPathW(len, buf);
|
|
|
|
ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
|
|
|
|
ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
|
|
|
|
/* The rest of the buffer must be zeroed */
|
|
|
|
for(len++; len < sizeof(buf) / sizeof(buf[0]); len++)
|
|
|
|
todo_wine
|
|
|
|
ok(buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, buf[len]);
|
2002-08-27 03:56:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetTempPath(void)
|
|
|
|
{
|
|
|
|
char save_TMP[MAX_PATH];
|
|
|
|
char windir[MAX_PATH];
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
2009-01-27 14:49:47 +01:00
|
|
|
if (!GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP))) save_TMP[0] = 0;
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
/* test default configuration */
|
|
|
|
trace("TMP=%s\n", save_TMP);
|
2009-01-27 14:49:47 +01:00
|
|
|
if (save_TMP[0])
|
|
|
|
{
|
|
|
|
strcpy(buf,save_TMP);
|
|
|
|
if (buf[strlen(buf)-1]!='\\')
|
|
|
|
strcat(buf,"\\");
|
|
|
|
test_GetTempPathA(buf);
|
|
|
|
test_GetTempPathW(buf);
|
|
|
|
}
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
/* TMP=C:\WINDOWS */
|
|
|
|
GetWindowsDirectoryA(windir, sizeof(windir));
|
|
|
|
SetEnvironmentVariableA("TMP", windir);
|
|
|
|
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
|
|
|
trace("TMP=%s\n", buf);
|
2002-12-11 01:16:31 +01:00
|
|
|
strcat(windir,"\\");
|
|
|
|
test_GetTempPathA(windir);
|
|
|
|
test_GetTempPathW(windir);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
/* TMP=C:\ */
|
|
|
|
GetWindowsDirectoryA(windir, sizeof(windir));
|
|
|
|
windir[3] = 0;
|
|
|
|
SetEnvironmentVariableA("TMP", windir);
|
|
|
|
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
|
|
|
trace("TMP=%s\n", buf);
|
2002-12-11 01:16:31 +01:00
|
|
|
test_GetTempPathA(windir);
|
|
|
|
test_GetTempPathW(windir);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
/* TMP=C: i.e. use current working directory of the specified drive */
|
|
|
|
GetWindowsDirectoryA(windir, sizeof(windir));
|
|
|
|
SetCurrentDirectoryA(windir);
|
|
|
|
windir[2] = 0;
|
|
|
|
SetEnvironmentVariableA("TMP", windir);
|
|
|
|
GetEnvironmentVariableA("TMP", buf, sizeof(buf));
|
|
|
|
trace("TMP=%s\n", buf);
|
2002-12-11 01:16:31 +01:00
|
|
|
GetWindowsDirectoryA(windir, sizeof(windir));
|
|
|
|
strcat(windir,"\\");
|
|
|
|
test_GetTempPathA(windir);
|
|
|
|
test_GetTempPathW(windir);
|
2002-08-27 03:56:08 +02:00
|
|
|
|
|
|
|
SetEnvironmentVariableA("TMP", save_TMP);
|
|
|
|
}
|
|
|
|
|
2009-12-02 15:18:16 +01:00
|
|
|
static void test_GetLongPathNameA(void)
|
|
|
|
{
|
2009-12-04 12:43:40 +01:00
|
|
|
DWORD length, explength, hostsize;
|
2009-12-02 15:18:16 +01:00
|
|
|
char tempfile[MAX_PATH];
|
|
|
|
char longpath[MAX_PATH];
|
|
|
|
char unc_prefix[MAX_PATH];
|
|
|
|
char unc_short[MAX_PATH], unc_long[MAX_PATH];
|
|
|
|
char temppath[MAX_PATH], temppath2[MAX_PATH];
|
|
|
|
HANDLE file;
|
|
|
|
|
|
|
|
if (!pGetLongPathNameA)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetTempPathA(MAX_PATH, tempfile);
|
|
|
|
lstrcatA(tempfile, "longfilename.longext");
|
|
|
|
|
|
|
|
file = CreateFileA(tempfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
/* Test a normal path with a small buffer size */
|
|
|
|
memset(temppath, 0, MAX_PATH);
|
|
|
|
length = pGetLongPathNameA(tempfile, temppath, 4);
|
2010-03-20 15:24:53 +01:00
|
|
|
/* We have a failure so length should be the minimum plus the terminating '0' */
|
2013-10-21 10:02:20 +02:00
|
|
|
ok(length >= strlen(tempfile) + 1, "Wrong length\n");
|
2009-12-02 15:18:16 +01:00
|
|
|
ok(temppath[0] == 0, "Buffer should not have been touched\n");
|
|
|
|
|
|
|
|
/* Some UNC syntax tests */
|
|
|
|
|
|
|
|
memset(temppath, 0, MAX_PATH);
|
|
|
|
memset(temppath2, 0, MAX_PATH);
|
|
|
|
lstrcpyA(temppath2, "\\\\?\\");
|
|
|
|
lstrcatA(temppath2, tempfile);
|
2009-12-04 12:43:40 +01:00
|
|
|
explength = length + 4;
|
2009-12-02 15:18:16 +01:00
|
|
|
|
2009-12-04 13:10:15 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2009-12-02 15:18:16 +01:00
|
|
|
length = pGetLongPathNameA(temppath2, NULL, 0);
|
2009-12-04 13:10:15 +01:00
|
|
|
if (length == 0 && GetLastError() == ERROR_BAD_NET_NAME)
|
|
|
|
{
|
|
|
|
win_skip("UNC syntax tests don't work on Win98/WinMe\n");
|
|
|
|
DeleteFileA(tempfile);
|
|
|
|
return;
|
|
|
|
}
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
|
|
|
|
length = pGetLongPathNameA(temppath2, NULL, MAX_PATH);
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
|
|
|
|
length = pGetLongPathNameA(temppath2, temppath, 4);
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
ok(temppath[0] == 0, "Buffer should not have been touched\n");
|
|
|
|
|
|
|
|
/* Now an UNC path with the computername */
|
|
|
|
lstrcpyA(unc_prefix, "\\\\");
|
|
|
|
hostsize = sizeof(unc_prefix) - 2;
|
2013-10-21 10:02:20 +02:00
|
|
|
GetComputerNameA(unc_prefix + 2, &hostsize);
|
2009-12-02 15:18:16 +01:00
|
|
|
lstrcatA(unc_prefix, "\\");
|
|
|
|
|
|
|
|
/* Create a short syntax for the whole unc path */
|
|
|
|
memset(unc_short, 0, MAX_PATH);
|
|
|
|
GetShortPathNameA(tempfile, temppath, MAX_PATH);
|
|
|
|
lstrcpyA(unc_short, unc_prefix);
|
|
|
|
unc_short[lstrlenA(unc_short)] = temppath[0];
|
|
|
|
lstrcatA(unc_short, "$\\");
|
|
|
|
lstrcatA(unc_short, strchr(temppath, '\\') + 1);
|
|
|
|
|
|
|
|
/* Create a long syntax for reference */
|
|
|
|
memset(longpath, 0, MAX_PATH);
|
|
|
|
pGetLongPathNameA(tempfile, temppath, MAX_PATH);
|
|
|
|
lstrcpyA(longpath, unc_prefix);
|
|
|
|
longpath[lstrlenA(longpath)] = temppath[0];
|
|
|
|
lstrcatA(longpath, "$\\");
|
|
|
|
lstrcatA(longpath, strchr(temppath, '\\') + 1);
|
|
|
|
|
|
|
|
/* NULL test */
|
2009-12-04 13:43:08 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2009-12-02 15:18:16 +01:00
|
|
|
length = pGetLongPathNameA(unc_short, NULL, 0);
|
2009-12-04 13:43:08 +01:00
|
|
|
if (length == 0 && GetLastError() == ERROR_BAD_NETPATH)
|
|
|
|
{
|
|
|
|
/* Seen on Window XP Home */
|
|
|
|
win_skip("UNC with computername is not supported\n");
|
|
|
|
DeleteFileA(tempfile);
|
|
|
|
return;
|
|
|
|
}
|
2009-12-04 12:43:40 +01:00
|
|
|
explength = lstrlenA(longpath) + 1;
|
2009-12-02 15:18:16 +01:00
|
|
|
todo_wine
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
|
|
|
|
length = pGetLongPathNameA(unc_short, NULL, MAX_PATH);
|
|
|
|
todo_wine
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
|
|
|
|
memset(unc_long, 0, MAX_PATH);
|
|
|
|
length = pGetLongPathNameA(unc_short, unc_long, lstrlenA(unc_short));
|
|
|
|
/* length will include terminating '0' on failure */
|
|
|
|
todo_wine
|
2009-12-04 12:43:40 +01:00
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
ok(unc_long[0] == 0, "Buffer should not have been touched\n");
|
|
|
|
|
|
|
|
memset(unc_long, 0, MAX_PATH);
|
|
|
|
length = pGetLongPathNameA(unc_short, unc_long, length);
|
|
|
|
/* length doesn't include terminating '0' on success */
|
2009-12-04 12:43:40 +01:00
|
|
|
explength--;
|
2009-12-02 15:18:16 +01:00
|
|
|
todo_wine
|
2009-12-04 12:43:40 +01:00
|
|
|
{
|
|
|
|
ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
|
2009-12-02 15:18:16 +01:00
|
|
|
ok(!lstrcmpiA(unc_long, longpath), "Expected (%s), got (%s)\n", longpath, unc_long);
|
2009-12-04 12:43:40 +01:00
|
|
|
}
|
2009-12-02 15:18:16 +01:00
|
|
|
|
|
|
|
DeleteFileA(tempfile);
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:21:31 +02:00
|
|
|
static void test_GetLongPathNameW(void)
|
|
|
|
{
|
2009-12-17 10:44:38 +01:00
|
|
|
DWORD length, expanded;
|
|
|
|
BOOL ret;
|
|
|
|
HANDLE file;
|
2006-09-29 09:21:31 +02:00
|
|
|
WCHAR empty[MAX_PATH];
|
2009-12-17 10:44:38 +01:00
|
|
|
WCHAR tempdir[MAX_PATH], name[200];
|
|
|
|
WCHAR dirpath[4 + MAX_PATH + 200]; /* To ease removal */
|
|
|
|
WCHAR shortpath[4 + MAX_PATH + 200 + 1 + 200];
|
|
|
|
static const WCHAR prefix[] = { '\\','\\','?','\\', 0};
|
|
|
|
static const WCHAR backslash[] = { '\\', 0};
|
|
|
|
static const WCHAR letterX[] = { 'X', 0};
|
|
|
|
|
|
|
|
if (!pGetLongPathNameW)
|
|
|
|
return;
|
2006-09-29 09:21:31 +02:00
|
|
|
|
2006-11-19 16:31:51 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = pGetLongPathNameW(NULL,NULL,0);
|
2007-04-25 13:21:19 +02:00
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("GetLongPathNameW is not implemented\n");
|
2007-04-25 13:21:19 +02:00
|
|
|
return;
|
|
|
|
}
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
|
2007-01-04 10:54:10 +01:00
|
|
|
ok(GetLastError()==ERROR_INVALID_PARAMETER,"GetLastError returned %d but expected ERROR_INVALID_PARAMETER\n",GetLastError());
|
2006-09-29 09:21:31 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
empty[0]=0;
|
|
|
|
length = pGetLongPathNameW(empty,NULL,0);
|
2006-10-10 01:06:48 +02:00
|
|
|
ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
|
2007-01-04 10:54:10 +01:00
|
|
|
ok(GetLastError()==ERROR_PATH_NOT_FOUND,"GetLastError returned %d but expected ERROR_PATH_NOT_FOUND\n",GetLastError());
|
2009-12-17 10:44:38 +01:00
|
|
|
|
|
|
|
/* Create a long path name. The path needs to exist for these tests to
|
|
|
|
* succeed so we need the "\\?\" prefix when creating directories and
|
|
|
|
* files.
|
|
|
|
*/
|
|
|
|
name[0] = 0;
|
|
|
|
while (lstrlenW(name) < (sizeof(name)/sizeof(WCHAR) - 1))
|
|
|
|
lstrcatW(name, letterX);
|
|
|
|
|
|
|
|
GetTempPathW(MAX_PATH, tempdir);
|
|
|
|
|
|
|
|
lstrcpyW(shortpath, prefix);
|
|
|
|
lstrcatW(shortpath, tempdir);
|
|
|
|
lstrcatW(shortpath, name);
|
|
|
|
lstrcpyW(dirpath, shortpath);
|
|
|
|
ret = CreateDirectoryW(shortpath, NULL);
|
|
|
|
ok(ret, "Could not create the temporary directory : %d\n", GetLastError());
|
|
|
|
lstrcatW(shortpath, backslash);
|
|
|
|
lstrcatW(shortpath, name);
|
|
|
|
|
|
|
|
/* Path does not exist yet and we know it overruns MAX_PATH */
|
|
|
|
|
|
|
|
/* No prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = pGetLongPathNameW(shortpath + 4, NULL, 0);
|
|
|
|
ok(length == 0, "Expected 0, got %d\n", length);
|
|
|
|
todo_wine
|
|
|
|
ok(GetLastError() == ERROR_PATH_NOT_FOUND,
|
|
|
|
"Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
|
|
|
|
/* With prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = pGetLongPathNameW(shortpath, NULL, 0);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(length == 0, "Expected 0, got %d\n", length);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
|
|
|
|
"Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
file = CreateFileW(shortpath, GENERIC_READ|GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE,
|
|
|
|
"Could not create the temporary file : %d.\n", GetLastError());
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
/* Path exists */
|
|
|
|
|
|
|
|
/* No prefix */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = pGetLongPathNameW(shortpath + 4, NULL, 0);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(length == 0, "Expected 0, got %d\n", length);
|
|
|
|
ok(GetLastError() == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
|
2006-09-29 09:21:31 +02:00
|
|
|
}
|
2009-12-17 10:44:38 +01:00
|
|
|
/* With prefix */
|
|
|
|
expanded = 4 + (pGetLongPathNameW(tempdir, NULL, 0) - 1) + lstrlenW(name) + 1 + lstrlenW(name) + 1;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = pGetLongPathNameW(shortpath, NULL, 0);
|
|
|
|
ok(length == expanded, "Expected %d, got %d\n", expanded, length);
|
|
|
|
|
|
|
|
/* NULL buffer with length crashes on Windows */
|
|
|
|
if (0)
|
2011-02-10 22:27:59 +01:00
|
|
|
pGetLongPathNameW(shortpath, NULL, 20);
|
2009-12-17 10:44:38 +01:00
|
|
|
|
|
|
|
ok(DeleteFileW(shortpath), "Could not delete temporary file\n");
|
|
|
|
ok(RemoveDirectoryW(dirpath), "Could not delete temporary directory\n");
|
2006-09-29 09:21:31 +02:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:15:09 +02:00
|
|
|
static void test_GetShortPathNameW(void)
|
|
|
|
{
|
|
|
|
WCHAR test_path[] = { 'L', 'o', 'n', 'g', 'D', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', 'N', 'a', 'm', 'e', 0 };
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
WCHAR short_path[MAX_PATH];
|
|
|
|
DWORD length;
|
|
|
|
HANDLE file;
|
|
|
|
int ret;
|
|
|
|
WCHAR name[] = { 't', 'e', 's', 't', 0 };
|
|
|
|
WCHAR backSlash[] = { '\\', 0 };
|
|
|
|
|
2008-01-10 11:05:35 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2007-07-19 11:15:09 +02:00
|
|
|
GetTempPathW( MAX_PATH, path );
|
2008-01-10 11:05:35 +01:00
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("GetTempPathW is not implemented\n");
|
2008-01-10 11:05:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-19 11:15:09 +02:00
|
|
|
lstrcatW( path, test_path );
|
|
|
|
lstrcatW( path, backSlash );
|
|
|
|
ret = CreateDirectoryW( path, NULL );
|
|
|
|
ok( ret, "Directory was not created. LastError = %d\n", GetLastError() );
|
|
|
|
|
|
|
|
/* Starting a main part of test */
|
|
|
|
length = GetShortPathNameW( path, short_path, 0 );
|
|
|
|
ok( length, "GetShortPathNameW returned 0.\n" );
|
|
|
|
ret = GetShortPathNameW( path, short_path, length );
|
|
|
|
ok( ret, "GetShortPathNameW returned 0.\n" );
|
2013-07-04 06:43:11 +02:00
|
|
|
|
2007-07-19 11:15:09 +02:00
|
|
|
lstrcatW( short_path, name );
|
2013-07-04 06:43:11 +02:00
|
|
|
|
|
|
|
/* GetShortPathName for a non-existent short file name should fail */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
length = GetShortPathNameW( short_path, path, 0 );
|
|
|
|
ok(!length, "GetShortPathNameW should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
|
|
|
|
|
2007-07-19 11:15:09 +02:00
|
|
|
file = CreateFileW( short_path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
|
ok( file != INVALID_HANDLE_VALUE, "File was not created.\n" );
|
|
|
|
|
|
|
|
/* End test */
|
|
|
|
CloseHandle( file );
|
|
|
|
ret = DeleteFileW( short_path );
|
2007-07-31 18:57:34 +02:00
|
|
|
ok( ret, "Cannot delete file.\n" );
|
2007-07-19 11:15:09 +02:00
|
|
|
ret = RemoveDirectoryW( path );
|
2007-07-31 18:57:34 +02:00
|
|
|
ok( ret, "Cannot delete directory.\n" );
|
2007-07-19 11:15:09 +02:00
|
|
|
}
|
|
|
|
|
2006-12-03 22:38:21 +01:00
|
|
|
static void test_GetSystemDirectory(void)
|
|
|
|
{
|
|
|
|
CHAR buffer[MAX_PATH + 4];
|
|
|
|
DWORD res;
|
|
|
|
DWORD total;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(NULL, 0);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* res includes the terminating Zero */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok(res > 0, "returned %d with %d (expected '>0')\n", res, GetLastError());
|
2006-12-03 22:38:21 +01:00
|
|
|
|
|
|
|
total = res;
|
2007-01-06 19:32:56 +01:00
|
|
|
|
|
|
|
/* this crashes on XP */
|
2011-02-10 22:27:59 +01:00
|
|
|
if (0)
|
2013-10-21 10:02:20 +02:00
|
|
|
GetSystemDirectoryA(NULL, total);
|
2006-12-03 22:38:21 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(NULL, total-1);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* 95+NT: total (includes the terminating Zero)
|
|
|
|
98+ME: 0 with ERROR_INVALID_PARAMETER */
|
|
|
|
ok( (res == total) || (!res && (GetLastError() == ERROR_INVALID_PARAMETER)),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d (expected '%d' or: '0' with "
|
2006-12-03 22:38:21 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError(), total);
|
|
|
|
|
|
|
|
if (total > MAX_PATH) return;
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(buffer, total);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* res does not include the terminating Zero */
|
|
|
|
ok( (res == (total-1)) && (buffer[0]),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d and '%s' (expected '%d' and a string)\n",
|
2006-12-03 22:38:21 +01:00
|
|
|
res, GetLastError(), buffer, total-1);
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(buffer, total + 1);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* res does not include the terminating Zero */
|
|
|
|
ok( (res == (total-1)) && (buffer[0]),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d and '%s' (expected '%d' and a string)\n",
|
2006-12-03 22:38:21 +01:00
|
|
|
res, GetLastError(), buffer, total-1);
|
|
|
|
|
|
|
|
memset(buffer, '#', total + 1);
|
|
|
|
buffer[total + 2] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(buffer, total-1);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* res includes the terminating Zero) */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
|
2006-12-03 22:38:21 +01:00
|
|
|
res, GetLastError(), buffer, total);
|
|
|
|
|
|
|
|
memset(buffer, '#', total + 1);
|
|
|
|
buffer[total + 2] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetSystemDirectoryA(buffer, total-2);
|
2006-12-03 22:38:21 +01:00
|
|
|
/* res includes the terminating Zero) */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
|
2006-12-03 22:38:21 +01:00
|
|
|
res, GetLastError(), buffer, total);
|
|
|
|
}
|
|
|
|
|
2006-12-03 22:38:50 +01:00
|
|
|
static void test_GetWindowsDirectory(void)
|
|
|
|
{
|
|
|
|
CHAR buffer[MAX_PATH + 4];
|
|
|
|
DWORD res;
|
|
|
|
DWORD total;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(NULL, 0);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* res includes the terminating Zero */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok(res > 0, "returned %d with %d (expected '>0')\n", res, GetLastError());
|
2006-12-03 22:38:50 +01:00
|
|
|
|
|
|
|
total = res;
|
2007-01-06 19:32:56 +01:00
|
|
|
/* this crashes on XP */
|
2011-02-10 22:27:59 +01:00
|
|
|
if (0)
|
2013-10-21 10:02:20 +02:00
|
|
|
GetWindowsDirectoryA(NULL, total);
|
2006-12-03 22:38:50 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(NULL, total-1);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* 95+NT: total (includes the terminating Zero)
|
|
|
|
98+ME: 0 with ERROR_INVALID_PARAMETER */
|
|
|
|
ok( (res == total) || (!res && (GetLastError() == ERROR_INVALID_PARAMETER)),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d (expected '%d' or: '0' with "
|
2006-12-03 22:38:50 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError(), total);
|
|
|
|
|
|
|
|
if (total > MAX_PATH) return;
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(buffer, total);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* res does not include the terminating Zero */
|
|
|
|
ok( (res == (total-1)) && (buffer[0]),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d and '%s' (expected '%d' and a string)\n",
|
2006-12-03 22:38:50 +01:00
|
|
|
res, GetLastError(), buffer, total-1);
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(buffer, total + 1);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* res does not include the terminating Zero */
|
|
|
|
ok( (res == (total-1)) && (buffer[0]),
|
2007-01-04 10:54:10 +01:00
|
|
|
"returned %d with %d and '%s' (expected '%d' and a string)\n",
|
2006-12-03 22:38:50 +01:00
|
|
|
res, GetLastError(), buffer, total-1);
|
|
|
|
|
|
|
|
memset(buffer, '#', total + 1);
|
|
|
|
buffer[total + 2] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(buffer, total-1);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* res includes the terminating Zero) */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
|
2006-12-03 22:38:50 +01:00
|
|
|
res, GetLastError(), buffer, total);
|
|
|
|
|
|
|
|
memset(buffer, '#', total + 1);
|
|
|
|
buffer[total + 2] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
res = GetWindowsDirectoryA(buffer, total-2);
|
2006-12-03 22:38:50 +01:00
|
|
|
/* res includes the terminating Zero) */
|
2007-01-04 10:54:10 +01:00
|
|
|
ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
|
2006-12-03 22:38:50 +01:00
|
|
|
res, GetLastError(), buffer, total);
|
|
|
|
}
|
|
|
|
|
2007-04-25 09:41:11 +02:00
|
|
|
static void test_NeedCurrentDirectoryForExePathA(void)
|
|
|
|
{
|
2009-12-21 18:21:16 +01:00
|
|
|
if (!pNeedCurrentDirectoryForExePathA)
|
|
|
|
{
|
|
|
|
win_skip("NeedCurrentDirectoryForExePathA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-25 09:41:11 +02:00
|
|
|
/* Crashes in Windows */
|
|
|
|
if (0)
|
2011-02-10 22:27:59 +01:00
|
|
|
pNeedCurrentDirectoryForExePathA(NULL);
|
2007-04-25 09:41:11 +02:00
|
|
|
|
|
|
|
SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL);
|
|
|
|
ok(pNeedCurrentDirectoryForExePathA("."), "returned FALSE for \".\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathA("c:\\"), "returned FALSE for \"c:\\\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned FALSE for \"cmd.exe\"\n");
|
|
|
|
|
|
|
|
SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya");
|
|
|
|
ok(!pNeedCurrentDirectoryForExePathA("."), "returned TRUE for \".\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathA("c:\\"), "returned FALSE for \"c:\\\"\n");
|
|
|
|
ok(!pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned TRUE for \"cmd.exe\"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_NeedCurrentDirectoryForExePathW(void)
|
|
|
|
{
|
|
|
|
const WCHAR thispath[] = {'.', 0};
|
|
|
|
const WCHAR fullpath[] = {'c', ':', '\\', 0};
|
|
|
|
const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0};
|
|
|
|
|
2009-12-21 18:21:16 +01:00
|
|
|
if (!pNeedCurrentDirectoryForExePathW)
|
|
|
|
{
|
|
|
|
win_skip("NeedCurrentDirectoryForExePathW is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-25 09:41:11 +02:00
|
|
|
/* Crashes in Windows */
|
|
|
|
if (0)
|
2011-02-10 22:27:59 +01:00
|
|
|
pNeedCurrentDirectoryForExePathW(NULL);
|
2007-04-25 09:41:11 +02:00
|
|
|
|
|
|
|
SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL);
|
|
|
|
ok(pNeedCurrentDirectoryForExePathW(thispath), "returned FALSE for \".\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for \"c:\\\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathW(cmdname), "returned FALSE for \"cmd.exe\"\n");
|
|
|
|
|
|
|
|
SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya");
|
|
|
|
ok(!pNeedCurrentDirectoryForExePathW(thispath), "returned TRUE for \".\"\n");
|
|
|
|
ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for \"c:\\\"\n");
|
|
|
|
ok(!pNeedCurrentDirectoryForExePathW(cmdname), "returned TRUE for \"cmd.exe\"\n");
|
|
|
|
}
|
|
|
|
|
2008-02-27 12:58:40 +01:00
|
|
|
/* Call various path/file name retrieving APIs and check the case of
|
|
|
|
* the returned drive letter. Some apps (for instance Adobe Photoshop CS3
|
2008-03-17 21:51:39 +01:00
|
|
|
* installer) depend on the drive letter being in upper case.
|
2008-02-27 12:58:40 +01:00
|
|
|
*/
|
|
|
|
static void test_drive_letter_case(void)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
|
|
|
#define is_upper_case_letter(a) ((a) >= 'A' && (a) <= 'Z')
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetWindowsDirectoryA(buf, sizeof(buf));
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetWindowsDirectory error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
|
|
|
/* re-use the buffer returned by GetFullPathName */
|
|
|
|
buf[2] = '/';
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetFullPathNameA(buf + 2, sizeof(buf), buf, NULL);
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetFullPathName error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetSystemDirectoryA(buf, sizeof(buf));
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetSystemDirectory error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetCurrentDirectoryA(sizeof(buf), buf);
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetCurrentDirectory error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
2008-05-08 01:31:02 +02:00
|
|
|
/* TEMP is an environment variable, so it can't be tested for case-sensitivity */
|
2008-02-27 12:58:40 +01:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetTempPathA(sizeof(buf), buf);
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetTempPath error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
2009-01-27 14:49:47 +01:00
|
|
|
if (buf[0])
|
|
|
|
{
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(buf[strlen(buf)-1] == '\\', "Temporary path (%s) doesn't end in a slash\n", buf);
|
|
|
|
}
|
2008-02-27 12:58:40 +01:00
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetFullPathNameA(".", sizeof(buf), buf, NULL);
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetFullPathName error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
|
|
|
/* re-use the buffer returned by GetFullPathName */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-21 10:02:20 +02:00
|
|
|
ret = GetShortPathNameA(buf, buf, sizeof(buf));
|
2008-02-27 12:58:40 +01:00
|
|
|
ok(ret, "GetShortPathName error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
|
|
|
|
if (pGetLongPathNameA)
|
|
|
|
{
|
|
|
|
/* re-use the buffer returned by GetShortPathName */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pGetLongPathNameA(buf, buf, sizeof(buf));
|
|
|
|
ok(ret, "GetLongPathNameA error %u\n", GetLastError());
|
|
|
|
ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
|
|
|
|
ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
|
|
|
|
ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
|
|
|
|
}
|
|
|
|
#undef is_upper_case_letter
|
|
|
|
}
|
|
|
|
|
2013-09-06 16:39:48 +02:00
|
|
|
static const char manifest_dep[] =
|
|
|
|
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
|
|
|
|
"<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
|
|
|
|
" <file name=\"testdep.dll\" />"
|
2013-11-22 15:12:37 +01:00
|
|
|
" <file name=\"ole32\" />"
|
2013-09-06 16:39:48 +02:00
|
|
|
" <file name=\"kernel32.dll\" />"
|
|
|
|
"</assembly>";
|
|
|
|
|
|
|
|
static const char manifest_main[] =
|
|
|
|
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
|
|
|
|
"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
|
|
|
|
"<dependency>"
|
|
|
|
" <dependentAssembly>"
|
|
|
|
" <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
|
|
|
|
" </dependentAssembly>"
|
|
|
|
"</dependency>"
|
|
|
|
"</assembly>";
|
|
|
|
|
|
|
|
static void create_manifest_file(const char *filename, const char *manifest)
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH], manifest_path[MAX_PATH];
|
|
|
|
HANDLE file;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
|
|
|
|
|
|
|
|
GetTempPathW(sizeof(manifest_path)/sizeof(WCHAR), manifest_path);
|
|
|
|
lstrcatW(manifest_path, path);
|
|
|
|
|
|
|
|
file = CreateFileW(manifest_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
|
|
|
|
WriteFile(file, manifest, strlen(manifest), &size, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_manifest_file(const char *filename)
|
|
|
|
{
|
|
|
|
CHAR path[MAX_PATH];
|
|
|
|
|
|
|
|
GetTempPathA(sizeof(path), path);
|
|
|
|
strcat(path, filename);
|
|
|
|
DeleteFileA(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE test_create(const char *file)
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH], manifest_path[MAX_PATH];
|
|
|
|
ACTCTXW actctx;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);
|
|
|
|
GetTempPathW(sizeof(manifest_path)/sizeof(WCHAR), manifest_path);
|
|
|
|
lstrcatW(manifest_path, path);
|
|
|
|
|
|
|
|
memset(&actctx, 0, sizeof(ACTCTXW));
|
|
|
|
actctx.cbSize = sizeof(ACTCTXW);
|
|
|
|
actctx.lpSource = manifest_path;
|
|
|
|
|
|
|
|
handle = pCreateActCtxW(&actctx);
|
|
|
|
ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError());
|
|
|
|
|
|
|
|
ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize);
|
|
|
|
ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags);
|
|
|
|
ok(actctx.lpSource == manifest_path, "lpSource=%p\n", actctx.lpSource);
|
|
|
|
ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
|
|
|
|
ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId);
|
|
|
|
ok(actctx.lpAssemblyDirectory == NULL, "lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
|
|
|
|
ok(actctx.lpResourceName == NULL, "lpResourceName=%p\n", actctx.lpResourceName);
|
|
|
|
ok(actctx.lpApplicationName == NULL, "lpApplicationName=%p\n", actctx.lpApplicationName);
|
|
|
|
ok(actctx.hModule == NULL, "hModule=%p\n", actctx.hModule);
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2009-12-21 21:00:38 +01:00
|
|
|
static void test_SearchPathA(void)
|
|
|
|
{
|
2013-09-06 16:39:48 +02:00
|
|
|
static const CHAR testdepA[] = "testdep.dll";
|
2013-09-11 10:18:25 +02:00
|
|
|
static const CHAR testdeprelA[] = "./testdep.dll";
|
2013-09-06 16:39:48 +02:00
|
|
|
static const CHAR kernel32A[] = "kernel32.dll";
|
|
|
|
static const CHAR fileA[] = "";
|
|
|
|
CHAR pathA[MAX_PATH], buffA[MAX_PATH], path2A[MAX_PATH];
|
2009-12-21 21:00:38 +01:00
|
|
|
CHAR *ptrA = NULL;
|
2013-09-06 16:39:48 +02:00
|
|
|
ULONG_PTR cookie;
|
|
|
|
HANDLE handle;
|
2009-12-21 21:00:38 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (!pSearchPathA)
|
|
|
|
{
|
|
|
|
win_skip("SearchPathA isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetWindowsDirectoryA(pathA, sizeof(pathA)/sizeof(CHAR));
|
|
|
|
|
|
|
|
/* NULL filename */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pSearchPathA(pathA, NULL, NULL, sizeof(buffA)/sizeof(CHAR), buffA, &ptrA);
|
|
|
|
ok(ret == 0, "Expected failure, got %d\n", ret);
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
|
|
|
|
|
|
|
|
/* empty filename */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pSearchPathA(pathA, fileA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, &ptrA);
|
|
|
|
ok(ret == 0, "Expected failure, got %d\n", ret);
|
2011-02-23 10:38:49 +01:00
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
2009-12-21 21:00:38 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
|
2013-09-06 16:39:48 +02:00
|
|
|
|
|
|
|
if (!pActivateActCtx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
create_manifest_file("testdep1.manifest", manifest_dep);
|
|
|
|
create_manifest_file("main.manifest", manifest_main);
|
|
|
|
|
|
|
|
handle = test_create("main.manifest");
|
|
|
|
delete_manifest_file("testdep1.manifest");
|
|
|
|
delete_manifest_file("main.manifest");
|
|
|
|
|
|
|
|
/* search fails without active context */
|
|
|
|
ret = pSearchPathA(NULL, testdepA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pSearchPathA(NULL, kernel32A, NULL, sizeof(path2A)/sizeof(CHAR), path2A, NULL);
|
|
|
|
ok(ret && ret == strlen(path2A), "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pActivateActCtx(handle, &cookie);
|
|
|
|
ok(ret, "failed to activate context, %u\n", GetLastError());
|
|
|
|
|
|
|
|
/* works when activated */
|
|
|
|
ret = pSearchPathA(NULL, testdepA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(ret && ret == strlen(buffA), "got %d\n", ret);
|
|
|
|
|
2013-09-11 10:18:25 +02:00
|
|
|
ret = pSearchPathA(NULL, "testdep.dll", ".ext", sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(ret && ret == strlen(buffA), "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pSearchPathA(NULL, "testdep", ".dll", sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(ret && ret == strlen(buffA), "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pSearchPathA(NULL, "testdep", ".ext", sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* name contains path */
|
|
|
|
ret = pSearchPathA(NULL, testdeprelA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* fails with specified path that doesn't contain this file */
|
|
|
|
ret = pSearchPathA(pathA, testdepA, NULL, sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* path is redirected for wellknown names too */
|
2013-09-06 16:39:48 +02:00
|
|
|
ret = pSearchPathA(NULL, kernel32A, NULL, sizeof(buffA)/sizeof(CHAR), buffA, NULL);
|
|
|
|
ok(ret && ret == strlen(buffA), "got %d\n", ret);
|
|
|
|
ok(strcmp(buffA, path2A), "got wrong path %s, %s\n", buffA, path2A);
|
|
|
|
|
|
|
|
ret = pDeactivateActCtx(0, cookie);
|
|
|
|
ok(ret, "failed to deactivate context, %u\n", GetLastError());
|
|
|
|
pReleaseActCtx(handle);
|
2009-12-21 21:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SearchPathW(void)
|
|
|
|
{
|
2013-09-11 10:18:25 +02:00
|
|
|
static const WCHAR testdeprelW[] = {'.','/','t','e','s','t','d','e','p','.','d','l','l',0};
|
2013-09-06 16:39:48 +02:00
|
|
|
static const WCHAR testdepW[] = {'t','e','s','t','d','e','p','.','d','l','l',0};
|
2013-09-11 10:18:25 +02:00
|
|
|
static const WCHAR testdep1W[] = {'t','e','s','t','d','e','p',0};
|
2013-11-22 15:12:37 +01:00
|
|
|
static const WCHAR kernel32dllW[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
|
|
|
|
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
|
|
|
|
static const WCHAR ole32W[] = {'o','l','e','3','2',0};
|
2013-09-11 10:18:25 +02:00
|
|
|
static const WCHAR extW[] = {'.','e','x','t',0};
|
|
|
|
static const WCHAR dllW[] = {'.','d','l','l',0};
|
2013-09-06 16:39:48 +02:00
|
|
|
static const WCHAR fileW[] = { 0 };
|
|
|
|
WCHAR pathW[MAX_PATH], buffW[MAX_PATH], path2W[MAX_PATH];
|
2009-12-21 21:00:38 +01:00
|
|
|
WCHAR *ptrW = NULL;
|
2013-09-06 16:39:48 +02:00
|
|
|
ULONG_PTR cookie;
|
|
|
|
HANDLE handle;
|
2009-12-21 21:00:38 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (!pSearchPathW)
|
|
|
|
{
|
|
|
|
win_skip("SearchPathW isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* NULL filename, crashes on nt4 */
|
2011-02-10 22:27:59 +01:00
|
|
|
pSearchPathW(pathW, NULL, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, &ptrW);
|
2009-12-21 21:00:38 +01:00
|
|
|
}
|
|
|
|
|
2013-09-11 10:18:25 +02:00
|
|
|
GetWindowsDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR));
|
|
|
|
|
2009-12-21 21:00:38 +01:00
|
|
|
/* empty filename */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pSearchPathW(pathW, fileW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, &ptrW);
|
|
|
|
ok(ret == 0, "Expected failure, got %d\n", ret);
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
|
2013-09-06 16:39:48 +02:00
|
|
|
|
|
|
|
if (!pActivateActCtx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
create_manifest_file("testdep1.manifest", manifest_dep);
|
|
|
|
create_manifest_file("main.manifest", manifest_main);
|
|
|
|
|
|
|
|
handle = test_create("main.manifest");
|
|
|
|
delete_manifest_file("testdep1.manifest");
|
|
|
|
delete_manifest_file("main.manifest");
|
|
|
|
|
|
|
|
/* search fails without active context */
|
|
|
|
ret = pSearchPathW(NULL, testdepW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
2013-11-22 15:12:37 +01:00
|
|
|
ret = pSearchPathW(NULL, kernel32dllW, NULL, sizeof(path2W)/sizeof(WCHAR), path2W, NULL);
|
2013-09-06 16:39:48 +02:00
|
|
|
ok(ret && ret == lstrlenW(path2W), "got %d\n", ret);
|
|
|
|
|
2013-11-22 15:12:37 +01:00
|
|
|
/* full path, name without 'dll' extension */
|
|
|
|
GetSystemDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR));
|
|
|
|
ret = pSearchPathW(pathW, kernel32W, NULL, sizeof(path2W)/sizeof(WCHAR), path2W, NULL);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR));
|
|
|
|
|
2013-09-06 16:39:48 +02:00
|
|
|
ret = pActivateActCtx(handle, &cookie);
|
|
|
|
ok(ret, "failed to activate context, %u\n", GetLastError());
|
|
|
|
|
|
|
|
/* works when activated */
|
|
|
|
ret = pSearchPathW(NULL, testdepW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
|
|
|
|
|
2013-09-11 10:18:25 +02:00
|
|
|
ret = pSearchPathW(NULL, testdepW, extW, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pSearchPathW(NULL, testdep1W, dllW, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = pSearchPathW(NULL, testdep1W, extW, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* name contains path */
|
|
|
|
ret = pSearchPathW(NULL, testdeprelW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* fails with specified path that doesn't contain this file */
|
|
|
|
ret = pSearchPathW(pathW, testdepW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
2013-11-22 15:12:37 +01:00
|
|
|
/* path is redirected for wellknown names too, meaning it takes precedence over normal search order */
|
|
|
|
ret = pSearchPathW(NULL, kernel32dllW, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
2013-09-06 16:39:48 +02:00
|
|
|
ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
|
|
|
|
ok(lstrcmpW(buffW, path2W), "got wrong path %s, %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(path2W));
|
|
|
|
|
2013-11-22 15:12:37 +01:00
|
|
|
/* path is built using on manifest file name */
|
|
|
|
ret = pSearchPathW(NULL, ole32W, NULL, sizeof(buffW)/sizeof(WCHAR), buffW, NULL);
|
|
|
|
ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
|
|
|
|
|
2013-09-06 16:39:48 +02:00
|
|
|
ret = pDeactivateActCtx(0, cookie);
|
|
|
|
ok(ret, "failed to deactivate context, %u\n", GetLastError());
|
|
|
|
pReleaseActCtx(handle);
|
2009-12-21 21:00:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-17 06:40:17 +02:00
|
|
|
static void test_GetFullPathNameA(void)
|
|
|
|
{
|
|
|
|
char output[MAX_PATH], *filepart;
|
|
|
|
DWORD ret;
|
2011-02-23 10:38:49 +01:00
|
|
|
int i;
|
2014-10-13 17:24:58 +02:00
|
|
|
UINT acp;
|
2010-06-17 06:40:17 +02:00
|
|
|
|
|
|
|
const struct
|
|
|
|
{
|
|
|
|
LPCSTR name;
|
|
|
|
DWORD len;
|
|
|
|
LPSTR buffer;
|
|
|
|
LPSTR *lastpart;
|
|
|
|
} invalid_parameters[] =
|
|
|
|
{
|
2011-02-23 10:38:49 +01:00
|
|
|
{NULL, 0, NULL, NULL},
|
|
|
|
{NULL, MAX_PATH, NULL, NULL},
|
|
|
|
{NULL, MAX_PATH, output, NULL},
|
|
|
|
{NULL, MAX_PATH, output, &filepart},
|
2010-06-17 06:40:17 +02:00
|
|
|
{"", 0, NULL, NULL},
|
|
|
|
{"", MAX_PATH, NULL, NULL},
|
|
|
|
{"", MAX_PATH, output, NULL},
|
|
|
|
{"", MAX_PATH, output, &filepart},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
strcpy(output, "deadbeef");
|
|
|
|
filepart = (char *)0xdeadbeef;
|
|
|
|
ret = GetFullPathNameA(invalid_parameters[i].name,
|
|
|
|
invalid_parameters[i].len,
|
|
|
|
invalid_parameters[i].buffer,
|
|
|
|
invalid_parameters[i].lastpart);
|
|
|
|
ok(!ret, "[%d] Expected GetFullPathNameA to return 0, got %u\n", i, ret);
|
|
|
|
ok(!strcmp(output, "deadbeef"), "[%d] Expected the output buffer to be unchanged, got \"%s\"\n", i, output);
|
|
|
|
ok(filepart == (char *)0xdeadbeef, "[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
|
|
|
|
ok(GetLastError() == 0xdeadbeef ||
|
|
|
|
GetLastError() == ERROR_INVALID_NAME, /* Win7 */
|
|
|
|
"[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
|
|
|
i, GetLastError());
|
|
|
|
}
|
2014-10-13 17:24:58 +02:00
|
|
|
|
|
|
|
acp = GetACP();
|
|
|
|
if (acp != 932)
|
|
|
|
skip("Skipping DBCS(Japanese) GetFullPathNameA test in this codepage (%d)\n", acp);
|
|
|
|
else {
|
|
|
|
const struct dbcs_case {
|
|
|
|
const char *input;
|
|
|
|
const char *expected;
|
|
|
|
} testset[] = {
|
|
|
|
{ "c:\\a\\\x95\x5c\x97\xa0.txt", "\x95\x5c\x97\xa0.txt" },
|
|
|
|
{ "c:\\\x83\x8f\x83\x43\x83\x93\\wine.c", "wine.c" },
|
|
|
|
{ "c:\\demo\\\x97\xa0\x95\x5c", "\x97\xa0\x95\x5c" }
|
|
|
|
};
|
|
|
|
for (i = 0; i < sizeof(testset)/sizeof(testset[0]); i++) {
|
|
|
|
ret = GetFullPathNameA(testset[i].input, sizeof(output),
|
|
|
|
output, &filepart);
|
|
|
|
ok(ret, "[%d] GetFullPathName error %u\n", i, GetLastError());
|
|
|
|
ok(!lstrcmpA(filepart, testset[i].expected),
|
|
|
|
"[%d] expected %s got %s\n", i, testset[i].expected, filepart);
|
|
|
|
}
|
|
|
|
}
|
2010-06-17 06:40:17 +02:00
|
|
|
}
|
|
|
|
|
2010-06-17 06:40:26 +02:00
|
|
|
static void test_GetFullPathNameW(void)
|
|
|
|
{
|
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
static const WCHAR deadbeefW[] = {'d','e','a','d','b','e','e','f',0};
|
|
|
|
|
|
|
|
WCHAR output[MAX_PATH], *filepart;
|
|
|
|
DWORD ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
const struct
|
|
|
|
{
|
|
|
|
LPCWSTR name;
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR buffer;
|
|
|
|
LPWSTR *lastpart;
|
|
|
|
int win7_expect;
|
|
|
|
} invalid_parameters[] =
|
|
|
|
{
|
|
|
|
{NULL, 0, NULL, NULL},
|
|
|
|
{NULL, 0, NULL, &filepart, 1},
|
|
|
|
{NULL, MAX_PATH, NULL, NULL},
|
|
|
|
{NULL, MAX_PATH, output, NULL},
|
|
|
|
{NULL, MAX_PATH, output, &filepart, 1},
|
|
|
|
{emptyW, 0, NULL, NULL},
|
|
|
|
{emptyW, 0, NULL, &filepart, 1},
|
|
|
|
{emptyW, MAX_PATH, NULL, NULL},
|
|
|
|
{emptyW, MAX_PATH, output, NULL},
|
|
|
|
{emptyW, MAX_PATH, output, &filepart, 1},
|
|
|
|
};
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetFullPathNameW(NULL, 0, NULL, NULL);
|
|
|
|
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("GetFullPathNameW is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcpyW(output, deadbeefW);
|
|
|
|
filepart = (WCHAR *)0xdeadbeef;
|
|
|
|
ret = GetFullPathNameW(invalid_parameters[i].name,
|
|
|
|
invalid_parameters[i].len,
|
|
|
|
invalid_parameters[i].buffer,
|
|
|
|
invalid_parameters[i].lastpart);
|
|
|
|
ok(!ret, "[%d] Expected GetFullPathNameW to return 0, got %u\n", i, ret);
|
|
|
|
ok(!lstrcmpW(output, deadbeefW), "[%d] Expected the output buffer to be unchanged, got %s\n", i, wine_dbgstr_w(output));
|
|
|
|
ok(filepart == (WCHAR *)0xdeadbeef ||
|
|
|
|
(invalid_parameters[i].win7_expect && filepart == NULL),
|
|
|
|
"[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
|
|
|
|
ok(GetLastError() == 0xdeadbeef ||
|
|
|
|
GetLastError() == ERROR_INVALID_NAME, /* Win7 */
|
|
|
|
"[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
|
|
|
i, GetLastError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-21 18:21:16 +01:00
|
|
|
static void init_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
|
|
|
|
|
|
|
|
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
|
|
|
|
MAKEFUNC(GetLongPathNameA);
|
|
|
|
MAKEFUNC(GetLongPathNameW);
|
|
|
|
MAKEFUNC(NeedCurrentDirectoryForExePathA);
|
|
|
|
MAKEFUNC(NeedCurrentDirectoryForExePathW);
|
2009-12-21 21:00:38 +01:00
|
|
|
MAKEFUNC(SearchPathA);
|
|
|
|
MAKEFUNC(SearchPathW);
|
2013-09-06 16:39:48 +02:00
|
|
|
MAKEFUNC(ActivateActCtx);
|
|
|
|
MAKEFUNC(CreateActCtxW);
|
|
|
|
MAKEFUNC(DeactivateActCtx);
|
|
|
|
MAKEFUNC(GetCurrentActCtx);
|
|
|
|
MAKEFUNC(ReleaseActCtx);
|
2009-12-21 18:21:16 +01:00
|
|
|
#undef MAKEFUNC
|
|
|
|
}
|
|
|
|
|
2013-10-29 08:10:07 +01:00
|
|
|
static void test_relative_path(void)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH], buf[MAX_PATH];
|
|
|
|
HANDLE file;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!pGetLongPathNameA) return;
|
|
|
|
|
|
|
|
GetTempPathA(MAX_PATH, path);
|
|
|
|
ret = SetCurrentDirectoryA(path);
|
|
|
|
ok(ret, "SetCurrentDirectory error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = CreateDirectoryA("foo", NULL);
|
|
|
|
ok(ret, "CreateDirectory error %d\n", GetLastError());
|
|
|
|
file = CreateFileA("foo\\file", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "failed to create temp file\n");
|
|
|
|
CloseHandle(file);
|
|
|
|
ret = CreateDirectoryA("bar", NULL);
|
|
|
|
ok(ret, "CreateDirectory error %d\n", GetLastError());
|
|
|
|
ret = SetCurrentDirectoryA("bar");
|
|
|
|
ok(ret, "SetCurrentDirectory error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = GetFileAttributesA("..\\foo\\file");
|
|
|
|
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributes error %d\n", GetLastError());
|
|
|
|
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = pGetLongPathNameA(".", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetLongPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, "."), "expected ., got %s\n", buf);
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = GetShortPathNameA(".", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetShortPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, "."), "expected ., got %s\n", buf);
|
|
|
|
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = pGetLongPathNameA("..", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetLongPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, ".."), "expected .., got %s\n", buf);
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = GetShortPathNameA("..", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetShortPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, ".."), "expected .., got %s\n", buf);
|
|
|
|
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = pGetLongPathNameA("..\\foo\\file", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetLongPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, "..\\foo\\file"), "expected ..\\foo\\file, got %s\n", buf);
|
|
|
|
strcpy(buf, "deadbeef");
|
|
|
|
ret = GetShortPathNameA("..\\foo\\file", buf, MAX_PATH);
|
|
|
|
ok(ret, "GetShortPathName error %d\n", GetLastError());
|
|
|
|
ok(!strcmp(buf, "..\\foo\\file"), "expected ..\\foo\\file, got %s\n", buf);
|
|
|
|
|
|
|
|
SetCurrentDirectoryA("..");
|
|
|
|
DeleteFileA("foo\\file");
|
|
|
|
RemoveDirectoryA("foo");
|
|
|
|
RemoveDirectoryA("bar");
|
|
|
|
}
|
|
|
|
|
2002-04-11 23:49:23 +02:00
|
|
|
START_TEST(path)
|
|
|
|
{
|
2002-07-16 03:19:41 +02:00
|
|
|
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
|
2009-12-21 18:21:16 +01:00
|
|
|
|
|
|
|
init_pointers();
|
2007-04-25 09:41:11 +02:00
|
|
|
|
2009-12-02 15:18:16 +01:00
|
|
|
/* Report only once */
|
|
|
|
if (!pGetLongPathNameA)
|
|
|
|
win_skip("GetLongPathNameA is not available\n");
|
|
|
|
if (!pGetLongPathNameW)
|
|
|
|
win_skip("GetLongPathNameW is not available\n");
|
2013-09-06 16:39:48 +02:00
|
|
|
if (!pActivateActCtx)
|
|
|
|
win_skip("Activation contexts not supported, some tests will be skipped\n");
|
2009-12-02 15:18:16 +01:00
|
|
|
|
2013-10-29 08:10:07 +01:00
|
|
|
test_relative_path();
|
2002-07-16 03:19:41 +02:00
|
|
|
test_InitPathA(curdir, &curDrive, &otherDrive);
|
2002-04-11 23:49:23 +02:00
|
|
|
test_CurrentDirectoryA(origdir,curdir);
|
2002-07-16 03:19:41 +02:00
|
|
|
test_PathNameA(curdir, curDrive, otherDrive);
|
2002-04-11 23:49:23 +02:00
|
|
|
test_CleanupPathA(origdir,curdir);
|
2002-08-27 03:56:08 +02:00
|
|
|
test_GetTempPath();
|
2009-12-02 15:18:16 +01:00
|
|
|
test_GetLongPathNameA();
|
2006-09-29 09:21:31 +02:00
|
|
|
test_GetLongPathNameW();
|
2007-07-19 11:15:09 +02:00
|
|
|
test_GetShortPathNameW();
|
2006-12-03 22:38:21 +01:00
|
|
|
test_GetSystemDirectory();
|
2006-12-03 22:38:50 +01:00
|
|
|
test_GetWindowsDirectory();
|
2009-12-21 18:21:16 +01:00
|
|
|
test_NeedCurrentDirectoryForExePathA();
|
|
|
|
test_NeedCurrentDirectoryForExePathW();
|
2008-02-27 12:58:40 +01:00
|
|
|
test_drive_letter_case();
|
2009-12-21 21:00:38 +01:00
|
|
|
test_SearchPathA();
|
|
|
|
test_SearchPathW();
|
2010-06-17 06:40:17 +02:00
|
|
|
test_GetFullPathNameA();
|
2010-06-17 06:40:26 +02:00
|
|
|
test_GetFullPathNameW();
|
2002-04-11 23:49:23 +02:00
|
|
|
}
|