function File.SplitBinaryRandom(filePath, folderPath, minSize, maxSize, CallbackFunction) fileSize = File.GetSize(filePath); counter = 1; files = {}; fileName = String.SplitPath(filePath).Filename..String.SplitPath(filePath).Extension.."."; realpart = io.open(filePath, "rb"); while fileSize > 0 do cSize = Math.Random(minSize, maxSize); if cSize > fileSize then cSize = fileSize; end Table.Insert(files, Table.Count(files)+1, cSize); fileSize = fileSize-cSize; end for i=1, Table.Count(files) do if CallbackFunction ~= nil then CallbackFunction(i, Table.Count(files), Math.Round((i/Table.Count(files))*100, 0), String.ToNumber(Table.Concat(files, "", i, i))); end if i < 10 then cfileName = "00"..i; elseif i < 100 then cfileName = "0"..i; elseif i < 1000 then cfileName = i; end curFile = io.open(folderPath.."\\"..fileName..cfileName, "wb"); curPart = realpart:read(String.ToNumber(Table.Concat(files, "", i, i))); curFile:write(curPart); curFile:close(); end realpart:close(); end function File.SplitBinary(filePath, folderPath, size, CallbackFunction) fileSize = File.GetSize(filePath); counter = 1; files = {}; fileName = String.SplitPath(filePath).Filename..String.SplitPath(filePath).Extension.."."; realpart = io.open(filePath, "rb"); while fileSize > 0 do if size > fileSize then size = fileSize; end Table.Insert(files, Table.Count(files)+1, size); fileSize = fileSize-size; end for i=1, Table.Count(files) do if CallbackFunction ~= nil then CallbackFunction(i, Table.Count(files), Math.Round((i/Table.Count(files))*100, 0)); end if i < 10 then cfileName = "00"..i; elseif i < 100 then cfileName = "0"..i; elseif i < 1000 then cfileName = i; end curFile = io.open(folderPath.."\\"..fileName..cfileName, "wb"); curPart = realpart:read(String.ToNumber(Table.Concat(files, "", i, i))); curFile:write(curPart); curFile:close(); end realpart:close(); end function File.JoinBinary(FilePath, OutFilePath) continue = true; counter = 1; local buffer = 2^12; subcounter = 0; if not (String.Length(String.SplitPath(FilePath).Extension) > 3) or not File.DoesExist(FilePath) then state_msg = _tblErrorMessages[1001]; else state_msg = _tblErrorMessages[0]; end while continue do if String.Length(String.SplitPath(FilePath).Extension) < 5 then if counter < 10 then subcounter = "00"..counter; elseif counter < 100 and counter > 9 then subcounter = "0"..counter; else subcounter = counter; end else if counter < 10 then subcounter = "000"..counter; elseif counter < 1000 and counter < 100 and counter > 9 then subcounter = "00"..counter; elseif counter > 99 and counter < 1000 then subcounter = "0"..counter; else subcounter = counter; end end if not File.DoesExist(String.SplitPath(FilePath).Drive..String.SplitPath(FilePath).Folder..String.SplitPath(FilePath).Filename.."."..subcounter) then continue = false; else local filesize = File.GetSize(FilePath); local nHdSz = File.GetSize(OutFilePath); local filesource, state_msg = io.open(String.SplitPath(FilePath).Drive..String.SplitPath(FilePath).Folder..String.SplitPath(FilePath).Filename.."."..subcounter, "rb"); if not filesource or state_msg or filesize <= 1 then continue = false; else local fileout, state_msg = io.open(OutFilePath, "ab"); if not fileout or state_msg then continue = false; state_msg = _tblErrorMessages[1001]; else while true do local block = filesource:read(buffer); if not block then break; end fileout:write(block); end fileout:close(); end end if filesource then filesource:close(); end counter = counter+1; end end return state_msg; end