proc vfs::ftp::Mount {dirurl local} {
::vfs::log "ftp-vfs: attempt to mount $dirurl at $local"
- if {[string range $dirurl 0 5] == "ftp://"} {
- set dirurl [string range $dirurl 6 end]
+ if {[string index $dirurl end] != "/"} {
+ ::vfs::log "ftp-vfs: adding missing directory delimiter to mount point"
+ append dirurl "/"
}
- if {![regexp {(([^:]*)(:([^@]*))?@)?([^/]*)(/(.*/)?([^/]*))?$} $dirurl \
- junk junk user junk pass host "" path file]} {
+
+ if {![regexp {(ftp://)?(([^:]*)(:([^@]*))?@)?([^/]*)(/(.*/)?([^/]*))?$} \
+ $dirurl junk junk junk user junk pass host "" path file]} {
return -code error "Sorry I didn't understand\
the url address \"$dirurl\""
}
}
}
+ if {![catch {vfs::filesystem info $dirurl}]} {
+ # unmount old mount
+ ::vfs::log "ftp-vfs: unmounted old mount point at $dirurl"
+ vfs::unmount $dirurl
+ }
::vfs::log "ftp $host, $path mounted at $fd"
vfs::filesystem mount $local [list vfs::ftp::handler $fd $path]
# Register command to unmount
set token [::http::geturl $dirurl -validate 1]
+ if {![catch {vfs::filesystem info $dirurl}]} {
+ # unmount old mount
+ ::vfs::log "ftp-vfs: unmounted old mount point at $dirurl"
+ vfs::unmount $dirurl
+ }
::vfs::log "http $host, $path mounted at $local"
vfs::filesystem mount $local [list vfs::http::handler $dirurl $path]
# Register command to unmount
namespace eval ::vfs::urltype {}
proc vfs::urltype::Mount {type} {
- # This requires Tcl 8.4a4.
+ set mountPoint [_typeToMount $type]
+ ::vfs::addVolume $mountPoint
+ ::vfs::filesystem mount $mountPoint [list vfs::urltype::handler $type]
+ return "Mounted at \"${mountPoint}\""
+}
+
+proc vfs::urltype::Unmount {type} {
+ set mountPoint [_typeToMount $type]
+ ::vfs::filesystem unmount $mountPoint
+ ::vfs::removeVolume $mountPoint
+}
+
+proc vfs::urltype::_typeToMount {type} {
set mountPoint "${type}://"
if {$type == "file"} {
append mountPoint "/"
}
- ::vfs::addVolume "${mountPoint}"
- ::vfs::filesystem mount $mountPoint [list vfs::urltype::handler $type]
- return "Mounted at \"${mountPoint}\""
+ return $mountPoint
}
proc vfs::urltype::handler {type cmd root relative actualpath args} {