diff options
author | mdejong <mdejong> | 2001-07-17 19:40:37 (GMT) |
---|---|---|
committer | mdejong <mdejong> | 2001-07-17 19:40:37 (GMT) |
commit | 0b43f7ca80a834714b13d5566605c6060dd75eef (patch) | |
tree | e0b67be12f7aa0162b8baac11a7c886736f5f1d3 | |
parent | 07962f3025b017a67b95967a8c5313067d02f745 (diff) | |
download | tcl-0b43f7ca80a834714b13d5566605c6060dd75eef.zip tcl-0b43f7ca80a834714b13d5566605c6060dd75eef.tar.gz tcl-0b43f7ca80a834714b13d5566605c6060dd75eef.tar.bz2 |
* win/tclWinFile.c (TclpReadlink): Add Cygwin specific definition
for the TclpReadlink function. This method implements reading of
symbolic links when build with Cygwin.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | win/tclWinFile.c | 47 |
2 files changed, 52 insertions, 1 deletions
@@ -1,5 +1,11 @@ 2001-07-17 Mo DeJong <mdejong@redhat.com> + * win/tclWinFile.c (TclpReadlink): Add Cygwin specific definition + for the TclpReadlink function. This method implements reading of + symbolic links when build with Cygwin. + +2001-07-17 Mo DeJong <mdejong@redhat.com> + * win/tclWinPort.h: Add Cygwin specific defines for environ and timezone variables. diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 13a8906..1038758 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.9 2000/10/27 01:58:00 davidg Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.10 2001/07/17 19:40:37 mdejong Exp $ */ #include "tclWinInt.h" @@ -689,6 +689,51 @@ TclpChdir(path) return 0; } +#ifdef __CYGWIN__ +/* + *--------------------------------------------------------------------------- + * + * TclpReadlink -- + * + * This function replaces the library version of readlink(). + * + * Results: + * The result is a pointer to a string specifying the contents + * of the symbolic link given by 'path', or NULL if the symbolic + * link could not be read. Storage for the result string is + * allocated in bufferPtr; the caller must call Tcl_DStringFree() + * when the result is no longer needed. + * + * Side effects: + * See readlink() documentation. + * + *--------------------------------------------------------------------------- + */ + +char * +TclpReadlink(path, linkPtr) + CONST char *path; /* Path of file to readlink (UTF-8). */ + Tcl_DString *linkPtr; /* Uninitialized or free DString filled + * with contents of link (UTF-8). */ +{ + char link[MAXPATHLEN]; + int length; + char *native; + Tcl_DString ds; + + native = Tcl_UtfToExternalDString(NULL, path, -1, &ds); + length = readlink(native, link, sizeof(link)); /* INTL: Native. */ + Tcl_DStringFree(&ds); + + if (length < 0) { + return NULL; + } + + Tcl_ExternalToUtfDString(NULL, link, length, linkPtr); + return Tcl_DStringValue(linkPtr); +} +#endif /* __CYGWIN__ */ + /* *---------------------------------------------------------------------- * |