Path: csiph.com!news.mixmin.net!aioe.org!BHGTVyTGRwF2ntnqLVfpDg.user.46.165.242.75.POSTED!not-for-mail From: "R.Wieser" Newsgroups: microsoft.public.scripting.vbscript Subject: Re: Finally found it! A seekable file stream Date: Wed, 9 Mar 2022 16:58:42 +0100 Organization: Aioe.org NNTP Server Lines: 45 Message-ID: References: <8yrub5dio333.di58abv72sye$.dlg@40tude.net> Injection-Info: gioia.aioe.org; logging-data="8318"; posting-host="BHGTVyTGRwF2ntnqLVfpDg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; X-RFC2646: Format=Flowed; Original X-MSMail-Priority: Normal X-Notice: Filtered by postfilter v. 0.9.2 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-Priority: 3 Xref: csiph.com microsoft.public.scripting.vbscript:12433 Mayayana, > For example, ... if you use ReadAll it will be snipped at > the first null. Not quite. Have you ever looked at the last series of bytes in both the actual file are the resulting "readall" buffer ? They match. Also, up until a certain number of bytes embedded NUL chars *and their following data* will be kept as you have provided it. The problem is that "readall" reads the file in chunks. When the current buffer overflows a new buffer is allocated the size of the old one + the size of a chunk, and copies the old buffer into the new buffer. And that copy method is where it goes wrong - it does a zero-terminated string copy*, instead of (a much simpler) block copy. But it still it stores the new data at the correct point in that buffer - into the last block of it. Hence the start *and* the end of the file matching the "readall" result. * That copy method actually has got two paths, one for zero-terminated string, and another for binary. My guess is therefore that someone made a fat-finger error - providing a True where a False should have been (or vice-verse). > The WSH designers were surprisingly sloppy. Tell me about it. Like the dictionary object *which adds a key* when you ask for it to return the data of a key and the key doesn't exist yet. It makes a bit of a mockery of the objects "exists" method. The most surprising to me is that neither have been fixed ... > I suppose that at the time it was just a seat-of-the-pants GUI > update to DOS that they figured would only be needed by a few > people. It was also used as the MS script language for webpages (as a "better" alternative to JS). I remember it as part of IE5 (W98). Regards, Rudy Wieser