Skip to content

Commit

Permalink
fix(vpkpp): remove removeDirectory method, forgot how i store pack fi…
Browse files Browse the repository at this point in the history
…les lmao
  • Loading branch information
craftablescience committed Jul 18, 2024
1 parent 833fc86 commit a04d3ea
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 76 deletions.
3 changes: 0 additions & 3 deletions include/vpkpp/PackFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ class PackFile {
/// Remove an entry
virtual bool removeEntry(const std::string& filename_);

/// Remove a directory
virtual bool removeDirectory(const std::string& dirPath_);

/// If output folder is unspecified, it will overwrite the original
virtual bool bake(const std::string& outputDir_ /*= ""*/, const Callback& callback /*= nullptr*/) = 0;

Expand Down
2 changes: 0 additions & 2 deletions include/vpkpp/format/VPK.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ class VPK : public PackFile {

bool removeEntry(const std::string& filename_) override;

bool removeDirectory(const std::string& dirPath_) override;

bool bake(const std::string& outputDir_ /*= ""*/, const Callback& callback /*= nullptr*/) override;

[[nodiscard]] std::string getTruncatedFilestem() const override;
Expand Down
2 changes: 0 additions & 2 deletions lang/c/include/vpkppc/PackFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ SOURCEPP_API void vpkpp_add_entry_from_mem(vpkpp_pack_file_handle_t handle, cons

SOURCEPP_API bool vpkpp_remove_entry(vpkpp_pack_file_handle_t handle, const char* filename);

SOURCEPP_API bool vpkpp_remove_directory(vpkpp_pack_file_handle_t handle, const char* dirPath);

SOURCEPP_API bool vpkpp_bake(vpkpp_pack_file_handle_t handle, const char* outputDir);

SOURCEPP_API bool vpkpp_extract_entry(vpkpp_pack_file_handle_t handle, vpkpp_entry_handle_t entry, const char* filePath);
Expand Down
7 changes: 0 additions & 7 deletions lang/c/src/vpkppc/PackFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ SOURCEPP_API bool vpkpp_remove_entry(vpkpp_pack_file_handle_t handle, const char
return Convert::packFile(handle)->removeEntry(filename);
}

SOURCEPP_API bool vpkpp_remove_directory(vpkpp_pack_file_handle_t handle, const char* dirPath) {
SOURCEPP_EARLY_RETURN_VAL(handle, false);
SOURCEPP_EARLY_RETURN_VAL(dirPath, false);

return Convert::packFile(handle)->removeDirectory(dirPath);
}

SOURCEPP_API bool vpkpp_bake(vpkpp_pack_file_handle_t handle, const char* outputDir) {
SOURCEPP_EARLY_RETURN_VAL(handle, false);
SOURCEPP_EARLY_RETURN_VAL(outputDir, false);
Expand Down
11 changes: 0 additions & 11 deletions lang/csharp/src/vpkpp/PackFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ internal static unsafe partial class Extern
[DllImport("vpkppc")]
public static extern byte vpkpp_remove_entry(void* handle, [MarshalAs(UnmanagedType.LPStr)] string filename);

[DllImport("vpkppc")]
public static extern byte vpkpp_remove_directory(void* handle, [MarshalAs(UnmanagedType.LPStr)] string dirPath);

[DllImport("vpkppc")]
public static extern byte vpkpp_bake(void* handle, [MarshalAs(UnmanagedType.LPStr)] string outputDir);

Expand Down Expand Up @@ -296,14 +293,6 @@ public bool RemoveEntry(string filename)
}
}

public bool RemoveDirectory(string dirPath)
{
unsafe
{
return Convert.ToBoolean(Extern.vpkpp_remove_directory(Handle, dirPath));
}
}

public bool Bake(string outputDir)
{
unsafe
Expand Down
23 changes: 0 additions & 23 deletions src/vpkpp/PackFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,29 +290,6 @@ bool PackFile::removeEntry(const std::string& filename_) {
return false;
}

bool PackFile::removeDirectory(const std::string& dirPath_) {
if (this->isReadOnly()) {
return false;
}

auto dirPath = dirPath_;
string::normalizeSlashes(dirPath);
if (!this->isCaseSensitive()) {
string::toLower(dirPath);
}

bool foundAnything = false;
if (this->unbakedEntries.contains(dirPath)) {
foundAnything = true;
this->unbakedEntries.erase(dirPath);
}
if (this->entries.contains(dirPath)) {
foundAnything = true;
this->entries.erase(dirPath);
}
return foundAnything;
}

bool PackFile::extractEntry(const Entry& entry, const std::string& filePath) const {
if (filePath.empty()) {
return false;
Expand Down
28 changes: 0 additions & 28 deletions src/vpkpp/format/VPK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,34 +432,6 @@ bool VPK::removeEntry(const std::string& filename_) {
return PackFile::removeEntry(filename_);
}

bool VPK::removeDirectory(const std::string& dirPath_) {
if (this->isReadOnly()) {
return false;
}

auto dirPath = dirPath_;
string::normalizeSlashes(dirPath);
if (!this->isCaseSensitive()) {
string::toLower(dirPath);
}

bool removedAnything = false;
if (this->unbakedEntries.contains(dirPath)) {
removedAnything = true;
this->unbakedEntries.erase(dirPath);
}
if (this->entries.contains(dirPath)) {
removedAnything = true;
for (const auto& entry : this->entries.at(dirPath)) {
if (entry.flags & VPK_FLAG_REUSING_CHUNK) {
this->freedChunks.push_back({entry.offset, entry.length, entry.archiveIndex});
}
}
this->entries.erase(dirPath);
}
return removedAnything;
}

bool VPK::bake(const std::string& outputDir_, const Callback& callback) {
// Get the proper file output folder
std::string outputDir = this->getBakeOutputDir(outputDir_);
Expand Down

0 comments on commit a04d3ea

Please sign in to comment.