summaryrefslogtreecommitdiff
path: root/core/io/file_access_pack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/file_access_pack.cpp')
-rw-r--r--core/io/file_access_pack.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index bb65a1afbc..00c4e76efe 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -54,12 +54,14 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
pf.pack = pkg_path;
pf.offset = ofs;
pf.size = size;
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
pf.md5[i] = p_md5[i];
+ }
pf.src = p_src;
- if (!exists || p_replace_files)
+ if (!exists || p_replace_files) {
files[pmd5] = pf;
+ }
if (!exists) {
//search for dir
@@ -106,8 +108,9 @@ PackedData::PackedData() {
}
void PackedData::_free_packed_dirs(PackedDir *p_dir) {
- for (Map<String, PackedDir *>::Element *E = p_dir->subdirs.front(); E; E = E->next())
+ for (Map<String, PackedDir *>::Element *E = p_dir->subdirs.front(); E; E = E->next()) {
_free_packed_dirs(E->get());
+ }
memdelete(p_dir);
}
@@ -122,8 +125,9 @@ 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)
+ if (!f) {
return false;
+ }
uint32_t magic = f->get_32();
@@ -252,8 +256,9 @@ uint8_t FileAccessPack::get_8() const {
}
int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
- if (eof)
+ if (eof) {
return 0;
+ }
uint64_t to_read = p_length;
if (to_read + pos > pf.size) {
@@ -263,8 +268,9 @@ int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
pos += p_length;
- if (to_read <= 0)
+ if (to_read <= 0) {
return 0;
+ }
f->get_buffer(p_dst, to_read);
return to_read;
@@ -276,8 +282,9 @@ void FileAccessPack::set_endian_swap(bool p_swap) {
}
Error FileAccessPack::get_error() const {
- if (eof)
+ if (eof) {
return ERR_FILE_EOF;
+ }
return OK;
}
@@ -308,8 +315,9 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
}
FileAccessPack::~FileAccessPack() {
- if (f)
+ if (f) {
memdelete(f);
+ }
}
//////////////////////////////////////////////////////////////////////////////////
@@ -378,8 +386,9 @@ Error DirAccessPack::change_dir(String p_dir) {
nd = nd.simplify_path();
- if (nd == "")
+ if (nd == "") {
nd = ".";
+ }
if (nd.begins_with("/")) {
nd = nd.replace_first("/", "");
@@ -390,10 +399,11 @@ Error DirAccessPack::change_dir(String p_dir) {
PackedData::PackedDir *pd;
- if (absolute)
+ if (absolute) {
pd = PackedData::get_singleton()->root;
- else
+ } else {
pd = current;
+ }
for (int i = 0; i < paths.size(); i++) {
String p = paths[i];