diff options
| author | Eli Zaretskii | 2019-06-26 19:23:34 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-06-26 19:23:34 +0300 |
| commit | e35708b454259425d1a3eda7b0e2f6cf559529ce (patch) | |
| tree | ab7070ae4ca485d2765c910bd460cca84c148cfa | |
| parent | d4a0e41829e59a0067461dc066dbfb945f2fe462 (diff) | |
| download | emacs-e35708b454259425d1a3eda7b0e2f6cf559529ce.tar.gz emacs-e35708b454259425d1a3eda7b0e2f6cf559529ce.zip | |
Support invoking Emacs via a symlink on MS-Windows
* src/w32.c (w32_my_exename): Resolve symlinks in the
executable name, to support searching for the pdumper file
when the executable is found via a symlink.
* src/emacs.c (load_pdump): Add a comment about symlink
resolution on Windows.
| -rw-r--r-- | src/emacs.c | 2 | ||||
| -rw-r--r-- | src/w32.c | 24 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/emacs.c b/src/emacs.c index 231acc0ef32..d5eccf78d80 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -868,6 +868,8 @@ load_pdump (int argc, char **argv) | |||
| 868 | if (exename) | 868 | if (exename) |
| 869 | { | 869 | { |
| 870 | #ifdef WINDOWSNT | 870 | #ifdef WINDOWSNT |
| 871 | /* w32_my_exename resolves symlinks internally, so no need to | ||
| 872 | call realpath. */ | ||
| 871 | real_exename = exename; | 873 | real_exename = exename; |
| 872 | exename = NULL; | 874 | exename = NULL; |
| 873 | #else | 875 | #else |
| @@ -9988,18 +9988,34 @@ w32_relocate (const char *epath_dir) | |||
| 9988 | return epath_dir; | 9988 | return epath_dir; |
| 9989 | } | 9989 | } |
| 9990 | 9990 | ||
| 9991 | /* Return the full absolute name of the running executable. | 9991 | /* Return the full absolute name of the running executable. If the |
| 9992 | executable is a symlink, resolve it. | ||
| 9992 | 9993 | ||
| 9993 | Note: this function is called early during startup, when Unicode | 9994 | Note: this function is called early during startup, when Unicode |
| 9994 | file name are not yet supported. */ | 9995 | file names are not yet supported. Thus the result must be an |
| 9996 | ANSI-encoded string. */ | ||
| 9995 | char * | 9997 | char * |
| 9996 | w32_my_exename (void) | 9998 | w32_my_exename (void) |
| 9997 | { | 9999 | { |
| 9998 | static char exename[MAX_PATH]; | 10000 | static char exename[MAX_PATH]; |
| 9999 | if (!GetModuleFileNameA (NULL, exename, MAX_PATH)) | 10001 | if (!GetModuleFileNameA (NULL, exename, MAX_PATH)) |
| 10000 | return NULL; | 10002 | return NULL; |
| 10001 | /* FIXME: Resolve possible symlinks in the last component of | 10003 | /* The caller expects us to resolve all possible symlinks in the |
| 10002 | exename, i.e. if the executable itself is a symlink. */ | 10004 | last component of exename, i.e. if the executable itself is a |
| 10005 | symlink to a file in another directory. */ | ||
| 10006 | if (get_volume_info (exename, NULL) | ||
| 10007 | && (volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0) | ||
| 10008 | { | ||
| 10009 | /* chase_symlinks wants its argument in UTF-8. */ | ||
| 10010 | char exename_utf8[MAX_UTF8_PATH]; | ||
| 10011 | filename_from_ansi (exename, exename_utf8); | ||
| 10012 | |||
| 10013 | /* If EXENAME is a symlink, replace it with its target. */ | ||
| 10014 | char *tgt = chase_symlinks (exename_utf8); | ||
| 10015 | if (tgt != exename_utf8) | ||
| 10016 | filename_to_ansi (tgt, exename); | ||
| 10017 | } | ||
| 10018 | |||
| 10003 | return exename; | 10019 | return exename; |
| 10004 | } | 10020 | } |
| 10005 | 10021 | ||