diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-02-05 18:18:02 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-02-05 18:18:02 +0000 |
commit | fbae2bf8641db16778ddd4348b6cb7a1115d5cca (patch) | |
tree | 0a084553b7593bacab3a50af33a1b073f83318aa /winsup/cygwin/fhandler_disk_file.cc | |
parent | 0913522dbd42e068bc737e7a32d1a8015a1e7c84 (diff) | |
download | cygnal-fbae2bf8641db16778ddd4348b6cb7a1115d5cca.tar.gz cygnal-fbae2bf8641db16778ddd4348b6cb7a1115d5cca.tar.bz2 cygnal-fbae2bf8641db16778ddd4348b6cb7a1115d5cca.zip |
* environ.cc (struct parse_thing): Add transparent_exe option.
* fhandler_disk_file.cc (fhandler_disk_file::link): Accomodate
transparent_exe option. Add .exe suffix for links to executable files,
if transparent_exe is set.
* fhandler_process.cc (fhandler_process::fill_filebuf): Remove .exe
suffix if transparent_exe option is set.
* path.cc (symlink_worker): Accomodate transparent_exe option.
(realpath): Don't tack on .exe suffix if transparent_exe is set.
* syscalls.cc (transparent_exe): New global variable.
(unlink): Accomodate transparent_exe option.
(open): Ditto.
(link): Ditto.
(rename): Ditto. Maybe add .exe suffix when renaming executable files.
(pathconf): Accomodate transparent_exe option.
* winsup.h: Declare transparent_exe.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 048574c1e..b187de58b 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -734,9 +734,11 @@ fhandler_disk_file::ftruncate (_off64_t length) int fhandler_disk_file::link (const char *newpath) { - path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX); extern bool allow_winsymlinks; + extern suffix_info stat_suffixes[]; + path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX, + transparent_exe ? stat_suffixes : NULL); if (newpc.error) { set_errno (newpc.case_clash ? ECASECLASH : newpc.error); @@ -757,14 +759,32 @@ fhandler_disk_file::link (const char *newpath) return -1; } - /* Shortcut hack. */ - char new_lnk_buf[CYG_MAX_PATH + 5]; - if (allow_winsymlinks && pc.is_lnk_special () && !newpc.case_clash) + char new_buf[CYG_MAX_PATH + 5]; + if (!newpc.error && !newpc.case_clash) { - strcpy (new_lnk_buf, newpath); - strcat (new_lnk_buf, ".lnk"); - newpath = new_lnk_buf; - newpc.check (newpath, PC_SYM_NOFOLLOW); + DWORD bintype; + int len; + + if (allow_winsymlinks && pc.is_lnk_special ()) + { + /* Shortcut hack. */ + strcpy (new_buf, newpath); + strcat (new_buf, ".lnk"); + newpath = new_buf; + newpc.check (newpath, PC_SYM_NOFOLLOW); + } + else if (transparent_exe + && !pc.isdir () + && GetBinaryType (pc, &bintype) + && (len = strlen (newpc)) > 4 + && !strcasematch ((const char *) newpc + len - 4, ".exe")) + { + /* Executable hack. */ + strcpy (new_buf, newpath); + strcat (new_buf, ".exe"); + newpath = new_buf; + newpc.check (newpath, PC_SYM_NOFOLLOW); + } } query_open (query_write_attributes); |