Commit 76f13deb authored by Rolf Kalbermatter's avatar Rolf Kalbermatter Committed by Alexandre Julliard

Use INVALID_FILE_ATTRIBUTES to test for failure of

GetFileAttributesA/W and not -1 or 0xFFFFFFFF.
parent c66b7b00
......@@ -900,7 +900,7 @@ void _searchenv(const char* file, const char* env, char *buf)
*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 @@ void _searchenv(const char* file, const char* env, char *buf)
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);
......
......@@ -279,7 +279,7 @@ int _access(const char *filename, int mode)
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 @@ int _waccess(const MSVCRT_wchar_t *filename, int mode)
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 @@ int _chmod(const char *path, int flags)
{
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 @@ int _wchmod(const MSVCRT_wchar_t *path, int flags)
{
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 @@ char *_mktemp(char *pattern)
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 @@ MSVCRT_wchar_t *_wmktemp(MSVCRT_wchar_t *pattern)
pattern++;
do
{
if (GetFileAttributesW(retVal) == 0xFFFFFFFF &&
if (GetFileAttributesW(retVal) == INVALID_FILE_ATTRIBUTES &&
GetLastError() == ERROR_FILE_NOT_FOUND)
return retVal;
*pattern = letter++;
......
......@@ -806,7 +806,7 @@ DWORD WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
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 @@ DWORD WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
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);
......
......@@ -446,7 +446,7 @@ BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
return FALSE;
return fnlen>12;
return fnlen > 12;
}
/*************************************************************************
......
......@@ -48,7 +48,7 @@ void createTestFile(CHAR *name)
BOOL file_exists(CHAR *name)
{
return GetFileAttributesA(name) != 0xFFFFFFFF;
return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
}
/* initializes the tests */
......
......@@ -382,14 +382,14 @@ DWORD WINAPI VerInstallFileA(
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 @@ DWORD WINAPI VerInstallFileA(
*/
}
}
if (attr == -1) {
if (attr == INVALID_FILE_ATTRIBUTES) {
char *s;
GetTempFileNameA(pdest,"ver",0,tmpfn); /* should not fail ... */
......@@ -505,7 +505,7 @@ DWORD WINAPI VerInstallFileA(
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;
......
......@@ -1606,7 +1606,7 @@ static BOOL INT21_FileAttributes( CONTEXT86 *context,
MultiByteToWideChar(CP_OEMCP, 0, fileA, -1, fileW, MAX_PATH);
result = GetFileAttributesW( fileW );
if (result == -1)
if (result == INVALID_FILE_ATTRIBUTES)
return FALSE;
else
{
......
......@@ -612,7 +612,7 @@ HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
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;
......
......@@ -855,11 +855,12 @@ DWORD WINAPI GetFileAttributesW( LPCWSTR name )
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 GetFileAttributesW( LPCWSTR name )
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))
......
......@@ -1182,14 +1182,14 @@ static int _get_reg_type(const WCHAR* windir)
/* 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;
}
......
......@@ -64,7 +64,7 @@ HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size)
#undef XXT
fnAVIFileInit();
if (-1==GetFileAttributes(cmdline)) {
if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
fprintf(stderr,"Usage: aviinfo <avifilename>\n");
exit(1);
}
......
......@@ -103,7 +103,7 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg);
fnAVIFileInit();
if (-1==GetFileAttributes(cmdline)) {
if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
fprintf(stderr,"Usage: aviplay <avifilename>\n");
exit(1);
}
......
......@@ -156,7 +156,7 @@ ULARGE_INTEGER byte_count, file_size;
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, "*");
}
......
......@@ -183,11 +183,11 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
* 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 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
strcat(tmppath, basename);
status = GetFileAttributes(tmppath);
if ( status != -1 ) break;
if ( status != INVALID_FILE_ATTRIBUTES ) break;
}
if ( sl == NULL )
......@@ -233,11 +233,11 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
}
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
......
......@@ -506,7 +506,7 @@ void MACRO_ExtInsertMenu(LPCSTR str1, LPCSTR str2, LPCSTR str3, LONG u1, LONG u2
BOOL MACRO_FileExist(LPCSTR str)
{
WINE_TRACE("(\"%s\")\n", str);
return GetFileAttributes(str) != 0xFFFFFFFF;
return GetFileAttributes(str) != INVALID_FILE_ATTRIBUTES;
}
void MACRO_FileOpen(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment