recognize Unix-style hidden files

Dimitrie O. Paun dpaun at rogers.com
Thu Sep 12 12:32:33 CDT 2002


I have hundreds of dot-files/directories in my home dir,
and they show up in the open dialog, etc. They get in the
way.

The semantics associated in Unix with files starting with
a . is that they are hidden, *exactly* like the hidden DOS
files. We should mark them as such.

We're lucky in that the DOS world does not use files that
only have extension, so we have no semantical conflict.

ChangeLog
  Mark files starting with a dot (.) as hidden.

Index: files/file.c
===================================================================
RCS file: /var/cvs/wine/files/file.c,v
retrieving revision 1.157
diff -u -r1.157 file.c
--- files/file.c	27 Aug 2002 01:29:07 -0000	1.157
+++ files/file.c	12 Sep 2002 17:08:11 -0000
@@ -736,14 +736,16 @@
 BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
 {
     struct stat st;
+    int is_symlink;
+    LPCSTR p;
 
     if (lstat( unixName, &st ) == -1)
     {
         FILE_SetDosError();
         return FALSE;
     }
-    if (!S_ISLNK(st.st_mode)) FILE_FillInfo( &st, info );
-    else
+    is_symlink = S_ISLNK(st.st_mode);
+    if (is_symlink)
     {
         /* do a "real" stat to find out
 	   about the type of the symlink destination */
@@ -752,9 +754,17 @@
             FILE_SetDosError();
             return FALSE;
         }
-        FILE_FillInfo( &st, info );
-        info->dwFileAttributes |= FILE_ATTRIBUTE_SYMLINK;
     }
+    
+    /* 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;
+    if (*p == '.') info->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
+    
     return TRUE;
 }
 




More information about the wine-patches mailing list