From d52e1c4be9b141dd60d09f34a6214f2430acb1b5 Mon Sep 17 00:00:00 2001 From: Gerard Patel Date: Fri, 16 Feb 2001 19:05:42 +0000 Subject: [PATCH] Gives back the ERROR_FILE_NOT_FOUND to GetFileAttributes. --- files/directory.c | 13 +++++++------ files/dos_fs.c | 6 ++++++ files/file.c | 5 +---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/files/directory.c b/files/directory.c index 10cc888eada..ed4aa6a1ae0 100644 --- a/files/directory.c +++ b/files/directory.c @@ -44,7 +44,7 @@ static DOS_FULL_NAME DIR_System; * Get a path name from the wine.ini file and make sure it is valid. */ static int DIR_GetPath( const char *keyname, const char *defval, - DOS_FULL_NAME *full_name ) + DOS_FULL_NAME *full_name, BOOL warn ) { char path[MAX_PATHNAME_LEN]; BY_HANDLE_FILE_INFORMATION info; @@ -55,7 +55,8 @@ static int DIR_GetPath( const char *keyname, const char *defval, (!FILE_Stat( full_name->long_name, &info ) && (mess=strerror(errno)))|| (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (mess="not a directory"))) { - MESSAGE("Invalid path '%s' for %s directory: %s\n", path, keyname, mess); + if (warn) + MESSAGE("Invalid path '%s' for %s directory: %s\n", path, keyname, mess); return 0; } return 1; @@ -90,9 +91,9 @@ int DIR_Init(void) DRIVE_Chdir( drive, cwd ); } - if (!(DIR_GetPath( "windows", "c:\\windows", &DIR_Windows )) || - !(DIR_GetPath( "system", "c:\\windows\\system", &DIR_System )) || - !(DIR_GetPath( "temp", "c:\\windows", &tmp_dir ))) + if (!(DIR_GetPath( "windows", "c:\\windows", &DIR_Windows, TRUE )) || + !(DIR_GetPath( "system", "c:\\windows\\system", &DIR_System, TRUE )) || + !(DIR_GetPath( "temp", "c:\\windows", &tmp_dir, TRUE ))) { PROFILE_UsageWineIni(); return 0; @@ -147,7 +148,7 @@ int DIR_Init(void) TRACE("Cwd = %c:\\%s\n", 'A' + drive, DRIVE_GetDosCwd( drive ) ); - if (DIR_GetPath( "profile", "", &profile_dir )) + if (DIR_GetPath( "profile", "", &profile_dir, FALSE )) { TRACE("USERPROFILE= %s\n", profile_dir.short_name ); SetEnvironmentVariableA( "USERPROFILE", profile_dir.short_name ); diff --git a/files/dos_fs.c b/files/dos_fs.c index 6860b57da9c..6dec7b0a2fd 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -843,6 +843,12 @@ BOOL DOSFS_GetFullName( LPCSTR name, BOOL check_last, DOS_FULL_NAME *full ) TRACE("%s (last=%d)\n", name, check_last ); + if ((!*name) || (*name=='\n')) + { /* error code for Win98 */ + SetLastError(ERROR_BAD_PATHNAME); + return FALSE; + } + if ((full->drive = DOSFS_GetPathDrive( &name )) == -1) return FALSE; flags = DRIVE_GetFlags( full->drive ); diff --git a/files/file.c b/files/file.c index 9d7c10c1190..0b66d8b285d 100644 --- a/files/file.c +++ b/files/file.c @@ -589,11 +589,8 @@ DWORD WINAPI GetFileAttributesA( LPCSTR name ) SetLastError( ERROR_INVALID_PARAMETER ); return -1; } - if (!*name || !DOSFS_GetFullName( name, TRUE, &full_name )) - { - SetLastError( ERROR_BAD_PATHNAME ); + if (!DOSFS_GetFullName( name, TRUE, &full_name) ) return -1; - } if (!FILE_Stat( full_name.long_name, &info )) return -1; return info.dwFileAttributes; }