Dodaj pliki projektów.
This commit is contained in:
parent
4912ed6774
commit
f6150b0d17
18 changed files with 9210 additions and 0 deletions
153
voidcmd.cpp
Normal file
153
voidcmd.cpp
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//============================================================================
|
||||
// Name : Void Archive Tool
|
||||
// Author : Yanczi
|
||||
// Version : 1.1
|
||||
// Copyright : Yanczi 19-06-2025
|
||||
// Description : Void Archive Tool. Packing and extract files
|
||||
//============================================================================
|
||||
|
||||
#include <iostream>
|
||||
#include <ftxui/dom/elements.hpp>
|
||||
#include <ftxui/screen/screen.hpp>
|
||||
|
||||
#include "CreateCargo.h"
|
||||
#include "ExtractCargo.h"
|
||||
#include "ViewCargo.h"
|
||||
#include "Interface.h"
|
||||
|
||||
void RenderHelp()
|
||||
{
|
||||
const std::string HelpTitle = "< Manual >";
|
||||
const std::string HelpInstruction =
|
||||
"voidarchive <parametr> <plik & katalog> \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 <directory>.txt\n"
|
||||
"EXTRACTING -x Extract files from the specified container \n"
|
||||
"LISTING -ls List files stored in a container \n"
|
||||
" \n"
|
||||
" \n"
|
||||
"<catalog>.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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue