diff options
Diffstat (limited to 'core/io/file_access_pack.cpp')
-rw-r--r-- | core/io/file_access_pack.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index d70f2ba445..4fd4d117af 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -35,11 +35,8 @@ #include <stdio.h> Error PackedData::add_pack(const String &p_path, bool p_replace_files) { - for (int i = 0; i < sources.size(); i++) { - if (sources[i]->try_open_pack(p_path, p_replace_files)) { - return OK; }; }; @@ -48,7 +45,6 @@ Error PackedData::add_pack(const String &p_path, bool p_replace_files) { }; void PackedData::add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files) { - PathMD5 pmd5(path.md5_buffer()); //printf("adding path %ls, %lli, %lli\n", path.c_str(), pmd5.a, pmd5.b); @@ -75,9 +71,7 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o Vector<String> ds = p.get_base_dir().split("/"); for (int j = 0; j < ds.size(); j++) { - if (!cd->subdirs.has(ds[j])) { - PackedDir *pd = memnew(PackedDir); pd->name = ds[j]; pd->parent = cd; @@ -97,7 +91,6 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o } void PackedData::add_pack_source(PackSource *p_source) { - if (p_source != nullptr) { sources.push_back(p_source); } @@ -106,7 +99,6 @@ void PackedData::add_pack_source(PackSource *p_source) { PackedData *PackedData::singleton = nullptr; PackedData::PackedData() { - singleton = this; root = memnew(PackedDir); @@ -114,14 +106,12 @@ PackedData::PackedData() { } void PackedData::_free_packed_dirs(PackedDir *p_dir) { - for (Map<String, PackedDir *>::Element *E = p_dir->subdirs.front(); E; E = E->next()) _free_packed_dirs(E->get()); memdelete(p_dir); } PackedData::~PackedData() { - for (int i = 0; i < sources.size(); i++) { memdelete(sources[i]); } @@ -131,7 +121,6 @@ PackedData::~PackedData() { ////////////////////////////////////////////////////////////////// bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) { - FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) return false; @@ -144,7 +133,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) f->seek(f->get_position() - 4); magic = f->get_32(); if (magic != PACK_HEADER_MAGIC) { - f->close(); memdelete(f); return false; @@ -156,7 +144,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) magic = f->get_32(); if (magic != PACK_HEADER_MAGIC) { - f->close(); memdelete(f); return false; @@ -187,7 +174,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) int file_count = f->get_32(); for (int i = 0; i < file_count; i++) { - uint32_t sl = f->get_32(); CharString cs; cs.resize(sl + 1); @@ -210,30 +196,25 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) }; FileAccess *PackedSourcePCK::get_file(const String &p_path, PackedData::PackedFile *p_file) { - return memnew(FileAccessPack(p_path, *p_file)); }; ////////////////////////////////////////////////////////////////// Error FileAccessPack::_open(const String &p_path, int p_mode_flags) { - ERR_FAIL_V(ERR_UNAVAILABLE); return ERR_UNAVAILABLE; } void FileAccessPack::close() { - f->close(); } bool FileAccessPack::is_open() const { - return f->is_open(); } void FileAccessPack::seek(size_t p_position) { - if (p_position > pf.size) { eof = true; } else { @@ -244,25 +225,20 @@ void FileAccessPack::seek(size_t p_position) { pos = p_position; } void FileAccessPack::seek_end(int64_t p_position) { - seek(pf.size + p_position); } size_t FileAccessPack::get_position() const { - return pos; } size_t FileAccessPack::get_len() const { - return pf.size; } bool FileAccessPack::eof_reached() const { - return eof; } uint8_t FileAccessPack::get_8() const { - if (pos >= pf.size) { eof = true; return 0; @@ -273,7 +249,6 @@ uint8_t FileAccessPack::get_8() const { } int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const { - if (eof) return 0; @@ -298,36 +273,30 @@ void FileAccessPack::set_endian_swap(bool p_swap) { } Error FileAccessPack::get_error() const { - if (eof) return ERR_FILE_EOF; return OK; } void FileAccessPack::flush() { - ERR_FAIL(); } void FileAccessPack::store_8(uint8_t p_dest) { - ERR_FAIL(); } void FileAccessPack::store_buffer(const uint8_t *p_src, int p_length) { - ERR_FAIL(); } bool FileAccessPack::file_exists(const String &p_name) { - return false; } FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) : pf(p_file), f(FileAccess::open(pf.pack, FileAccess::READ)) { - ERR_FAIL_COND_MSG(!f, "Can't open pack-referenced file '" + String(pf.pack) + "'."); f->seek(pf.offset); @@ -345,17 +314,14 @@ FileAccessPack::~FileAccessPack() { ////////////////////////////////////////////////////////////////////////////////// Error DirAccessPack::list_dir_begin() { - list_dirs.clear(); list_files.clear(); for (Map<String, PackedData::PackedDir *>::Element *E = current->subdirs.front(); E; E = E->next()) { - list_dirs.push_back(E->key()); } for (Set<String>::Element *E = current->files.front(); E; E = E->next()) { - list_files.push_back(E->get()); } @@ -363,7 +329,6 @@ Error DirAccessPack::list_dir_begin() { } String DirAccessPack::get_next() { - if (list_dirs.size()) { cdir = true; String d = list_dirs.front()->get(); @@ -379,30 +344,24 @@ String DirAccessPack::get_next() { } } bool DirAccessPack::current_is_dir() const { - return cdir; } bool DirAccessPack::current_is_hidden() const { - return false; } void DirAccessPack::list_dir_end() { - list_dirs.clear(); list_files.clear(); } int DirAccessPack::get_drive_count() { - return 0; } String DirAccessPack::get_drive(int p_drive) { - return ""; } Error DirAccessPack::change_dir(String p_dir) { - String nd = p_dir.replace("\\", "/"); bool absolute = false; if (nd.begins_with("res://")) { @@ -430,7 +389,6 @@ Error DirAccessPack::change_dir(String p_dir) { pd = current; for (int i = 0; i < paths.size(); i++) { - String p = paths[i]; if (p == ".") { continue; @@ -439,11 +397,9 @@ Error DirAccessPack::change_dir(String p_dir) { pd = pd->parent; } } else if (pd->subdirs.has(p)) { - pd = pd->subdirs[p]; } else { - return ERR_INVALID_PARAMETER; } } @@ -454,7 +410,6 @@ Error DirAccessPack::change_dir(String p_dir) { } String DirAccessPack::get_current_dir(bool p_include_drive) { - PackedData::PackedDir *pd = current; String p = current->name; @@ -467,35 +422,29 @@ String DirAccessPack::get_current_dir(bool p_include_drive) { } bool DirAccessPack::file_exists(String p_file) { - p_file = fix_path(p_file); return current->files.has(p_file); } bool DirAccessPack::dir_exists(String p_dir) { - p_dir = fix_path(p_dir); return current->subdirs.has(p_dir); } Error DirAccessPack::make_dir(String p_dir) { - return ERR_UNAVAILABLE; } Error DirAccessPack::rename(String p_from, String p_to) { - return ERR_UNAVAILABLE; } Error DirAccessPack::remove(String p_name) { - return ERR_UNAVAILABLE; } size_t DirAccessPack::get_space_left() { - return 0; } |