summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/dir.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-02-21 21:49:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-02-21 21:49:37 +0000
commit10b06c5ee0712991bc7cec3688f8059069f9fcd2 (patch)
tree52156053d0ae8881b6c7e52fe3a0bc568f0eccb8 /winsup/cygwin/dir.cc
parent5b2ea3a43613c3d93ca9549880d3fd2dbb9ec0e1 (diff)
downloadcygnal-10b06c5ee0712991bc7cec3688f8059069f9fcd2.tar.gz
cygnal-10b06c5ee0712991bc7cec3688f8059069f9fcd2.tar.bz2
cygnal-10b06c5ee0712991bc7cec3688f8059069f9fcd2.zip
* Makefile.in: Add `-lshell32 -luuid' to link pass for new-cygwin1.dll.
* autoload.cc: Add LoadDLLinitfunc for ole32.dll. Add LoadDLLfuncEx statements for CoInitialize@4, CoUninitialize@0 and CoCreateInstance@20. * dir.cc (dir_suffixes): New datastructure. (readdir): Check for R/O *.lnk files to hide the suffix. (opendir): Use `dir_suffixes' in path conversion. (rmdir): Ditto. * fhandler.cc (fhandler_disk_file::fstat): Add S_IFLNK flag before calling `get_file_attribute'. Take FILE_ATTRIBUTE_READONLY into account only if the file is no symlink. * path.cc (inner_suffixes): New datastructure. (SYMLINKATTR): Eliminated. (path_conv::check): Use `inner_suffixes' on inner path components. (shortcut_header): New global static variable. (shortcut_initalized): Ditto. (create_shortcut_header): New function. (cmp_shortcut_header): Ditto. (symlink): Create symlinks by creating windows shortcuts. Preserve the old code. (symlink_info::check_shortcut): New method. (symlink_info::check_sysfile): Ditto. (symlink_info::check): Check for shortcuts. Move code reading old system attribute symlinks into symlink_info::check_sysfile(). (chdir): Use `dir_suffixes' in path conversion. * security.cc (get_file_attribute): Check for S_IFLNK flag. Force 0777 permissions then. * spawn.cc (std_suffixes): Add ".lnk" suffix. * syscalls.cc (_unlink): Use `inner_suffixes' in path conversion. Check for shortcut symlinks to eliminate R/O attribute before calling DeleteFile(). (stat_suffixes): Add ".lnk" suffix. (stat_worker): Force 0777 permissions if file is a symlink.
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r--winsup/cygwin/dir.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index a14b44f8f..b4b93da20 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -59,6 +59,13 @@ writable_directory (const char *file)
#endif
}
+suffix_info dir_suffixes[] =
+{
+ suffix_info ("", 1),
+ suffix_info (".lnk", 1),
+ suffix_info (NULL)
+};
+
/* opendir: POSIX 5.1.2.1 */
extern "C" DIR *
opendir (const char *dirname)
@@ -68,7 +75,7 @@ opendir (const char *dirname)
DIR *res = 0;
struct stat statbuf;
- path_conv real_dirname (dirname, PC_SYM_FOLLOW | PC_FULL);
+ path_conv real_dirname (dirname, PC_SYM_FOLLOW | PC_FULL, dir_suffixes);
if (real_dirname.error)
{
@@ -174,6 +181,14 @@ readdir (DIR * dir)
/* We get here if `buf' contains valid data. */
strcpy (dir->__d_dirent->d_name, buf.cFileName);
+ if (buf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ {
+ char *c = dir->__d_dirent->d_name;
+ int len = strlen (c);
+ if (!strcasecmp (c + len - 4, ".lnk"))
+ c[len - 4] = '\0';
+ }
+
/* Compute d_ino by combining filename hash with the directory hash
(which was stored in dir->__d_dirhash when opendir was called). */
if (buf.cFileName[0] == '.')
@@ -316,7 +331,7 @@ rmdir (const char *dir)
{
int res = -1;
- path_conv real_dir (dir, PC_SYM_NOFOLLOW);
+ path_conv real_dir (dir, PC_SYM_NOFOLLOW, dir_suffixes);
if (real_dir.error)
{