function File.JoinBinary(FilePath, OutPath, call) local counter = 1; local buffer = 2^12; if not File.DoesExist(FilePath) then return -1, "File doesn't exist"; end local tAt = String.SplitPath(FilePath); local sF = (String.SplitPath(OutPath).Extension~= "") and OutPath or OutPath.."\\"..tAt.Filename; local fileout, state_msg = io.open(sF, "ab"); if not fileout or state_msg then return -1, "Couldn't open destination file"; end local sD = tAt.Drive..tAt.Folder..tAt.Filename local n = 1; while true do if not File.DoesExist(sD.."."..string.format("%0"..(#tAt.Extension-1).."d", n)) then break; else n = n + 1; end end n = n-1; while true do if call then local a = call(counter, n); if not a then return -1, "Process cancelled by user" end end local sFile = sD.."."..string.format("%0"..(#tAt.Extension-1).."d", counter); if not File.DoesExist(sFile) then break; else local filesize = File.GetSize(sFile); local filesource, state_msg = io.open(sFile, "rb"); if not filesource or state_msg or filesize <= 1 then fileout:close(); return -1, "Couldn't open source file: "..sFile; else while true do local block = filesource:read(buffer); if not block then break; end fileout:write(block); end end if filesource then filesource:close(); end counter = counter+1; end end fileout:close(); return 0, "Success"; end