Mercurial > hg > xemacs-beta
diff src/sysfile.h @ 2526:902d5bd9b75c
[xemacs-hg @ 2005-01-28 02:36:11 by ben]
Support symlinks under Windows
nt.c, fileio.c: Fix sync comments.
config.h.in, dired-msw.c, emacs.c, event-msw.c, fileio.c, glyphs.c, lisp.h, nt.c, process-nt.c, realpath.c, sound.c, symsinit.h, sysdep.c, sysfile.h, syswindows.h, win32.c: Add support for treating shortcuts under Windows as symbolic links.
Enabled with mswindows-shortcuts-are-links (t by default). Rewrite
lots of places to use PATHNAME_CONVERT_OUT, which is moved to
sysfile.h. Add PATHNAME_RESOLVE_LINKS, which only does things
under Windows.
Add profiling section for expand_file_name calls.
nt.c, sysdep.c: Unicode-ize.
realpath.c: Renamed from readlink_and_correct_case. Fix some problems with
Windows implementation due to incorrect understanding of workings
of the function.
sound.c, ntplay.c, sound.h: Rename play_sound_file to nt_play_sound_file and pass
internally-formatted data to it to avoid converting out and back
again.
text.h: is_c -> is_ascii.
author | ben |
---|---|
date | Fri, 28 Jan 2005 02:36:28 +0000 |
parents | ab71ad6ff3dd |
children | facf3239ba30 |
line wrap: on
line diff
--- a/src/sysfile.h Fri Jan 28 02:05:05 2005 +0000 +++ b/src/sysfile.h Fri Jan 28 02:36:28 2005 +0000 @@ -238,6 +238,13 @@ #undef S_ISSOCK #endif /* STAT_MACROS_BROKEN. */ +#ifdef WIN32_NATIVE +/* This is the standard value for S_IFLNK. All of the S_... flags that + exist in the MSVCRT have standard values, so their bit tests will + magically work. */ +#define S_IFLNK 0120000 +#endif + #if !defined(S_ISBLK) && defined(S_IFBLK) #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) #endif @@ -376,7 +383,8 @@ int qxe_readlink (const Ibyte *path, Ibyte *buf, size_t bufsiz); int qxe_fstat (int fd, struct stat *buf); int qxe_stat (const Ibyte *path, struct stat *buf); -Ibyte *qxe_realpath (const Ibyte *path, Ibyte resolved_path []); +Ibyte *qxe_realpath (const Ibyte *path, Ibyte resolved_path [], + Boolint links_only); /* encapsulations: file-manipulation calls */ @@ -399,6 +407,10 @@ on systems like SCO 3.2v5 */ void filemodestring (struct stat *, char *); +#ifdef WIN32_ANY +extern int mswindows_shortcuts_are_symlinks; +#endif + #endif /* emacs */ @@ -507,6 +519,50 @@ #endif /* WIN32_ANY */ +#if defined (WIN32_NATIVE) +#define PATHNAME_RESOLVE_LINKS(path, pathout) \ +do \ +{ \ + if (mswindows_shortcuts_are_symlinks) \ + { \ + Ibyte *_prl_path_ = (Ibyte *) (path); \ + Ibyte _prl_path2_[PATH_MAX_INTERNAL]; \ + \ + if (!qxe_realpath (_prl_path_, _prl_path2_, 1)) \ + (pathout) = _prl_path_; \ + else \ + IBYTE_STRING_TO_ALLOCA (_prl_path2_, pathout); \ + } \ + else (pathout) = (Ibyte *) (path); \ +} while (0) +#else +#define PATHNAME_RESOLVE_LINKS(path, pathout) ((pathout) = (Ibyte *) (path)) +#endif + +#define LISP_PATHNAME_RESOLVE_LINKS(path, pathout) \ + PATHNAME_RESOLVE_LINKS (XSTRING_DATA (path), pathout) + +/* The documentation in VC++ claims that the pathname library functions + accept strings in the current locale-specific encoding, but that's + false, because they just call the native Win32 routines directly, which + always use the system-default encoding (which is what Qmswindows_tstr + will give us when not XEUNICODE_P). */ +#ifdef WIN32_NATIVE +# define PATHNAME_CONVERT_OUT(path, pathout) \ +do \ +{ \ + const Ibyte *_pco_path_; \ + PATHNAME_RESOLVE_LINKS (path, _pco_path_); \ + C_STRING_TO_TSTR (_pco_path_, pathout); \ +} while (0) +#else +# define PATHNAME_CONVERT_OUT(path, pathout) \ + C_STRING_TO_EXTERNAL (path, pathout, Qfile_name) +#endif + +#define LISP_PATHNAME_CONVERT_OUT(path, pathout) \ + PATHNAME_CONVERT_OUT (XSTRING_DATA (path), pathout) + #endif /* emacs */ #endif /* INCLUDED_sysfile_h_ */