This repository has been archived by the owner on Apr 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved ABMP7/10 integration with PACK
- Loading branch information
Marcin Kurczewski
committed
Apr 1, 2015
1 parent
b2ed126
commit 6a270ee
Showing
10 changed files
with
141 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef FORMATS_QLIE_ABMP10_ARCHIVE_H | ||
#define FORMATS_QLIE_ABMP10_ARCHIVE_H | ||
#include "formats/archive.h" | ||
|
||
namespace Formats | ||
{ | ||
namespace QLiE | ||
{ | ||
class Abmp10Archive final : public Archive | ||
{ | ||
public: | ||
void unpack_internal(File &, FileSaver &) const override; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "formats/qlie/abmp7_archive.h" | ||
#include "util/encoding.h" | ||
using namespace Formats::QLiE; | ||
|
||
namespace | ||
{ | ||
const std::string magic("ABMP7", 5); | ||
|
||
void read_first_file(File &arc_file, FileSaver &file_saver) | ||
{ | ||
size_t length = arc_file.io.read_u32_le(); | ||
std::unique_ptr<File> subfile(new File); | ||
subfile->io.write_from_io(arc_file.io, length); | ||
subfile->name = arc_file.name + "$.dat"; | ||
subfile->guess_extension(); | ||
file_saver.save(std::move(subfile)); | ||
} | ||
|
||
void read_next_file(File &arc_file, FileSaver &file_saver) | ||
{ | ||
std::string encoded_name = arc_file.io.read(arc_file.io.read_u8()); | ||
arc_file.io.skip(31 - encoded_name.size()); | ||
std::string name = convert_encoding(encoded_name, "cp932", "utf-8"); | ||
size_t length = arc_file.io.read_u32_le(); | ||
std::unique_ptr<File> subfile(new File); | ||
subfile->io.write_from_io(arc_file.io, length); | ||
subfile->name = arc_file.name + "_" + name + ".dat"; | ||
subfile->guess_extension(); | ||
file_saver.save(std::move(subfile)); | ||
} | ||
} | ||
|
||
void Abmp7Archive::unpack_internal(File &arc_file, FileSaver &file_saver) const | ||
{ | ||
if (arc_file.io.read(magic.size()) != magic) | ||
throw std::runtime_error("Not an ABMP7 container"); | ||
|
||
arc_file.io.seek(12); | ||
arc_file.io.skip(arc_file.io.read_u32_le()); | ||
|
||
read_first_file(arc_file, file_saver); | ||
while (arc_file.io.tell() < arc_file.io.size()) | ||
read_next_file(arc_file, file_saver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef FORMATS_QLIE_ABMP7_ARCHIVE_H | ||
#define FORMATS_QLIE_ABMP7_ARCHIVE_H | ||
#include "formats/archive.h" | ||
|
||
namespace Formats | ||
{ | ||
namespace QLiE | ||
{ | ||
class Abmp7Archive final : public Archive | ||
{ | ||
public: | ||
void unpack_internal(File &, FileSaver &) const override; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.