summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--win/tclWinFile.c47
2 files changed, 52 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 415d99e..079bd62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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__ */
+
/*
*----------------------------------------------------------------------
*