diff --git a/files/directory.c b/files/directory.c index 023d58fbb4c..6967fd505b3 100644 --- a/files/directory.c +++ b/files/directory.c @@ -80,7 +80,7 @@ static int DIR_GetPath( LPCWSTR keyname, LPCWSTR defval, DOS_FULL_NAME *full_nam PROFILE_GetWineIniString( wineW, keyname, defval, path, MAX_PATHNAME_LEN ); if (!DOSFS_GetFullName( path, TRUE, full_name ) || - (!FILE_Stat( full_name->long_name, &info ) && (mess=strerror(errno)))|| + (!FILE_Stat( full_name->long_name, &info, NULL ) && (mess=strerror(errno)))|| (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (mess="not a directory")) || (!(GetLongPathNameW(full_name->short_name, longname, longname_len))) ) { diff --git a/files/dos_fs.c b/files/dos_fs.c index d1c8b54bb31..3ec28bdc3a6 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -1696,7 +1696,7 @@ BOOL WINAPI wine_get_unix_file_name( LPCSTR dos, LPSTR buffer, DWORD len ) */ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry ) { - DWORD attr = info->attr | FA_UNUSED | FA_ARCHIVE | FA_RDONLY | FILE_ATTRIBUTE_SYMLINK; + DWORD attr = info->attr | FA_UNUSED | FA_ARCHIVE | FA_RDONLY; UINT flags = DRIVE_GetFlags( info->drive ); char *p, buffer[MAX_PATHNAME_LEN]; const char *drive_path; @@ -1704,6 +1704,7 @@ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry ) LPCWSTR long_name, short_name; BY_HANDLE_FILE_INFORMATION fileinfo; WCHAR dos_name[13]; + BOOL is_symlink; if ((info->attr & ~(FA_UNUSED | FA_ARCHIVE | FA_RDONLY)) == FA_LABEL) { @@ -1765,13 +1766,12 @@ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry ) /* Check the file attributes */ WideCharToMultiByte(DRIVE_GetCodepage(info->drive), 0, long_name, -1, p, sizeof(buffer) - (int)(p - buffer), NULL, NULL); - if (!FILE_Stat( buffer, &fileinfo )) + if (!FILE_Stat( buffer, &fileinfo, &is_symlink )) { WARN("can't stat %s\n", buffer); continue; } - if ((fileinfo.dwFileAttributes & FILE_ATTRIBUTE_SYMLINK) && - (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + if (is_symlink && (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { static const WCHAR wineW[] = {'w','i','n','e',0}; static const WCHAR ShowDirSymlinksW[] = {'S','h','o','w','D','i','r','S','y','m','l','i','n','k','s',0}; diff --git a/files/drive.c b/files/drive.c index 4590cab981a..f13bc53852f 100644 --- a/files/drive.c +++ b/files/drive.c @@ -1104,7 +1104,7 @@ int DRIVE_Chdir( int drive, LPCWSTR path ) buffer[MAX_PATHNAME_LEN - 1] = 0; /* ensure 0 termination */ if (!DOSFS_GetFullName( buffer, TRUE, &full_name )) return 0; - if (!FILE_Stat( full_name.long_name, &info )) return 0; + if (!FILE_Stat( full_name.long_name, &info, NULL )) return 0; if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { SetLastError( ERROR_FILE_NOT_FOUND ); diff --git a/files/file.c b/files/file.c index 7f875f126ac..c04b33de173 100644 --- a/files/file.c +++ b/files/file.c @@ -734,7 +734,7 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info ) * * Stat a Unix path name. Return TRUE if OK. */ -BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) +BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info, BOOL *is_symlink_ptr ) { struct stat st; int is_symlink; @@ -756,11 +756,10 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) return FALSE; } } - + /* fill in the information we gathered so far */ FILE_FillInfo( &st, info ); - if (is_symlink) info->dwFileAttributes |= FILE_ATTRIBUTE_SYMLINK; - + /* and now see if this is a hidden file, based on the name */ p = strrchr( unixName, '/'); p = p ? p + 1 : unixName; @@ -774,7 +773,7 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) if (!show_dot_files) info->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; } - + if (is_symlink_ptr) *is_symlink_ptr = is_symlink; return TRUE; } @@ -849,7 +848,7 @@ DWORD WINAPI GetFileAttributesW( LPCWSTR name ) } if (!DOSFS_GetFullName( name, TRUE, &full_name) ) return -1; - if (!FILE_Stat( full_name.long_name, &info )) return -1; + if (!FILE_Stat( full_name.long_name, &info, NULL )) return -1; return info.dwFileAttributes; } @@ -3361,7 +3360,7 @@ BOOL WINAPI GetFileAttributesExW( LPWIN32_FILE_ATTRIBUTE_DATA lpFad = (LPWIN32_FILE_ATTRIBUTE_DATA) lpFileInformation; if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name )) return FALSE; - if (!FILE_Stat( full_name.long_name, &info )) return FALSE; + if (!FILE_Stat( full_name.long_name, &info, NULL )) return FALSE; lpFad->dwFileAttributes = info.dwFileAttributes; lpFad->ftCreationTime = info.ftCreationTime; diff --git a/include/file.h b/include/file.h index c12ae75cc5c..60aed614eee 100644 --- a/include/file.h +++ b/include/file.h @@ -73,7 +73,7 @@ extern int FILE_strcasecmp( const char *str1, const char *str2 ); extern int FILE_strncasecmp( const char *str1, const char *str2, int len ); extern void FILE_SetDosError(void); extern int FILE_GetUnixHandle( HANDLE handle, DWORD access ); -extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ); +extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info, BOOL *is_symlink ); extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 ); extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, diff --git a/include/winnt.h b/include/winnt.h index b4cc51cd153..3b482a34178 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -3309,7 +3309,6 @@ typedef enum tagSID_NAME_USE { #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L #define FILE_ATTRIBUTE_OFFLINE 0x00001000L -#define FILE_ATTRIBUTE_SYMLINK 0x80000000L /* Not in Windows API */ /* File notification flags */ #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001