Concatenating/appending files on Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Concatenating/appending files on Windows

Wayne Johnston
I don't see a VA method to append one file onto another.  It's easy to open the "source" file and get its #contents, and write that to the "destination" file.  But that means the entire contents of the source file is in memory, which can be a problem if it's huge.

Is there another way besides getting chunks of the source file and appending each chunk?

Guess I could create & invoke a command/batch script which runs the COPY command to do the append...

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating/appending files on Windows

Seth Berman
Hi Wayne,

So are you saying you do not wish to do something like:

| dest source bufferSize bytesLeft sourceSize |

source := CfsReadFileStream open: 'fileA.txt'.
source isBytes: true.
sourceSize := source size.

dest := CfsWriteFileStream open: 'fileB.txt'.
dest setToEnd.
dest isBytes: true.

bytesLeft := sourceSize.
bufferSize := 16 * 1024.
[
[source atEnd] whileFalse: [
              dest nextPutAll: (source next: (bytesLeft min: bufferSize)).
              bytesLeft := bytesLeft - (bytesLeft min: bufferSize).
].
] ensure: [source close. dest close]



On Thursday, March 29, 2018 at 1:02:11 PM UTC-4, Wayne Johnston wrote:
I don't see a VA method to append one file onto another.  It's easy to open the "source" file and get its #contents, and write that to the "destination" file.  But that means the entire contents of the source file is in memory, which can be a problem if it's huge.

Is there another way besides getting chunks of the source file and appending each chunk?

Guess I could create & invoke a command/batch script which runs the COPY command to do the append...

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating/appending files on Windows

Wayne Johnston
That is indeed what I'd like to do - avoiding #contents.  Thanks for writing my code for me!  ;-)  Actually I was coming up with equivalent code but I like your isBytes:true, and I was going to use a 32k buffer for no good reason...

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating/appending files on Windows

Seth Berman
Hi Wayne,

My pleasure.  Yeah that's ok...I wasn't in the mood to write my own code today:)

-- Seth


On Thursday, March 29, 2018 at 4:46:14 PM UTC-4, Wayne Johnston wrote:
That is indeed what I'd like to do - avoiding #contents.  Thanks for writing my code for me!  ;-)  Actually I was coming up with equivalent code but I like your isBytes:true, and I was going to use a 32k buffer for no good reason...

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.