Sujet : Re: File ops on a VFS mounted file
De : apnmbx-public (at) *nospam* yahoo.com (Ashok)
Groupes : comp.lang.tclDate : 21. Apr 2025, 06:26:44
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vu4kuk$1h294$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Perhaps you can exec [info nameofexecutable] itself to do the copy
in a cross-platform manner? Either (obviously untested)
set fd [open |[info nameofexecutable]...
puts $fd [list file copy [info nameofexecutable] target]
or
exec [info nameofexecutable] [file join [info nameofexecutable] yourcopyscript.tcl]
where youcopyscript is a Tcl script within your VFS that does
the copy.
Perhaps someone will suggest a simple way ...
/Ashok
On 4/21/2025 7:12 AM, Scott Pitcher wrote:
Hi,
I've got some executables built with kbskit on Windows and Linux, and
I'm trying to get one of them to copy itself to another file, as part of
initialising a new VFS for an end user application.
The VFS was created with vlerq by kbs.tcl.
When the exetuable VFS attempts to copy itself to the target image
(opts(1) == the target file name) -
if {[catch "file copy $extraarg $argv0 $opts(1)" output ropts]} {
ErrorExit 1 "init: failed to create target VFS \"$argv0\": $output"
}
I get the error:
failed to create target VFS "...": can't overwrite file "..." with
directory
- because of course the VFS is also mounted and my script is running
inside of that.
I tried using [open ...] and [puts ... [read ..]] but the VFS image
file can't be opened while it's mounted.
I was able to successfully use [exec cp......], but external tools
probably won't be available on the end user systems and certainly not
on MS Windows.
But if the VFS is mounted then it's already been opened by the VFS
library itself. Perhaps there is a way of duplicating the file handle or
accessing the naked VFS image file without invoking the VFS library?
Kind regards,
Scott