rpcsx/rpcs3/Loader/TAR.h
Eladash a9ddb1d3b3 GUI: Implement full extraction of PUP
* Implement full extraction of PS3UPDAT.PUP.
* Implement TAR extraction via GUI.
* Use VFS to implement missing PS3 filesystem characters escaping.
* Use VFS to error on illegal paths. (illegal paths such as malware pointing to "/../../..and so on../C:/Windows")
2021-03-19 17:51:09 +01:00

42 lines
953 B
C++

#pragma once
#include <map>
struct TARHeader
{
char name[100];
char dontcare[24];
char size[12];
char mtime[12];
char chksum[8];
char filetype;
char linkname[100];
char magic[6];
char dontcare2[82];
char prefix[155];
char padding[12];
};
class tar_object
{
const fs::file& m_file;
usz largest_offset = 0; // We store the largest offset so we can continue to scan from there.
std::map<std::string, std::pair<u64, TARHeader>> m_map; // Maps path to offset of file data and its header
TARHeader read_header(u64 offset) const;
public:
tar_object(const fs::file& file);
std::vector<std::string> get_filenames();
fs::file get_file(const std::string& path);
// Extract all files in archive to destination as VFS
// Allow to optionally specify explicit mount point (which may be directory meant for extraction)
bool extract(std::string vfs_mp = {});
};
bool extract_tar(const std::string& file_path, const std::string& dir_path);