TIP #402: General Platform UNC Support


TIP:402
Title:General Platform UNC Support
Version:$Revision: 1.2 $
Author:Jan Nijtmans <jan dot nijtmans at users dot sf dot net>
State:Draft
Type:Project
Tcl-Version:8.7
Vote:Pending
Created:Saturday, 16 July 2011
Discussions To:Tcl Core list
Keywords:Tcl

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 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.


Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows