diff options
Diffstat (limited to 'core/io')
35 files changed, 549 insertions, 94 deletions
diff --git a/core/io/SCsub b/core/io/SCsub index 4efc902717..79b56cb716 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -5,3 +5,4 @@ Import('env') env.add_source_files(env.core_sources, "*.cpp") Export('env') + diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 44fa65e11d..51d48901cf 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -33,9 +33,9 @@ #include "zip_io.h" #include "thirdparty/misc/fastlz.h" -#include "thirdparty/zstd/zstd.h" #include <zlib.h> +#include <zstd.h> int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode) { @@ -78,9 +78,16 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, } break; case MODE_ZSTD: { - + ZSTD_CCtx *cctx = ZSTD_createCCtx(); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, zstd_level); + if (zstd_long_distance_matching) { + ZSTD_CCtx_setParameter(cctx, ZSTD_p_enableLongDistanceMatching, 1); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_windowLog, zstd_window_log_size); + } int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD); - return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level); + int ret = ZSTD_compressCCtx(cctx, p_dst, max_dst_size, p_src, p_src_size, zstd_level); + ZSTD_freeCCtx(cctx); + return ret; } break; } @@ -165,8 +172,11 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p return total; } break; case MODE_ZSTD: { - - return ZSTD_decompress(p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_DCtx *dctx = ZSTD_createDCtx(); + if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size); + int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_freeDCtx(dctx); + return ret; } break; } @@ -176,3 +186,5 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p int Compression::zlib_level = Z_DEFAULT_COMPRESSION; int Compression::gzip_level = Z_DEFAULT_COMPRESSION; int Compression::zstd_level = 3; +bool Compression::zstd_long_distance_matching = false; +int Compression::zstd_window_log_size = 27; diff --git a/core/io/compression.h b/core/io/compression.h index 22d8109d4f..5a9aedec31 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -38,6 +38,8 @@ public: static int zlib_level; static int gzip_level; static int zstd_level; + static bool zstd_long_distance_matching; + static int zstd_window_log_size; enum Mode { MODE_FASTLZ, diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index daa6b01d6e..2b60150832 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -75,7 +75,7 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V } else { if (!values.has(p_section)) { - values[p_section] = Map<String, Variant>(); + values[p_section] = OrderedHashMap<String, Variant>(); } values[p_section][p_key] = p_value; @@ -106,16 +106,16 @@ bool ConfigFile::has_section_key(const String &p_section, const String &p_key) c void ConfigFile::get_sections(List<String> *r_sections) const { - for (const Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) { - r_sections->push_back(E->key()); + for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::ConstElement E = values.front(); E; E = E.next()) { + r_sections->push_back(E.key()); } } void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const { ERR_FAIL_COND(!values.has(p_section)); - for (const Map<String, Variant>::Element *E = values[p_section].front(); E; E = E->next()) { - r_keys->push_back(E->key()); + for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) { + r_keys->push_back(E.key()); } } @@ -135,17 +135,17 @@ Error ConfigFile::save(const String &p_path) { return err; } - for (Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) { + for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::Element E = values.front(); E; E = E.next()) { if (E != values.front()) file->store_string("\n"); - file->store_string("[" + E->key() + "]\n\n"); + file->store_string("[" + E.key() + "]\n\n"); - for (Map<String, Variant>::Element *F = E->get().front(); F; F = F->next()) { + for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) { String vstr; - VariantWriter::write_to_string(F->get(), vstr); - file->store_string(F->key() + "=" + vstr + "\n"); + VariantWriter::write_to_string(F.get(), vstr); + file->store_string(F.key() + "=" + vstr + "\n"); } } diff --git a/core/io/config_file.h b/core/io/config_file.h index 8ed8a069e4..29bd369a24 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -30,13 +30,14 @@ #ifndef CONFIG_FILE_H #define CONFIG_FILE_H +#include "core/ordered_hash_map.h" #include "reference.h" class ConfigFile : public Reference { GDCLASS(ConfigFile, Reference); - Map<String, Map<String, Variant> > values; + OrderedHashMap<String, OrderedHashMap<String, Variant> > values; PoolStringArray _get_sections() const; PoolStringArray _get_section_keys(const String &p_section) const; diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index 859f2e3f8c..9ec03bf32b 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -76,7 +76,7 @@ void FileAccessBuffered::seek_end(int64_t p_position) { file.offset = file.size + p_position; }; -size_t FileAccessBuffered::get_pos() const { +size_t FileAccessBuffered::get_position() const { return file.offset; }; diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h index d3137058fb..70aaeb8ae0 100644 --- a/core/io/file_access_buffered.h +++ b/core/io/file_access_buffered.h @@ -72,7 +72,7 @@ protected: int get_cache_size(); public: - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual void seek(size_t p_position); ///< seek to a given position diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index 9e41834561..309fc16d09 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -76,6 +76,11 @@ protected: }; public: + void flush() { + + f.flush(); + }; + void store_8(uint8_t p_dest) { f.store_8(p_dest); diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 70430ca5d3..514e3c65f0 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -62,7 +62,7 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) { block_size = f->get_32(); read_total = f->get_32(); int bc = (read_total / block_size) + 1; - int acc_ofs = f->get_pos() + bc * 4; + int acc_ofs = f->get_position() + bc * 4; int max_bs = 0; for (int i = 0; i < bc; i++) { @@ -232,7 +232,7 @@ void FileAccessCompressed::seek_end(int64_t p_position) { seek(read_total + p_position); } } -size_t FileAccessCompressed::get_pos() const { +size_t FileAccessCompressed::get_position() const { ERR_FAIL_COND_V(!f, 0); if (writing) { @@ -338,6 +338,13 @@ Error FileAccessCompressed::get_error() const { return read_eof ? ERR_FILE_EOF : OK; } +void FileAccessCompressed::flush() { + ERR_FAIL_COND(!f); + ERR_FAIL_COND(!writing); + + // compressed files keep data in memory till close() +} + void FileAccessCompressed::store_8(uint8_t p_dest) { ERR_FAIL_COND(!f); diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index ba84c9767c..1d99e5bfd4 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -74,7 +74,7 @@ public: virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF @@ -84,6 +84,7 @@ public: virtual Error get_error() const; ///< get last error + virtual void flush(); virtual void store_8(uint8_t p_dest); ///< store a byte virtual bool file_exists(const String &p_name); ///< return true if a file exists diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 12503f3be4..e5da307153 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -62,16 +62,16 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8 writing = false; key = p_key; uint32_t magic = p_base->get_32(); - print_line("MAGIC: " + itos(magic)); ERR_FAIL_COND_V(magic != COMP_MAGIC, ERR_FILE_UNRECOGNIZED); + mode = Mode(p_base->get_32()); ERR_FAIL_INDEX_V(mode, MODE_MAX, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(mode == 0, ERR_FILE_CORRUPT); - print_line("MODE: " + itos(mode)); + unsigned char md5d[16]; p_base->get_buffer(md5d, 16); length = p_base->get_64(); - base = p_base->get_pos(); + base = p_base->get_position(); ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT); uint32_t ds = length; if (ds % 16) { @@ -199,7 +199,7 @@ void FileAccessEncrypted::seek_end(int64_t p_position) { seek(data.size() + p_position); } -size_t FileAccessEncrypted::get_pos() const { +size_t FileAccessEncrypted::get_position() const { return pos; } @@ -268,6 +268,12 @@ void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) { } } +void FileAccessEncrypted::flush() { + ERR_FAIL_COND(!writing); + + // encrypted files keep data in memory till close() +} + void FileAccessEncrypted::store_8(uint8_t p_dest) { ERR_FAIL_COND(!writing); diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 74d00a5a8f..d83fed3e0e 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -61,7 +61,7 @@ public: virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF @@ -71,6 +71,7 @@ public: virtual Error get_error() const; ///< get last error + virtual void flush(); virtual void store_8(uint8_t p_dest); ///< store a byte virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 5b186b7798..0a5815fca8 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -120,7 +120,7 @@ void FileAccessMemory::seek_end(int64_t p_position) { pos = length + p_position; } -size_t FileAccessMemory::get_pos() const { +size_t FileAccessMemory::get_position() const { ERR_FAIL_COND_V(!data, 0); return pos; @@ -170,6 +170,10 @@ Error FileAccessMemory::get_error() const { return pos >= length ? ERR_FILE_EOF : OK; } +void FileAccessMemory::flush() { + ERR_FAIL_COND(!data); +} + void FileAccessMemory::store_8(uint8_t p_byte) { ERR_FAIL_COND(!data); diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index 7feb16461b..23392719b4 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -51,7 +51,7 @@ public: virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position); ///< seek from the end of file - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF @@ -62,6 +62,7 @@ public: virtual Error get_error() const; ///< get last error + virtual void flush(); virtual void store_8(uint8_t p_byte); ///< store a byte virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 58ca2d4c58..a224abd9e7 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -350,7 +350,7 @@ void FileAccessNetwork::seek_end(int64_t p_position) { seek(total_size + p_position); } -size_t FileAccessNetwork::get_pos() const { +size_t FileAccessNetwork::get_position() const { ERR_FAIL_COND_V(!opened, 0); return pos; @@ -456,6 +456,10 @@ Error FileAccessNetwork::get_error() const { return pos == total_size ? ERR_FILE_EOF : OK; } +void FileAccessNetwork::flush() { + ERR_FAIL(); +} + void FileAccessNetwork::store_8(uint8_t p_dest) { ERR_FAIL(); diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index cd5046f007..20614476d0 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -145,7 +145,7 @@ public: virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF @@ -155,6 +155,7 @@ public: virtual Error get_error() const; ///< get last error + virtual void flush(); virtual void store_8(uint8_t p_dest); ///< store a byte virtual bool file_exists(const String &p_path); ///< return true if a file exists diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index e511085ac5..a7eb8ce6a9 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -140,17 +140,17 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) { if (magic != 0x43504447) { //maybe at he end.... self contained exe f->seek_end(); - f->seek(f->get_pos() - 4); + f->seek(f->get_position() - 4); magic = f->get_32(); if (magic != 0x43504447) { memdelete(f); return false; } - f->seek(f->get_pos() - 12); + f->seek(f->get_position() - 12); uint64_t ds = f->get_64(); - f->seek(f->get_pos() - ds - 8); + f->seek(f->get_position() - ds - 8); magic = f->get_32(); if (magic != 0x43504447) { @@ -236,7 +236,7 @@ void FileAccessPack::seek_end(int64_t p_position) { seek(pf.size + p_position); } -size_t FileAccessPack::get_pos() const { +size_t FileAccessPack::get_position() const { return pos; } @@ -293,6 +293,11 @@ Error FileAccessPack::get_error() const { return OK; } +void FileAccessPack::flush() { + + ERR_FAIL(); +} + void FileAccessPack::store_8(uint8_t p_dest) { ERR_FAIL(); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 758e9afa8e..12187a353a 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -148,7 +148,7 @@ public: virtual void seek(size_t p_position); virtual void seek_end(int64_t p_position = 0); - virtual size_t get_pos() const; + virtual size_t get_position() const; virtual size_t get_len() const; virtual bool eof_reached() const; @@ -161,6 +161,7 @@ public: virtual Error get_error() const; + virtual void flush(); virtual void store_8(uint8_t p_dest); virtual void store_buffer(const uint8_t *p_src, int p_length); diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 8c99ef2983..ec809011a9 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -65,7 +65,7 @@ static uLong godot_write(voidpf opaque, voidpf stream, const void *buf, uLong si static long godot_tell(voidpf opaque, voidpf stream) { FileAccess *f = (FileAccess *)opaque; - return f->get_pos(); + return f->get_position(); }; static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { @@ -76,7 +76,7 @@ static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR: - pos = f->get_pos() + offset; + pos = f->get_position() + offset; break; case ZLIB_FILEFUNC_SEEK_END: pos = f->get_len() + offset; @@ -301,7 +301,7 @@ void FileAccessZip::seek_end(int64_t p_position) { unzSeekCurrentFile(zfile, get_len() + p_position); }; -size_t FileAccessZip::get_pos() const { +size_t FileAccessZip::get_position() const { ERR_FAIL_COND_V(!zfile, 0); return unztell(zfile); @@ -353,6 +353,11 @@ Error FileAccessZip::get_error() const { return OK; }; +void FileAccessZip::flush() { + + ERR_FAIL(); +} + void FileAccessZip::store_8(uint8_t p_dest) { ERR_FAIL(); diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 2a8ec3fca5..0977b241ee 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -98,7 +98,7 @@ public: virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file - virtual size_t get_pos() const; ///< get position in the file + virtual size_t get_position() const; ///< get position in the file virtual size_t get_len() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF @@ -108,6 +108,7 @@ public: virtual Error get_error() const; ///< get last error + virtual void flush(); virtual void store_8(uint8_t p_dest); ///< store a byte virtual bool file_exists(const String &p_name); ///< return true if a file exists diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index dd56db9bf9..46d52384e5 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -189,16 +189,6 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str return OK; } -Error HTTPClient::send_body_text(const String &p_body) { - - return OK; -} - -Error HTTPClient::send_body_data(const PoolByteArray &p_body) { - - return OK; -} - bool HTTPClient::has_response() const { return response_headers.size() != 0; @@ -297,7 +287,7 @@ Error HTTPClient::poll() { case StreamPeerTCP::STATUS_CONNECTED: { if (ssl) { Ref<StreamPeerSSL> ssl = StreamPeerSSL::create(); - Error err = ssl->connect_to_stream(tcp_connection, true, ssl_verify_host ? conn_host : String()); + Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, ssl_verify_host ? conn_host : String()); if (err != OK) { close(); status = STATUS_SSL_HANDSHAKE_ERROR; @@ -629,8 +619,6 @@ void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection); ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw); ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String())); - ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text); - ClassDB::bind_method(D_METHOD("send_body_data", "body"), &HTTPClient::send_body_data); ClassDB::bind_method(D_METHOD("close"), &HTTPClient::close); ClassDB::bind_method(D_METHOD("has_response"), &HTTPClient::has_response); diff --git a/core/io/http_client.h b/core/io/http_client.h index 023370ae81..f8a3349e6e 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -169,8 +169,6 @@ public: Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body); Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String()); - Error send_body_text(const String &p_body); - Error send_body_data(const PoolByteArray &p_body); void close(); diff --git a/core/io/logger.cpp b/core/io/logger.cpp new file mode 100644 index 0000000000..ce2ce44b1d --- /dev/null +++ b/core/io/logger.cpp @@ -0,0 +1,266 @@ +/*************************************************************************/ +/* logger.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "logger.h" +#include "os/dir_access.h" +#include "os/os.h" +#include "print_string.h" + +// va_copy was defined in the C99, but not in C++ standards before C++11. +// When you compile C++ without --std=c++<XX> option, compilers still define +// va_copy, otherwise you have to use the internal version (__va_copy). +#if !defined(va_copy) +#if defined(__GNUC__) +#define va_copy(d, s) __va_copy(d, s) +#else +#define va_copy(d, s) ((d) = (s)) +#endif +#endif + +bool Logger::should_log(bool p_err) { + return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled); +} + +void Logger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { + if (!should_log(true)) { + return; + } + + const char *err_type = "**ERROR**"; + switch (p_type) { + case ERR_ERROR: err_type = "**ERROR**"; break; + case ERR_WARNING: err_type = "**WARNING**"; break; + case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break; + case ERR_SHADER: err_type = "**SHADER ERROR**"; break; + default: ERR_PRINT("Unknown error type"); break; + } + + const char *err_details; + if (p_rationale && *p_rationale) + err_details = p_rationale; + else + err_details = p_code; + + logf_error("%s: %s\n", err_type, err_details); + logf_error(" At: %s:%i:%s() - %s\n", p_file, p_line, p_function, p_code); +} + +void Logger::logf(const char *p_format, ...) { + if (!should_log(false)) { + return; + } + + va_list argp; + va_start(argp, p_format); + + logv(p_format, argp, false); + + va_end(argp); +} + +void Logger::logf_error(const char *p_format, ...) { + if (!should_log(true)) { + return; + } + + va_list argp; + va_start(argp, p_format); + + logv(p_format, argp, true); + + va_end(argp); +} + +Logger::~Logger() {} + +void RotatedFileLogger::close_file() { + if (file) { + memdelete(file); + file = NULL; + } +} + +void RotatedFileLogger::clear_old_backups() { + int max_backups = max_files - 1; // -1 for the current file + + String basename = base_path.get_file().get_basename(); + String extension = "." + base_path.get_extension(); + + DirAccess *da = DirAccess::open(base_path.get_base_dir()); + if (!da) { + return; + } + + da->list_dir_begin(); + String f = da->get_next(); + Set<String> backups; + while (f != String()) { + if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path.get_file()) { + backups.insert(f); + } + f = da->get_next(); + } + da->list_dir_end(); + + if (backups.size() > max_backups) { + // since backups are appended with timestamp and Set iterates them in sorted order, + // first backups are the oldest + int to_delete = backups.size() - max_backups; + for (Set<String>::Element *E = backups.front(); E && to_delete > 0; E = E->next(), --to_delete) { + da->remove(E->get()); + } + } + + memdelete(da); +} + +void RotatedFileLogger::rotate_file() { + close_file(); + + if (FileAccess::exists(base_path)) { + if (max_files > 1) { + char timestamp[21]; + OS::Date date = OS::get_singleton()->get_date(); + OS::Time time = OS::get_singleton()->get_time(); + sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec); + + String backup_name = base_path.get_basename() + timestamp + "." + base_path.get_extension(); + + DirAccess *da = DirAccess::open(base_path.get_base_dir()); + if (da) { + da->copy(base_path, backup_name); + memdelete(da); + } + clear_old_backups(); + } + } else { + DirAccess *da = DirAccess::create(DirAccess::ACCESS_USERDATA); + if (da) { + da->make_dir_recursive(base_path.get_base_dir()); + memdelete(da); + } + } + + file = FileAccess::open(base_path, FileAccess::WRITE); +} + +RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) { + file = NULL; + base_path = p_base_path.simplify_path(); + max_files = p_max_files > 0 ? p_max_files : 1; + + rotate_file(); +} + +void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) { + if (!should_log(p_err)) { + return; + } + + if (file) { + const int static_buf_size = 512; + char static_buf[static_buf_size]; + char *buf = static_buf; + va_list list_copy; + va_copy(list_copy, p_list); + int len = vsnprintf(buf, static_buf_size, p_format, p_list); + if (len >= static_buf_size) { + buf = (char *)Memory::alloc_static(len + 1); + vsnprintf(buf, len + 1, p_format, list_copy); + } + va_end(list_copy); + file->store_buffer((uint8_t *)buf, len); + if (len >= static_buf_size) { + Memory::free_static(buf); + } +#ifdef DEBUG_ENABLED + const bool need_flush = true; +#else + bool need_flush = p_err; +#endif + if (need_flush) { + file->flush(); + } + } +} + +RotatedFileLogger::~RotatedFileLogger() { + close_file(); +} + +void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) { + if (!should_log(p_err)) { + return; + } + + if (p_err) { + vfprintf(stderr, p_format, p_list); + } else { + vprintf(p_format, p_list); +#ifdef DEBUG_ENABLED + fflush(stdout); +#endif + } +} + +StdLogger::~StdLogger() {} + +CompositeLogger::CompositeLogger(Vector<Logger *> p_loggers) { + loggers = p_loggers; +} + +void CompositeLogger::logv(const char *p_format, va_list p_list, bool p_err) { + if (!should_log(p_err)) { + return; + } + + for (int i = 0; i < loggers.size(); ++i) { + va_list list_copy; + va_copy(list_copy, p_list); + loggers[i]->logv(p_format, list_copy, p_err); + va_end(list_copy); + } +} + +void CompositeLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { + if (!should_log(true)) { + return; + } + + for (int i = 0; i < loggers.size(); ++i) { + loggers[i]->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); + } +} + +CompositeLogger::~CompositeLogger() { + for (int i = 0; i < loggers.size(); ++i) { + memdelete(loggers[i]); + } +} diff --git a/core/io/logger.h b/core/io/logger.h new file mode 100644 index 0000000000..cf0cc7699f --- /dev/null +++ b/core/io/logger.h @@ -0,0 +1,107 @@ +/*************************************************************************/ +/* logger.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef LOGGER_H +#define LOGGER_H + +#include "os/file_access.h" +#include "ustring.h" +#include "vector.h" +#include <stdarg.h> + +class Logger { +protected: + bool should_log(bool p_err); + +public: + enum ErrorType { + ERR_ERROR, + ERR_WARNING, + ERR_SCRIPT, + ERR_SHADER + }; + + virtual void logv(const char *p_format, va_list p_list, bool p_err) = 0; + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); + + void logf(const char *p_format, ...); + void logf_error(const char *p_format, ...); + + virtual ~Logger(); +}; + +/** + * Writes messages to stdout/stderr. + */ +class StdLogger : public Logger { + +public: + virtual void logv(const char *p_format, va_list p_list, bool p_err); + virtual ~StdLogger(); +}; + +/** + * Writes messages to the specified file. If the file already exists, creates a copy (backup) + * of it with timestamp appended to the file name. Maximum number of backups is configurable. + * When maximum is reached, the oldest backups are erased. With the maximum being equal to 1, + * it acts as a simple file logger. + */ +class RotatedFileLogger : public Logger { + String base_path; + int max_files; + + FileAccess *file; + + void rotate_file_without_closing(); + void close_file(); + void clear_old_backups(); + void rotate_file(); + +public: + RotatedFileLogger(const String &p_base_path, int p_max_files = 10); + + virtual void logv(const char *p_format, va_list p_list, bool p_err); + + virtual ~RotatedFileLogger(); +}; + +class CompositeLogger : public Logger { + Vector<Logger *> loggers; + +public: + CompositeLogger(Vector<Logger *> p_loggers); + + virtual void logv(const char *p_format, va_list p_list, bool p_err); + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); + + virtual ~CompositeLogger(); +}; + +#endif
\ No newline at end of file diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 0834d6c321..d388a622de 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1140,8 +1140,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo if (buf) { encode_uint32(0, buf); buf += 4; - r_len += 4; } + r_len += 4; + } else { _encode_string(obj->get_class(), buf, r_len); diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index f1f5b6f538..23e86580d1 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -119,7 +119,7 @@ Error PCKPacker::flush(bool p_verbose) { for (int i = 0; i < files.size(); i++) { file->store_pascal_string(files[i].path); - files[i].offset_offset = file->get_pos(); + files[i].offset_offset = file->get_position(); file->store_64(0); // offset file->store_64(files[i].size); // size @@ -130,10 +130,10 @@ Error PCKPacker::flush(bool p_verbose) { file->store_32(0); }; - uint64_t ofs = file->get_pos(); + uint64_t ofs = file->get_position(); ofs = _align(ofs, alignment); - _pad(file, ofs - file->get_pos()); + _pad(file, ofs - file->get_position()); const uint32_t buf_max = 65536; uint8_t *buf = memnew_arr(uint8_t, buf_max); @@ -150,7 +150,7 @@ Error PCKPacker::flush(bool p_verbose) { to_write -= read; }; - uint64_t pos = file->get_pos(); + uint64_t pos = file->get_position(); file->seek(files[i].offset_offset); // go back to store the file's offset file->store_64(ofs); file->seek(pos); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 16ec6cd3c5..03c3c5f615 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -282,7 +282,6 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { property = _get_string(); NodePath np = NodePath(names, subnames, absolute, property); - //print_line("got path: "+String(np)); r_v = np; @@ -640,7 +639,6 @@ Error ResourceInteractiveLoaderBinary::poll() { String path = external_resources[s].path; - print_line("load external res: " + path); if (remaps.has(path)) { path = remaps[path]; } @@ -706,8 +704,6 @@ Error ResourceInteractiveLoaderBinary::poll() { String t = get_unicode_string(); - // print_line("loading resource of type "+t+" path is "+path); - Object *obj = ClassDB::instance(t); if (!obj) { error = ERR_FILE_CORRUPT; @@ -907,20 +903,6 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) { external_resources.push_back(er); } - //see if the exporter has different set of external resources for more efficient loading - /* - String preload_depts = "deps/"+res_path.md5_text(); - if (Globals::get_singleton()->has(preload_depts)) { - external_resources.clear(); - //ignore external resources and use these - NodePath depts=Globals::get_singleton()->get(preload_depts); - external_resources.resize(depts.get_name_count()); - for(int i=0;i<depts.get_name_count();i++) { - external_resources[i].path=depts.get_name(i); - } - print_line(res_path+" - EXTERNAL RESOURCES: "+itos(external_resources.size())); - }*/ - print_bl("ext resources: " + itos(ext_resources_size)); uint32_t int_resources_size = f->get_32(); @@ -1179,7 +1161,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons save_ustring(fw, get_ustring(f)); //type - size_t md_ofs = f->get_pos(); + size_t md_ofs = f->get_position(); size_t importmd_ofs = f->get_64(); fw->store_64(0); //metadata offset @@ -1227,7 +1209,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons save_ustring(fw, path); } - int64_t size_diff = (int64_t)fw->get_pos() - (int64_t)f->get_pos(); + int64_t size_diff = (int64_t)fw->get_position() - (int64_t)f->get_position(); //internal resources uint32_t int_resources_size = f->get_32(); @@ -1880,7 +1862,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } else { save_unicode_string(r->get_path()); //actual external } - ofs_pos.push_back(f->get_pos()); + ofs_pos.push_back(f->get_position()); f->store_64(0); //offset in 64 bits } @@ -1891,7 +1873,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p ResourceData &rd = E->get(); - ofs_table.push_back(f->get_pos()); + ofs_table.push_back(f->get_position()); save_unicode_string(rd.type); f->store_32(rd.properties.size()); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index be486a86a3..401d704222 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -77,7 +77,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy if (assign != String()) { if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) { String feature = assign.get_slicec('.', 1); - if (OS::get_singleton()->check_feature_support(feature)) { + if (OS::get_singleton()->has_feature(feature)) { r_path_and_type.path = value; path_found = true; //first match must have priority } @@ -87,6 +87,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy path_found = true; //first match must have priority } else if (assign == "type") { r_path_and_type.type = value; + } else if (assign == "importer") { + r_path_and_type.importer = value; } else if (assign == "valid") { if (r_valid) { *r_valid = value; @@ -184,6 +186,29 @@ bool ResourceFormatImporter::can_be_imported(const String &p_path) const { return ResourceFormatLoader::recognize_path(p_path); } +int ResourceFormatImporter::get_import_order(const String &p_path) const { + + Ref<ResourceImporter> importer; + + if (FileAccess::exists(p_path + ".import")) { + + PathAndType pat; + Error err = _get_path_and_type(p_path, pat); + + if (err == OK) { + importer = get_importer_by_name(pat.importer); + } + } else { + + importer = get_importer_by_extension(p_path.get_extension().to_lower()); + } + + if (importer.is_valid()) + return importer->get_import_order(); + + return 0; +} + bool ResourceFormatImporter::handles_type(const String &p_type) const { for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { @@ -291,7 +316,7 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String> return ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types); } -Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) { +Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const { for (Set<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { if (E->get()->get_importer_name() == p_name) { @@ -315,7 +340,7 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi } } -Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String &p_extension) { +Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String &p_extension) const { Ref<ResourceImporter> importer; float priority = 0; diff --git a/core/io/resource_import.h b/core/io/resource_import.h index b10255fbab..28489b5d34 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -38,6 +38,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { struct PathAndType { String path; String type; + String importer; }; Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; @@ -58,14 +59,15 @@ public: virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual bool can_be_imported(const String &p_path) const; + virtual int get_import_order(const String &p_path) const; String get_internal_resource_path(const String &p_path) const; void get_internal_resource_path_list(const String &p_path, List<String> *r_paths); void add_importer(const Ref<ResourceImporter> &p_importer) { importers.insert(p_importer); } void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); } - Ref<ResourceImporter> get_importer_by_name(const String &p_name); - Ref<ResourceImporter> get_importer_by_extension(const String &p_extension); + Ref<ResourceImporter> get_importer_by_name(const String &p_name) const; + Ref<ResourceImporter> get_importer_by_extension(const String &p_extension) const; void get_importers_for_extension(const String &p_extension, List<Ref<ResourceImporter> > *r_importers); String get_import_base_path(const String &p_for_file) const; @@ -82,6 +84,7 @@ public: virtual String get_save_extension() const = 0; virtual String get_resource_type() const = 0; virtual float get_priority() const { return 1.0; } + virtual int get_import_order() const { return 0; } struct ImportOption { PropertyInfo option; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 4f266df43e..ed0d491679 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -308,6 +308,31 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l } } +int ResourceLoader::get_import_order(const String &p_path) { + + String path = _path_remap(p_path); + + String local_path; + if (path.is_rel_path()) + local_path = "res://" + path; + else + local_path = ProjectSettings::get_singleton()->localize_path(path); + + for (int i = 0; i < loader_count; i++) { + + if (!loader[i]->recognize_path(local_path)) + continue; + /* + if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + continue; + */ + + return loader[i]->get_import_order(p_path); + } + + return 0; +} + bool ResourceLoader::is_import_valid(const String &p_path) { String path = _path_remap(p_path); @@ -467,7 +492,7 @@ void ResourceLoader::reload_translation_remaps() { void ResourceLoader::load_translation_remaps() { - if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) return; Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index a71a568569..5deffbca1a 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -67,6 +67,7 @@ public: virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map) { return OK; } virtual bool is_import_valid(const String &p_path) const { return true; } + virtual int get_import_order(const String &p_path) const { return 0; } virtual ~ResourceFormatLoader() {} }; @@ -110,6 +111,7 @@ public: static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); static bool is_import_valid(const String &p_path); + static int get_import_order(const String &p_path); static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load = p_timestamp; } diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index f4f81f0807..2583eb369d 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -405,9 +405,9 @@ void StreamPeer::_bind_methods() { void StreamPeerBuffer::_bind_methods() { - ClassDB::bind_method(D_METHOD("seek", "pos"), &StreamPeerBuffer::seek); + ClassDB::bind_method(D_METHOD("seek", "position"), &StreamPeerBuffer::seek); ClassDB::bind_method(D_METHOD("get_size"), &StreamPeerBuffer::get_size); - ClassDB::bind_method(D_METHOD("get_pos"), &StreamPeerBuffer::get_pos); + ClassDB::bind_method(D_METHOD("get_position"), &StreamPeerBuffer::get_position); ClassDB::bind_method(D_METHOD("resize", "size"), &StreamPeerBuffer::resize); ClassDB::bind_method(D_METHOD("set_data_array", "data"), &StreamPeerBuffer::set_data_array); ClassDB::bind_method(D_METHOD("get_data_array"), &StreamPeerBuffer::get_data_array); @@ -484,7 +484,7 @@ int StreamPeerBuffer::get_size() const { return data.size(); } -int StreamPeerBuffer::get_pos() const { +int StreamPeerBuffer::get_position() const { return pointer; } diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index 1ee997c123..b120d18501 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -111,7 +111,7 @@ public: void seek(int p_pos); int get_size() const; - int get_pos() const; + int get_position() const; void resize(int p_size); void set_data_array(const PoolVector<uint8_t> &p_data); diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 3a4be7cd13..8ae68183d7 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -369,7 +369,7 @@ void XMLParser::_bind_methods() { ClassDB::bind_method(D_METHOD("is_empty"), &XMLParser::is_empty); ClassDB::bind_method(D_METHOD("get_current_line"), &XMLParser::get_current_line); ClassDB::bind_method(D_METHOD("skip_section"), &XMLParser::skip_section); - ClassDB::bind_method(D_METHOD("seek", "pos"), &XMLParser::seek); + ClassDB::bind_method(D_METHOD("seek", "position"), &XMLParser::seek); ClassDB::bind_method(D_METHOD("open", "file"), &XMLParser::open); ClassDB::bind_method(D_METHOD("open_buffer", "buffer"), &XMLParser::open_buffer); diff --git a/core/io/zip_io.h b/core/io/zip_io.h index 8cf971ee08..ce3c919b77 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -72,7 +72,7 @@ static uLong zipio_write(voidpf opaque, voidpf stream, const void *buf, uLong si static long zipio_tell(voidpf opaque, voidpf stream) { FileAccess *f = *(FileAccess **)opaque; - return f->get_pos(); + return f->get_position(); }; static long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { @@ -83,7 +83,7 @@ static long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR: - pos = f->get_pos() + offset; + pos = f->get_position() + offset; break; case ZLIB_FILEFUNC_SEEK_END: pos = f->get_len() + offset; |