* 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.
This commit is contained in:
Corinna Vinschen 2001-11-13 21:49:06 +00:00
parent 7a43fd8be1
commit 03adcc0fda
5 changed files with 45 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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. */

View File

@ -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;

View File

@ -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