Author: Jan Nijtmans <jan.nijtmans@users.sf.net>
State: Draft
Type: Project
Vote: Pending
Created: 16-Jul-2011
Post-History:
Discussions-To: Tcl Core list
Keywords: Tcl
Tcl-Version: 8.7
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 //
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 http://core.tcl.tk/tcl in branch jn-unc-vfs.
Copyright
This document has been placed in the public domain.