By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.SignUp Now!
v:\> d 1m* 2023-07-10 11:32 1,048,576 1meg.rnd v:\> wsl cd /v ; split -n 3 /v/1meg.rnd v:\> d xa? 2023-08-01 15:44 349,525 xaa 2023-08-01 15:44 349,525 xab 2023-08-01 15:44 349,526 xac
This plugin took less than 2 hours to write (and it will probably take a day to polish it, add error control, and test it more than once).I don't, but it might be a fun project. As Joe asked, are you looking to split binary files or text files? By lines or bytes?
v:\> help split SPLIT N (pieces) file_name v:\> split 5 1meg.rnd v:\> d 1m* 2023-07-10 11:32 1,048,576 1meg.rnd 2023-08-01 17:32 209,716 1meg.rnd_1 2023-08-01 17:32 209,716 1meg.rnd_2 2023-08-01 17:32 209,716 1meg.rnd_3 2023-08-01 17:32 209,716 1meg.rnd_4 2023-08-01 17:32 209,712 1meg.rnd_5
For me, with piece_size specified, there is no computation; I don't need to know n_pieces. I'd just read piece_size and write however much was read (which, for the last piece might be less than the piece_size) It'll be done when the reading produces 0 bytes.If it's by piece size - what would the computation be?
I thought I had a working plugin template for Visual Studio; I have one but I wouldn't call it working. So I don't have a good mechanism for making ad hoc plugins. Charles, if you want the barebones code that produced the example above, just say so.
SPLIT /P|/S N filename Split file into pieces without regard for content N = number of pieces (/P) or piece size in bytes (/S) filesize < 2^32; 2 <= N <= filesize/2
COPY /B piece_* reassembly.
v:\> d 1g* 2023-08-02 14:52 1,073,741,824 1gig.rnd v:\> split /p 5 1gig.rnd v:\> d 1g* 2023-08-02 14:52 1,073,741,824 1gig.rnd 2023-08-02 14:53 214,748,365 1gig.rnd_1 2023-08-02 14:53 214,748,365 1gig.rnd_2 2023-08-02 14:53 214,748,365 1gig.rnd_3 2023-08-02 14:53 214,748,365 1gig.rnd_4 2023-08-02 14:53 214,748,364 1gig.rnd_5 v:\> copy /b 1gig.rnd_* wholefile.rnd V:\1gig.rnd_1 => V:\wholefile.rnd V:\1gig.rnd_2 =>> V:\wholefile.rnd V:\1gig.rnd_3 =>> V:\wholefile.rnd V:\1gig.rnd_4 =>> V:\wholefile.rnd V:\1gig.rnd_5 =>> V:\wholefile.rnd 5 files copied v:\> echo %@compare[1gig.rnd,wholefile.rnd] 1
v:\> rndmfile 4gig.rnd %@eval[2**32-1] v:\> bsplit 4gig.rnd FileUtils plugin: Can’t get file size for "D:\work\4gig.rnd"
v:\> rndmfile 1meg.rnd %@eval[2**20] v:\> bsplit 1meg.rnd * FileSize = 1048576 * Opened input file 'D:\work\1meg.rnd'.
That's better.Major goof on my part. I've re-zipped and re-uploaded; would you mind trying again?
v:\> bsplit /n:2 1meg.rnd Creating file "v:\1meg.000" Creating file "v:\1meg.001" v:\> d 1m* 2023-08-02 16:38 524,288 1meg.000 2023-08-02 16:38 524,288 1meg.001 2023-08-02 16:37 1,048,576 1meg.rnd
Looks like it should work.I'm using QueryFileSize(). I should use GetFileSize() instead!
__int64 WINAPI QueryFileSize( LPCTSTR pszName, int fAllocated ); /* Returns the file size for the file pszName, or -1 if it doesn't exist. fAllocated = if != 0, return the allocated size. */
I could make a guess. If QueryFileSize() uses GetFileSize() ... When GetFileSize() fails and you have asked for dwFileSizeHigh, it returns 2^32-1 (INVALID_FILE_SIZE). But that's only an error if (also) GetLastError() != NO_ERROR. It could be QFS() isn't checking that additional condition.I'm using QueryFileSize(). I should use GetFileSize() instead!
I could make a guess. If QueryFileSize() uses GetFileSize() ... When GetFileSize() fails and you have asked for dwFileSizeHigh, it returns 2^32-1 (INVALID_FILE_SIZE). But that's only an error if (also) GetLastError() != NO_ERROR. It could be QFS() isn't checking that additional condition.