Use INVALID_FILE_ATTRIBUTES to test for failure of
GetFileAttributesA/W and not -1 or 0xFFFFFFFF.
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index 4343461..a5ba3da 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -900,7 +900,7 @@
*buf = '\0';
/* Try CWD first */
- if (GetFileAttributesA( file ) != 0xFFFFFFFF)
+ if (GetFileAttributesA( file ) != INVALID_FILE_ATTRIBUTES)
{
GetFullPathNameA( file, MAX_PATH, buf, NULL );
/* Sigh. This error is *always* set, regardless of success */
@@ -940,7 +940,7 @@
strcat(curPath, file);
TRACE("Checking for file %s\n", curPath);
- if (GetFileAttributesA( curPath ) != 0xFFFFFFFF)
+ if (GetFileAttributesA( curPath ) != INVALID_FILE_ATTRIBUTES)
{
strcpy(buf, curPath);
MSVCRT__set_errno(ERROR_FILE_NOT_FOUND);
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 8ccc0ca..f5484e7 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -279,7 +279,7 @@
TRACE("(%s,%d) %ld\n",filename,mode,attr);
- if (!filename || attr == 0xffffffff)
+ if (!filename || attr == INVALID_FILE_ATTRIBUTES)
{
MSVCRT__set_errno(GetLastError());
return -1;
@@ -301,7 +301,7 @@
TRACE("(%s,%d) %ld\n",debugstr_w(filename),mode,attr);
- if (!filename || attr == 0xffffffff)
+ if (!filename || attr == INVALID_FILE_ATTRIBUTES)
{
MSVCRT__set_errno(GetLastError());
return -1;
@@ -321,7 +321,7 @@
{
DWORD oldFlags = GetFileAttributesA(path);
- if (oldFlags != 0x0FFFFFFFF)
+ if (oldFlags != INVALID_FILE_ATTRIBUTES)
{
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
oldFlags | FILE_ATTRIBUTE_READONLY;
@@ -340,7 +340,7 @@
{
DWORD oldFlags = GetFileAttributesW(path);
- if (oldFlags != 0x0FFFFFFFF)
+ if (oldFlags != INVALID_FILE_ATTRIBUTES)
{
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
oldFlags | FILE_ATTRIBUTE_READONLY;
@@ -873,7 +873,7 @@
pattern++;
do
{
- if (GetFileAttributesA(retVal) == 0xFFFFFFFF &&
+ if (GetFileAttributesA(retVal) == INVALID_FILE_ATTRIBUTES &&
GetLastError() == ERROR_FILE_NOT_FOUND)
return retVal;
*pattern = letter++;
@@ -907,7 +907,7 @@
pattern++;
do
{
- if (GetFileAttributesW(retVal) == 0xFFFFFFFF &&
+ if (GetFileAttributesW(retVal) == INVALID_FILE_ATTRIBUTES &&
GetLastError() == ERROR_FILE_NOT_FOUND)
return retVal;
*pattern = letter++;
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 29810e1..2d00e17 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -806,7 +806,7 @@
lstrcpyA(old_lnk_name, link_dir);
PathAppendA(old_lnk_name, ptr);
if (!DeleteFileA(old_lnk_name)) {
- if ((attr = GetFileAttributesA(old_lnk_name)) == -1) {
+ if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
ERR("Delete for %s failed, err=%d, attr=%08lx\n",
old_lnk_name, err, attr);
@@ -835,7 +835,7 @@
PathAppendA(new_lnk_filepath, new_lnk_name);
i = 1;
olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
- while (GetFileAttributesA(new_lnk_filepath) != -1) {
+ while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
i++;
wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
lstrcpyA(new_lnk_filepath, link_dir);
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 22d9dfa..b1e726c 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -446,7 +446,7 @@
if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
return FALSE;
- return fnlen>12;
+ return fnlen > 12;
}
/*************************************************************************
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index 7d9061e..ecd46b4 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -48,7 +48,7 @@
BOOL file_exists(CHAR *name)
{
- return GetFileAttributesA(name) != 0xFFFFFFFF;
+ return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
}
/* initializes the tests */
diff --git a/dlls/version/install.c b/dlls/version/install.c
index 295481e..d9ae145 100644
--- a/dlls/version/install.c
+++ b/dlls/version/install.c
@@ -382,14 +382,14 @@
sprintf(tmpfn,"%s\\%s",pdest,destfilename);
tmplast=strlen(pdest)+1;
attr = GetFileAttributesA(tmpfn);
- if (attr!=-1) {
+ if (attr != INVALID_FILE_ATTRIBUTES) {
if (attr & FILE_ATTRIBUTE_READONLY) {
LZClose(hfsrc);
return VIF_WRITEPROT;
}
/* FIXME: check if file currently in use and return VIF_FILEINUSE */
}
- attr = -1;
+ attr = INVALID_FILE_ATTRIBUTES;
if (flags & VIFF_FORCEINSTALL) {
if (tmpfile[0]) {
sprintf(tmpfn,"%s\\%s",pdest,tmpfile);
@@ -400,7 +400,7 @@
*/
}
}
- if (attr == -1) {
+ if (attr == INVALID_FILE_ATTRIBUTES) {
char *s;
GetTempFileNameA(pdest,"ver",0,tmpfn); /* should not fail ... */
@@ -505,7 +505,7 @@
char curfn[260];
sprintf(curfn,"%s\\%s",curdir,destfilename);
- if (-1!=GetFileAttributesA(curfn)) {
+ if (INVALID_FILE_ATTRIBUTES != GetFileAttributesA(curfn)) {
/* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */
if (!DeleteFileA(curfn))
xret|=_error2vif(GetLastError())|VIF_CANNOTDELETECUR;
diff --git a/dlls/winedos/int21.c b/dlls/winedos/int21.c
index fee02e3..3c8beb5 100644
--- a/dlls/winedos/int21.c
+++ b/dlls/winedos/int21.c
@@ -1606,7 +1606,7 @@
MultiByteToWideChar(CP_OEMCP, 0, fileA, -1, fileW, MAX_PATH);
result = GetFileAttributesW( fileW );
- if (result == -1)
+ if (result == INVALID_FILE_ATTRIBUTES)
return FALSE;
else
{
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
index b02a174..9cbddd4 100644
--- a/dlls/winmm/mmio.c
+++ b/dlls/winmm/mmio.c
@@ -612,7 +612,7 @@
if (GetFullPathNameA(szFileName, sizeof(buffer), buffer, NULL) >= sizeof(buffer))
return (HMMIO16)FALSE;
- if ((dwOpenFlags & MMIO_EXIST) && (GetFileAttributesA(buffer) == -1))
+ if ((dwOpenFlags & MMIO_EXIST) && (GetFileAttributesA(buffer) == INVALID_FILE_ATTRIBUTES))
return (HMMIO)FALSE;
strcpy(szFileName, buffer);
return (HMMIO)TRUE;
diff --git a/files/file.c b/files/file.c
index 9b78e2f..c366b98 100644
--- a/files/file.c
+++ b/files/file.c
@@ -855,11 +855,12 @@
if (name == NULL)
{
SetLastError( ERROR_INVALID_PARAMETER );
- return -1;
+ return INVALID_FILE_ATTRIBUTES;
}
if (!DOSFS_GetFullName( name, TRUE, &full_name) )
- return -1;
- if (!FILE_Stat( full_name.long_name, &info, NULL )) return -1;
+ return INVALID_FILE_ATTRIBUTES;
+ if (!FILE_Stat( full_name.long_name, &info, NULL ))
+ return INVALID_FILE_ATTRIBUTES;
return info.dwFileAttributes;
}
@@ -870,12 +871,12 @@
DWORD WINAPI GetFileAttributesA( LPCSTR name )
{
UNICODE_STRING nameW;
- DWORD ret = (DWORD)-1;
+ DWORD ret = INVALID_FILE_ATTRIBUTES;
if (!name)
{
SetLastError( ERROR_INVALID_PARAMETER );
- return (DWORD)-1;
+ return INVALID_FILE_ATTRIBUTES;
}
if (RtlCreateUnicodeStringFromAsciiz(&nameW, name))
diff --git a/misc/registry.c b/misc/registry.c
index 9d2f077..eb50157 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -1182,14 +1182,14 @@
/* test %windir%/system32/config/system --> winnt */
strcpyW(tmp, windir);
strcatW(tmp, nt_reg_pathW);
- if(GetFileAttributesW(tmp) != (DWORD)-1)
+ if(GetFileAttributesW(tmp) != INVALID_FILE_ATTRIBUTES)
ret = REG_WINNT;
else
{
/* test %windir%/system.dat --> win95 */
strcpyW(tmp, windir);
strcatW(tmp, win9x_reg_pathW);
- if(GetFileAttributesW(tmp) != (DWORD)-1)
+ if(GetFileAttributesW(tmp) != INVALID_FILE_ATTRIBUTES)
ret = REG_WIN95;
}
diff --git a/programs/avitools/aviinfo.c b/programs/avitools/aviinfo.c
index 2208bef..86c22e4 100644
--- a/programs/avitools/aviinfo.c
+++ b/programs/avitools/aviinfo.c
@@ -64,7 +64,7 @@
#undef XXT
fnAVIFileInit();
- if (-1==GetFileAttributes(cmdline)) {
+ if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
fprintf(stderr,"Usage: aviinfo <avifilename>\n");
exit(1);
}
diff --git a/programs/avitools/aviplay.c b/programs/avitools/aviplay.c
index 1ef1a49..dd6abd3 100644
--- a/programs/avitools/aviplay.c
+++ b/programs/avitools/aviplay.c
@@ -103,7 +103,7 @@
fnAVIFileInit();
- if (-1==GetFileAttributes(cmdline)) {
+ if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
fprintf(stderr,"Usage: aviplay <avifilename>\n");
exit(1);
}
diff --git a/programs/wcmd/directory.c b/programs/wcmd/directory.c
index f1e51f1..6d1cf92 100644
--- a/programs/wcmd/directory.c
+++ b/programs/wcmd/directory.c
@@ -156,7 +156,7 @@
if ((strchr(search_path, '*') == NULL) && (strchr(search_path, '%') == NULL)) {
status = GetFileAttributes (search_path);
- if ((status != -1) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
+ if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
if (search_path[strlen(search_path)-1] == '\\') {
strcat (search_path, "*");
}
diff --git a/programs/winedbg/source.c b/programs/winedbg/source.c
index 559bc5f..db3f00f 100644
--- a/programs/winedbg/source.c
+++ b/programs/winedbg/source.c
@@ -183,11 +183,11 @@
* Crapola. We need to try and open the file.
*/
status = GetFileAttributes(sourcefile);
- if ( status != -1 )
+ if ( status != INVALID_FILE_ATTRIBUTES )
{
strcpy(tmppath, sourcefile);
}
- else if ( (status = GetFileAttributes(basename)) != -1 )
+ else if ( (status = GetFileAttributes(basename)) != INVALID_FILE_ATTRIBUTES )
{
strcpy(tmppath, basename);
}
@@ -206,7 +206,7 @@
strcat(tmppath, basename);
status = GetFileAttributes(tmppath);
- if ( status != -1 ) break;
+ if ( status != INVALID_FILE_ATTRIBUTES ) break;
}
if ( sl == NULL )
@@ -233,11 +233,11 @@
}
else
{
- status = -1;
+ status = INVALID_FILE_ATTRIBUTES;
strcpy(tmppath, sourcefile);
}
- if ( status == -1 )
+ if ( status == INVALID_FILE_ATTRIBUTES )
{
/*
* OK, I guess the user doesn't really want to see it
diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c
index 8b39fb2..c25d209 100644
--- a/programs/winhelp/macro.c
+++ b/programs/winhelp/macro.c
@@ -506,7 +506,7 @@
BOOL MACRO_FileExist(LPCSTR str)
{
WINE_TRACE("(\"%s\")\n", str);
- return GetFileAttributes(str) != 0xFFFFFFFF;
+ return GetFileAttributes(str) != INVALID_FILE_ATTRIBUTES;
}
void MACRO_FileOpen(void)