Roughed out archive info function. Functional but lacks validation and checks.
This commit is contained in:
parent
1550a41b3a
commit
99f3d9a07c
@ -1,7 +1,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Project: agstools
|
||||
// Program: archive_tool
|
||||
// Purpose:
|
||||
// Purpose: Data archive unpacking, packing and info tool for Animation Game System engine DAT files.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -10,7 +10,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function: archive_info
|
||||
// Purpose: Displays info about provided archive.
|
||||
void archive_info(std::string& input_path)
|
||||
void archive_info(std::string& input_path) //Unless refactored into class, could create duplicate code issues.
|
||||
{
|
||||
//Struct --NOTE: May move to global if other functions use it or create overall archive class
|
||||
struct file_node
|
||||
@ -20,31 +20,55 @@ void archive_info(std::string& input_path)
|
||||
int location = 0;
|
||||
};
|
||||
|
||||
//Local Variables
|
||||
//Local Variables --Note: Okay! You got me compiler! I'll initialize them this time...
|
||||
std::ifstream input_file;
|
||||
char* p_buffer = NULL;
|
||||
file_node* p_files_array = NULL;
|
||||
short file_count = 0;
|
||||
|
||||
|
||||
//Assumes exists --NOTE: Replace with check to check if exists, then what type.
|
||||
//Assumes exists and opens --NOTE: Replace with check to check if exists, then what type.
|
||||
input_file.open(input_path);
|
||||
p_buffer = new char[8];
|
||||
p_buffer = new char[6];
|
||||
input_file.read(p_buffer, 6); //Reads magic and number count together into buffer
|
||||
|
||||
input_file.read(p_buffer, 8);
|
||||
|
||||
/*
|
||||
if (p_buffer == MAGIC)
|
||||
if ((int)&p_buffer == 1801675120) //This is 4-byte int of 'pack'. Quick 'n dirty compare.
|
||||
{
|
||||
|
||||
file_count = (short)&p_buffer[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
//Not correct format!
|
||||
printf("\nError! Format error!\n");
|
||||
delete[] p_buffer; //Prevent potential memory leak?
|
||||
return;
|
||||
}
|
||||
|
||||
delete[] p_buffer;
|
||||
|
||||
*/
|
||||
;
|
||||
//Read full index
|
||||
p_buffer = new char[file_count * 24];
|
||||
input_file.seekg(6);
|
||||
input_file.read(p_buffer, (file_count * 24)); //sub expression warning but ITS OKAY! I PROMISE! :D
|
||||
|
||||
//Process index into file_node array
|
||||
p_files_array = new file_node[file_count];
|
||||
for (int loop_a = 0; loop_a < file_count; loop_a++)
|
||||
{
|
||||
p_files_array[loop_a].name = p_buffer[(loop_a * 24)]; //Complicated... non-null terminated but fixed size.
|
||||
p_files_array[loop_a].size = p_buffer[(loop_a * 24) + 10];
|
||||
p_files_array[loop_a].location = 0;
|
||||
}
|
||||
|
||||
delete[] p_buffer;
|
||||
|
||||
//Print data cause... info
|
||||
for (int loop_b = 0; loop_b < file_count; loop_b++)
|
||||
{
|
||||
//So... Hey... If there is a lot of files, this gonna make a lot of output, ya know?
|
||||
printf("[%i] %s (%i bytes) (loc %i\n", loop_b + 1, p_files_array[loop_b].name.c_str(), p_files_array[loop_b].size, p_files_array[loop_b].location);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user