/*
* This file is part of VoidArchiveTool.
*
* Copyright (C) 2025 Yanczi
*
* Void Archive Toolis free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
//============================================================================
// Name : Void Archive Tool
// Author : Yanczi
// Version : 1.1
// Copyright : Yanczi 19-06-2025
// Description : Void Archive Tool. Packing and extract files
//============================================================================
#include
#include
#include
#include "CreateCargo.h"
#include "ExtractCargo.h"
#include "ViewCargo.h"
#include "Interface.h"
void RenderHelp()
{
const std::string HelpTitle = "< Manual >";
const std::string HelpInstruction =
"voidarchive \n"
" \n"
"COMPRESSION -c Pack and compress files from the specified directory \n"
"PACKING -p Pack files from the specified directory \n"
"FILTERING -f Pack the files according to the guidelines given in the .txt\n"
"EXTRACTING -x Extract files from the specified container \n"
"LISTING -ls List files stored in a container \n"
" \n"
" \n"
".txt \n"
" \n"
"Keys: \n"
" \n"
" {compress} - Compressing files -> /path/data/file.txt *.txt *.* - All files \n"
" {ignore} - Ignoring concrete files -> /path/data/file.txt *.txt \n";
Interface tui;
tui.TextBorder(HelpTitle, HelpInstruction);
}
bool EmptyPath(std::string path)
{
if (path == "")
{
std::cerr << "Error: Nie podano sciezki!" << std::endl;
return false;
}
return true;
}
int main(int argc, char* argv[]) {
std::string path = "";
std::cout << "\n" << PROGRAM_TITLE << " " << PROGRAM_VERSION << " Release " << PROGRAM_COMPILING << std::endl;
std::cout << "Author: " << PROGRAM_AUTHOR << std::endl;
std::cout << "License: " << PROGRAM_LICENSE << "\n" << std::endl;
CreateCargo cargo;
ExtractCargo extract;
ViewCargo viewCargo;
for (int i = 0; i < argc; ++i)
{
std::string arg = argv[i];
if (arg == "-c" && i + 1 < argc)
{
path = argv[i + 1];
if (!EmptyPath(path)) { return 1; }
if (!cargo.Create(path, true, false))
{
return 1;
}
i++;
}
if (arg == "-p" && i + 1 < argc)
{
path = argv[i + 1];
if (!cargo.Create(path, false, false))
{
return 1;
}
i++;
}
if (arg == "-f" && i + 1 < argc)
{
path = argv[i + 1];
if (!EmptyPath(path)) { return 1; }
if (!cargo.Create(path, false, true))
{
return 1;
}
i++;
}
if (arg == "-x" && i + 1 < argc)
{
path = argv[i + 1];
if (!EmptyPath(path)) { return 1; }
if (!extract.Extract(path))
{
return 1;
}
i++;
}
if (arg == "-ls" && i + 1 < argc)
{
path = argv[i + 1];
if (!EmptyPath(path)) { return 1; }
if (!viewCargo.View(path))
{
return 1;
}
i++;
}
if (arg == "-help")
{
//std::cout << helpText << std::endl;
RenderHelp();
return 0;
i++;
}
}
return 0;
}