|
|
|
|
|
#zip file with Tcl loader prepended. |
|
|
#generated using modpod::make_zip_modpod |
|
|
if {[catch {file normalize [info script]} modfile]} { |
|
|
error "modpod zip stub error. Unable to determine module path. (possible safe interp restrictions?)" |
|
|
} |
|
|
if {$modfile eq "" || ![file exists $modfile]} { |
|
|
error "modpod zip stub error. Unable to determine module path" |
|
|
} |
|
|
set moddir [file dirname $modfile] |
|
|
set mod_and_ver [file rootname [file tail $modfile]] |
|
|
lassign [split $mod_and_ver -] moduletail version |
|
|
if {[file exists $moddir/#modpod-$mod_and_ver]} { |
|
|
source $moddir/#modpod-$mod_and_ver/$mod_and_ver.tm |
|
|
} else { |
|
|
if {[info commands tcl::zipfs::mount] ne ""} { |
|
|
#argument order changed to be consistent with vfs::zip::Mount etc |
|
|
#early versions: zipfs::Mount mountpoint zipname |
|
|
#since 2023-09: zipfs::Mount zipname mountpoint |
|
|
#don't use 'file exists' when testing mountpoints. (some versions at least give massive delays on non-existance) |
|
|
set mountpoints [dict keys [tcl::zipfs::mount]] |
|
|
if {"//zipfs:/#mounted-modpod-$mod_and_ver" ni $mountpoints} { |
|
|
#despite API change tcl::zipfs package version was unfortunately not updated - so we don't know argument order without trying it |
|
|
if {[catch { |
|
|
#tcl::zipfs::mount $modfile //zipfs:/#mounted-modpod-$mod_and_ver ;#extremely slow if this is a wrong guess (artifact of aforementioned file exists issue ?) |
|
|
tcl::zipfs::mount $modfile #mounted-modpod-$mod_and_ver |
|
|
} errM]} { |
|
|
#try old api |
|
|
tcl::zipfs::mount //zipfs:/#mounted-modpod-$mod_and_ver $modfile |
|
|
} |
|
|
if {![file exists //zipfs:/#mounted-modpod-$mod_and_ver/#modpod-$mod_and_ver/$mod_and_ver.tm]} { |
|
|
tcl::zipfs::unmount //zipfs:/#mounted-modpod-$mod_and_ver |
|
|
} |
|
|
source //zipfs:/#mounted-modpod-$mod_and_ver/#modpod-$mod_and_ver/$mod_and_ver.tm |
|
|
} |
|
|
} else { |
|
|
#fallback to slower vfs::zip |
|
|
if {![file exists $moddir/#mounted-modpod-$mod_and_ver]} { |
|
|
if {[catch {package require vfs::zip} errM]} { |
|
|
set msg "Unable to load vfs::zip package to mount module $mod_and_ver" |
|
|
append msg \n "If vfs::zip is unavailable - the module can still be loaded by manually unzipping the file $modfile in place." |
|
|
append msg \n "The unzipped data will all be contained in a folder named #modpod-$mod_and_ver in the same parent folder as $ |
|
|
} |
|
|
set fd [vfs::zip::Mount $modfile $moddir/#mounted-modpod-$mod_and_ver] |
|
|
if {![file exists $moddir/#mounted-modpod-$mod_and_ver/#modpod-$mod_and_ver/$mod_and_ver.tm]} { |
|
|
vfs::zip::Unmount $fd $moddir/#mounted-modpod-$mod_and_ver |
|
|
error "Unable to find #modpod-$mod_and_ver/$mod_and_ver.tm in $modfile" |
|
|
} |
|
|
} |
|
|
source $moddir/#mounted-modpod-$mod_and_ver/#modpod-$mod_and_ver/$mod_and_ver.tm |
|
|
} |
|
|
} |
|
|
#zipped data follows |
|
|
PK |