GetFileAttributesA/W returns INVALID_FILE_ATTRIBUTES on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cahngelog
  - dlls/msvcrt/dir.c
  - dlls/msvcrt/file.c
  - dlls/shell32/shellpath.c
  - dlls/shell32/shellord.c
  - dlls/shell32/tests/shlfileop.c
  - dlls/winmm/mmio.c
  - dlls/version/install.c
  - files/file.c
  - misc/registry.c
  - programs/avitools/aviinfo.c
  - programs/avitools/aviplay.c
  - programs/wcmd/directory.c
  - programs/winedbg/source.c
  - programs/winhelp/macro.c
    Use INVALID_FILE_ATTRIBUTES to test for failure of GetFileAttributesA/W and not -1 or 0xFFFFFFFF

Rolf Kalbermatter

Index: dlls/msvcrt/dir.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/dir.c,v
retrieving revision 1.20
diff -u -r1.20 dir.c
--- dlls/msvcrt/dir.c	5 Sep 2003 23:08:35 -0000	1.20
+++ dlls/msvcrt/dir.c	15 Oct 2003 21:40:02 -0000
@@ -942,7 +942,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 */
@@ -982,7 +982,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);
Index: dlls/msvcrt/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/file.c,v
retrieving revision 1.55
diff -u -r1.55 file.c
--- dlls/msvcrt/file.c	7 Oct 2003 05:22:04 -0000	1.55
+++ dlls/msvcrt/file.c	15 Oct 2003 21:40:03 -0000
@@ -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++;
Index: dlls/shell32/shellord.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellord.c,v
retrieving revision 1.117
diff -u -r1.117 shellord.c
--- dlls/shell32/shellord.c	15 Sep 2003 22:13:40 -0000	1.117
+++ dlls/shell32/shellord.c	15 Oct 2003 21:40:05 -0000
@@ -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);
Index: dlls/shell32/shellpath.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellpath.c,v
retrieving revision 1.73
diff -u -r1.73 shellpath.c
--- dlls/shell32/shellpath.c	2 Oct 2003 04:27:21 -0000	1.73
+++ dlls/shell32/shellpath.c	15 Oct 2003 21:40:05 -0000
@@ -446,7 +446,7 @@
 
     if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
 	return FALSE;
-    return fnlen>12;
+    return fnlen > 12;
 }
 
 /*************************************************************************
Index: dlls/shell32/tests/shlfileop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/tests/shlfileop.c,v
retrieving revision 1.10
diff -u -r1.10 shlfileop.c
--- dlls/shell32/tests/shlfileop.c	27 Sep 2003 03:47:35 -0000	1.10
+++ dlls/shell32/tests/shlfileop.c	15 Oct 2003 21:40:06 -0000
@@ -48,7 +48,7 @@
 
 BOOL file_exists(CHAR *name)
 {
-    return GetFileAttributesA(name) != 0xFFFFFFFF;
+    return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
 }
 
 /* initializes the tests */
Index: dlls/version/install.c
===================================================================
RCS file: /home/wine/wine/dlls/version/install.c,v
retrieving revision 1.22
diff -u -r1.22 install.c
--- dlls/version/install.c	27 Sep 2003 02:22:21 -0000	1.22
+++ dlls/version/install.c	15 Oct 2003 21:40:07 -0000
@@ -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;
Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.42
diff -u -r1.42 int21.c
--- dlls/winedos/int21.c	22 Sep 2003 19:32:51 -0000	1.42
+++ dlls/winedos/int21.c	15 Oct 2003 21:40:08 -0000
@@ -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
         {
Index: dlls/winmm/mmio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/mmio.c,v
retrieving revision 1.41
diff -u -r1.41 mmio.c
--- dlls/winmm/mmio.c	15 Sep 2003 20:13:30 -0000	1.41
+++ dlls/winmm/mmio.c	15 Oct 2003 21:40:09 -0000
@@ -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;
Index: files/file.c
===================================================================
RCS file: /home/wine/wine/files/file.c,v
retrieving revision 1.190
diff -u -r1.190 file.c
--- files/file.c	8 Oct 2003 00:25:33 -0000	1.190
+++ files/file.c	15 Oct 2003 21:40:11 -0000
@@ -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 = (DWORD)INVALID_FILE_ATTRIBUTES;
 
     if (!name)
     {
         SetLastError( ERROR_INVALID_PARAMETER );
-        return (DWORD)-1;
+        return (DWORD)INVALID_FILE_ATTRIBUTES;
     }
 
     if (RtlCreateUnicodeStringFromAsciiz(&nameW, name))
Index: misc/registry.c
===================================================================
RCS file: /home/wine/wine/misc/registry.c,v
retrieving revision 1.132
diff -u -r1.132 registry.c
--- misc/registry.c	18 Sep 2003 23:27:20 -0000	1.132
+++ misc/registry.c	15 Oct 2003 21:40:13 -0000
@@ -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;
     }
 
Index: programs/avitools/aviinfo.c
===================================================================
RCS file: /home/wine/wine/programs/avitools/aviinfo.c,v
retrieving revision 1.11
diff -u -r1.11 aviinfo.c
--- programs/avitools/aviinfo.c	18 Oct 2002 00:22:24 -0000	1.11
+++ programs/avitools/aviinfo.c	15 Oct 2003 21:40:13 -0000
@@ -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);
     }
Index: programs/avitools/aviplay.c
===================================================================
RCS file: /home/wine/wine/programs/avitools/aviplay.c,v
retrieving revision 1.16
diff -u -r1.16 aviplay.c
--- programs/avitools/aviplay.c	18 Aug 2003 20:11:29 -0000	1.16
+++ programs/avitools/aviplay.c	15 Oct 2003 21:40:13 -0000
@@ -103,7 +103,7 @@
 
 
     fnAVIFileInit();
-    if (-1==GetFileAttributes(cmdline)) {
+    if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
     	fprintf(stderr,"Usage: aviplay <avifilename>\n");
 	exit(1);
     }
Index: programs/wcmd/directory.c
===================================================================
RCS file: /home/wine/wine/programs/wcmd/directory.c,v
retrieving revision 1.17
diff -u -r1.17 directory.c
--- programs/wcmd/directory.c	27 Feb 2003 01:41:21 -0000	1.17
+++ programs/wcmd/directory.c	15 Oct 2003 21:40:14 -0000
@@ -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, "*");
       }
Index: programs/winedbg/source.c
===================================================================
RCS file: /home/wine/wine/programs/winedbg/source.c,v
retrieving revision 1.3
diff -u -r1.3 source.c
--- programs/winedbg/source.c	23 Sep 2003 22:54:57 -0000	1.3
+++ programs/winedbg/source.c	15 Oct 2003 21:40:14 -0000
@@ -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
Index: programs/winhelp/macro.c
===================================================================
RCS file: /home/wine/wine/programs/winhelp/macro.c,v
retrieving revision 1.18
diff -u -r1.18 macro.c
--- programs/winhelp/macro.c	11 Oct 2003 05:25:31 -0000	1.18
+++ programs/winhelp/macro.c	15 Oct 2003 21:40:14 -0000
@@ -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)




[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux