Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » Indigo Rose AutoPlay Media Studio (часть 5)

Модерирует : gyra, Maz

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

CryptoUsbtor



Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
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
 

Всего записей: 745 | Зарегистр. 24-04-2016 | Отправлено: 08:52 20-09-2017 | Исправлено: CryptoUsbtor, 08:59 20-09-2017
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » Indigo Rose AutoPlay Media Studio (часть 5)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru