diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-11-13 21:49:06 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-11-13 21:49:06 +0000 |
commit | 03adcc0fda221ca636b5fe71547cde0a0737161b (patch) | |
tree | c850a2256759b6a1a2c38922c1f6e3871ac4176e | |
parent | 7a43fd8be112c2a94b3b7f06a28ce54ba931dbb2 (diff) | |
download | newlib-03adcc0fda221ca636b5fe71547cde0a0737161b.zip newlib-03adcc0fda221ca636b5fe71547cde0a0737161b.tar.gz newlib-03adcc0fda221ca636b5fe71547cde0a0737161b.tar.bz2 |
* dir.cc (mkdir): Add HIDDEN file attribute if file has leading dot
and HIDDEN_DOT_FILES is defined.
* fhandler.cc (fhandler_base::open): Ditto.
* path.cc (symlink): Ditto.
* syscalls.cc (_rename): Ditto and remove HIDDEN file attribute if
new filename does not begin with a dot.
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/dir.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 11 |
5 files changed, 45 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 94cde6c..ba6e5ea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2001-11-13 Corinna Vinschen <corinna@vinschen.de> + + * dir.cc (mkdir): Add HIDDEN file attribute if file has leading dot + and HIDDEN_DOT_FILES is defined. + * fhandler.cc (fhandler_base::open): Ditto. + * path.cc (symlink): Ditto. + * syscalls.cc (_rename): Ditto and remove HIDDEN file attribute if + new filename does not begin with a dot. + 2001-11-12 Christopher Faylor <cgf@redhat.com> * fhandler_console.cc (fhandler_console::read): Revert 2001-10-23 diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index b99bef3..9ccf832 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -340,6 +340,11 @@ mkdir (const char *dir, mode_t mode) if (!allow_ntsec && allow_ntea) set_file_attribute (real_dir.has_acls (), real_dir.get_win32 (), S_IFDIR | ((mode & 07777) & ~cygheap->umask)); +#ifdef HIDDEN_DOT_FILES + char *c = strrchr (real_dir.get_win32 (), '\\'); + if ((c && c[1] == '.') || *real_dir.get_win32 () == '.') + SetFileAttributes (real_dir.get_win32 (), FILE_ATTRIBUTE_HIDDEN); +#endif res = 0; } else diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 510c725..9a177bd 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -371,6 +371,15 @@ fhandler_base::open (path_conv *, int flags, mode_t mode) if (get_device () == FH_SERIAL) file_attributes |= FILE_FLAG_OVERLAPPED; +#ifdef HIDDEN_DOT_FILES + if (flags & O_CREAT && get_device () == FH_DISK) + { + char *c = strrchr (get_win32_name (), '\\'); + if ((c && c[1] == '.') || *get_win32_name () == '.') + file_attributes |= FILE_ATTRIBUTE_HIDDEN; + } +#endif + /* CreateFile() with dwDesiredAccess == 0 when called on remote share returns some handle, even if file doesn't exist. This code works around this bug. */ diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 130f45d..41ea4d4 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2605,9 +2605,9 @@ symlink (const char *topath, const char *frompath) &sa, alloca (4096), 4096); h = CreateFileA(win32_path, GENERIC_WRITE, 0, &sa, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if (h == INVALID_HANDLE_VALUE) - __seterrno (); + __seterrno (); else { BOOL success; @@ -2651,9 +2651,16 @@ symlink (const char *topath, const char *frompath) set_file_attribute (win32_path.has_acls (), win32_path.get_win32 (), S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO); - SetFileAttributesA (win32_path.get_win32 (), - allow_winsymlinks ? FILE_ATTRIBUTE_READONLY - : FILE_ATTRIBUTE_SYSTEM); + + DWORD attr = allow_winsymlinks ? FILE_ATTRIBUTE_READONLY + : FILE_ATTRIBUTE_SYSTEM; +#ifdef HIDDEN_DOT_FILES + cp = strrchr (win32_path, '\\'); + if ((cp && cp[1] == '.') || *win32_path == '.') + attr |= FILE_ATTRIBUTE_HIDDEN; +#endif + SetFileAttributesA (win32_path.get_win32 (), attr); + if (win32_path.fs_fast_ea ()) set_symlink_ea (win32_path, topath); res = 0; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 3b2104d..307d618 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1240,7 +1240,16 @@ done: else { /* make the new file have the permissions of the old one */ - SetFileAttributes (real_new, real_old); + DWORD attr = real_old; +#ifdef HIDDEN_DOT_FILES + char *c = strrchr (real_old.get_win32 (), '\\'); + if ((c && c[1] == '.') || *real_old.get_win32 () == '.') + attr &= ~FILE_ATTRIBUTE_HIDDEN; + c = strrchr (real_new.get_win32 (), '\\'); + if ((c && c[1] == '.') || *real_new.get_win32 () == '.') + attr |= FILE_ATTRIBUTE_HIDDEN; +#endif + SetFileAttributes (real_new, attr); /* Shortcut hack, No. 2, part 2 */ /* if the new filename was an existing shortcut, remove it now if the |