Deutsch   English   Français   Italiano  
<20250421163621.744e3aea@officepc>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Scott Pitcher <scotty@svptechnicalservices.com.au>
Newsgroups: comp.lang.tcl
Subject: Re: File ops on a VFS mounted file
Date: Mon, 21 Apr 2025 16:36:28 +1000
Organization: SVP TECHNICAL SERVICES
Lines: 83
Message-ID: <20250421163621.744e3aea@officepc>
References: <20250421114119.79ff1721@officepc>
	<vu4kuk$1h294$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 21 Apr 2025 08:36:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a75ec9d72baa437077f4d5bd96793abc";
	logging-data="1676458"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19eBHL4pLcjPbNeE/mQMkDNFcjdlJTnEZA="
Cancel-Lock: sha1:gPQN+6ZYoUzuGfkJ+ezV0vRgSkc=
X-Newsreader: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu)

On Mon, 21 Apr 2025 10:56:44 +0530
Ashok <apnmbx-public@yahoo.com> wrote:

I did try a simple test before I emailed, where argv0 and [info
nameofexecutable] are the same thing -

set fdin [open $argv0 "rb"]
set fdout [open $opts(1) "wb"]
puts -nonewline $fdout [read $fdin]

- but this fails because $argv0 is already mounted automatically when
the executable is first run. Trying to open $argv0 is interpreted as
attempting to open a directory for reading.

I'm looking at mk4tcl... source now and particularly mk4tcl.cpp. It
might be easier to expose either a binary dump of the file or handle
access.

Kind regards,
Scott



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