Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split huge files
i cant' find the topic, kent asked this some time ago?
large file questions

how to split a 1GB file to 399mb pieces?
i have 180 GB of data which need to be split into 399mb pieces.

joining them usually can be done with 7zip, but it also would be nice to have qm code for this.
Function SplitFile
Copy      Help
function $file_ $destFolder partSizeMB

;Splits file into smaller files.
;Error if fails.

;file_ - file.
;destFolder - folder for file parts. Creates if does not exist.
;partSizeMB - part size, MB.

;Error if destFolder contains files with same names as of new files. You should delete old file part files or whole folder before calling this function.

str sf1.expandpath(file_) sf2 sff.expandpath(destFolder) sfn.getfilename(sf1 1)

mkdir sff

__HFile f1 f2

int fi bs(1024*1024) br newFile(1) ps
str sb.all(bs)

,if(!ReadFile(f1 sb bs &br 0)) end "failed"
,if(!br) ret
,if newFile
,,sf2.format("%s\%s_%i" sff sfn fi)
,if(!WriteFile(f2 sb br &_i 0)) end "failed"
,ps-1; if(!ps) newFile=1

err+ end _error

Now you also know how to create function to join.

Forum Jump:

Users browsing this thread: 1 Guest(s)