"" -
"r" {
ftp::Get $fd $name -variable tmp
- package require Memchan
- set filed [memchan]
+ set filed [vfs::memchan]
fconfigure $filed -translation binary
puts -nonewline $filed $tmp
if {[catch [list ::ftp::Append $fd -data "" $name] err] || !$err} {
error "Can't open $name for appending"
}
- package require Memchan
- set filed [memchan]
+
+ set filed [vfs::memchan]
return [list $filed [list ::vfs::ftp::_closing $fd $name $filed Append]]
}
"w*" {
if {[catch [list ::ftp::Put $fd -data "" $name] err] || !$err} {
error "Can't open $name for writing"
}
- package require Memchan
- set filed [memchan]
+
+ set filed [vfs::memchan]
return [list $filed [list ::vfs::ftp::_closing $fd $name $filed Put]]
}
default {
"" -
"r" {
set state [::http::geturl [file join $dirurl $name]]
- package require Memchan
- set filed [memchan]
+ set filed [vfs::memchan]
fconfigure $filed -translation binary
puts -nonewline $filed [::http::data $state]
::mk4vfs::stat $db $file sb
if { $sb(csize) != $sb(size) } {
- package require Trf
- package require Memchan
- set fd [memchan]
+ set fd [vfs::memchan]
fconfigure $fd -translation binary
set s [mk::get $sb(ino) contents]
- puts -nonewline $fd [zip -mode decompress $s]
+ puts -nonewline $fd [vfs::zip -mode decompress $s]
fconfigure $fd -translation auto
seek $fd 0
return [list $fd [list _memchan_handler close $fd]]
} elseif { $::mk4vfs::direct } {
- package require Trf
- package require Memchan
- set fd [memchan]
+ set fd [vfs::memchan]
fconfigure $fd -translation binary
puts -nonewline $fd [mk::get $sb(ino) contents]
}
if { $sb(csize) != $sb(size) } {
- package require Trf
- package require Memchan
append mode z
- set fd [memchan]
+ set fd [vfs::memchan]
fconfigure $fd -translation binary
set s [mk::get $sb(ino) contents]
- puts -nonewline $fd [zip -mode decompress $s]
+ puts -nonewline $fd [vfs::zip -mode decompress $s]
fconfigure $fd -translation auto
} else {
set fd [mk::channel $sb(ino) contents a]
}
if { [string match *z* $mode] || $mk4vfs::compress } {
- package require Trf
- package require Memchan
append mode z
- set fd [memchan]
+ set fd [vfs::memchan]
} else {
set fd [mk::channel $sb(ino) contents w]
}
switch -- $mode {
"" -
"r" {
- package require Memchan
-
- set nfd [memchan]
+ set nfd [vfs::memchan]
fconfigure $nfd -translation binary
puts -nonewline $nfd [_generate ::${ns}::${name}]
fconfigure $nfd -translation auto
}
}
+# This can be overridden to use a different memchan implementation
+proc ::vfs::memchan {args} {
+ ::package require Memchan
+ uplevel 1 ::memchan $args
+}
+
+# This can be overridden to use a different zlib implementation
+proc ::vfs::zlib {args} {
+ ::package require Trf
+ uplevel 1 ::zlib $args
+}
+
+# This can be overridden to use a different zlib implementation
+proc ::vfs::zip {args} {
+ ::package require Trf
+ uplevel 1 ::zip $args
+}
+
proc ::vfs::autoMountExtension {ext cmd {pkg ""}} {
variable extMounts
set extMounts($ext) [list $cmd $pkg]
package require vfs
-package require pink
package provide zipvfs 1.0
# Using the vfs, memchan and Trf extensions, we ought to be able
::zip::stat $zipfd $name sb
- package require Memchan
-
- set nfd [memchan]
+ set nfd [vfs::memchan]
fconfigure $nfd -translation binary
seek $zipfd $sb(ino) start
if { $sb(method) != 0 } {
if { [catch {
- set data [zlib decompress $data]
+ set data [vfs::zlib decompress $data]
} err] } {
::vfs::log "$sb(name): inflate error: $err"
binary scan $data H* x
}
return
if { $verify } {
- set ncrc [zlib crc32 $data]
+ set ncrc [vfs::zlib crc32 $data]
if { $ncrc != $sb(crc) } {
tclLog [format {%s: crc mismatch: expected 0x%x, got 0x%x} \
$sb(name) $sb(crc) $ncrc]
if {[info exists env(TEMP)] && [file writable $env(TEMP)]} {
set vfsTestDir $env(TEMP)
tcltest::testConstraint vfsWritable 1
- puts stdout "Using temporary directory for some files"
+ puts stdout "Using temporary directory for some files\
+ (since [pwd] is not writable)"
} else {
tcltest::testConstraint vfsWritable 0
}