TIP 402: General Platform UNC Support

Login
Author:         Jan Nijtmans <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        16-Jul-2011
Post-History:   
Discussions-To: Tcl Core list
Keywords:       Tcl
Tcl-Version:    8.7
Tcl-Branch:     tip-402
Vote-Results:   3/0/2 accepted
Votes-For:      FV, KW, JN
Votes-Against:  none
Votes-Present:  DGP, SL

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:

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 collapses more than 2 slashes to exactly 2 slashes, as the current Windows and Cygwin implementations do.

Reference Implementation

A reference implementation is available at https://core.tcl-lang.org/tcl in branch tip-402.

Copyright

This document has been placed in the public domain.