From: Jan N. <jan...@us...> - 2012-08-01 21:43:54
|
TIP #402: GENERAL PLATFORM UNC SUPPORT ======================================== Version: $Revision: 1.1 $ Author: Jan Nijtmans <jan.nijtmans_at_users.sf.net> State: Draft Type: Project Tcl-Version: 8.6 Vote: Pending Created: Saturday, 16 July 2011 URL: http://purl.org/tcl/tip/402.html WebEdit: http://purl.org/tcl/tip/edit/402 Discussions-To: Tcl Core list Post-History: ------------------------------------------------------------------------- ABSTRACT ========== Both Windows and Cygwin interpret paths starting with *//* as a special prefix, indicating that the path has the form: *//server/share/file_path*. Windows has built-in handling of such paths built-in. UNIX doesn't have this. It could be implemented through a VFS extension, but there is one problem: File normalization on UNIX collapes multiple slashes into a single slash, so this would convert the UNC path into a normal path. This makes it impossible to implement a VFS extension which uses *//* as prefix, implementing connection to a Samba server using the UNC path format. RATIONALE =========== At the moment, Cygwin and Windows have built-in a special case that paths starting with double-slash will not be collapsed into a single slash. UNIX does not do that. This change will allow a single uniform format for accessing (Samba) shares on external machines using the path format *//server/share/file_path*. On Windows and Cygwin this already works, because it is built-in Windows functionality. On UNIX a VFS extension could be developed which does the same. SPECIFICATION =============== This document proposes: * Extend the special case built-in for Windows and Cygwin to UNIX, so paths starting with double-slash will no longer normalize to paths starting with a single slash. *POTENTIAL INCOMPATIBILITY* * As *//* becomes a special prefix, the *file split* will return *//* as its first list element when the original path starts with a double slash. COMPATIBILITY =============== On UNIX, this means that paths like *//usr/bin/tclsh* might no longer do what it did earlier, if a VFS exists which uses *//* as path prefix. If no such VFS exists, it will probably still work, only comparing normalized paths will no longer regard *//<foo>* as equal to */<foo>*. Handling of multiple slashes in other locations of the string will not change. So normalizing */foo//bar* will still give */foo/bar*. The most likely cause of multiple slashes appearing in a path is because of appending a file name to a path which already ends with a slash, e.g. set dir "somedir/" set path $dir/filename Of course, the *file join* command does not have this danger: set dir "somedir/" set path [file join $dir filename] On Windows and Cygwin, there is no change in behavior at all. ALTERNATIVES ============== Variations are possible in the handling of paths starting with 3 or more slashes. The current TIP implementation collapes more than 2 slashes to exactly 2 slashes, as the current Windows and Cygwin implementations do. REFERENCE IMPLEMENTATION ========================== A reference implementation is available at <URL:http://core.tcl.tk/tcl> in branch /jn-unc-vfs/. COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows |