diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2014-03-30 16:34:19 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2014-03-30 16:34:19 +0000 |
| commit | 93cffb85dbe5e7e522e061fa21e00df9c8270fbc (patch) | |
| tree | d66772c0f391435208fc3f8f874a2d440a452831 | |
| parent | Fix checking for unordered containers on incomplete C++11 implementations (diff) | |
| download | inkscape-93cffb85dbe5e7e522e061fa21e00df9c8270fbc.tar.gz inkscape-93cffb85dbe5e7e522e061fa21e00df9c8270fbc.zip | |
Migrate inkjar to cstdio functions to fix build issues on Free BSD (Thanks Markus Engel); see bug #1232474
(bzr r13233)
| -rw-r--r-- | src/io/inkjar.cpp | 18 | ||||
| -rw-r--r-- | src/io/inkjar.h | 6 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp index 4af140737..b9335c556 100644 --- a/src/io/inkjar.cpp +++ b/src/io/inkjar.cpp @@ -68,7 +68,7 @@ JarFile::JarFile(gchar const*new_filename) { _filename = g_strdup(new_filename); _last_filename = NULL; - fd = -1; + fd = NULL; } //fixme: the following should probably just return a const gchar* and not @@ -104,7 +104,7 @@ bool JarFile::init_inflation() bool JarFile::open() { - if ((fd = ::open(_filename, O_RDONLY)) < 0) { + if ((fd = fopen(_filename, O_RDONLY)) < 0) { fprintf(stderr, "open failed.\n"); return false; } @@ -116,7 +116,7 @@ bool JarFile::open() bool JarFile::close() { - if (fd >= 0 && !::close(fd)) { + if (fd >= 0 && !fclose(fd)) { inflateEnd(&_zs); return true; } @@ -257,7 +257,7 @@ GByteArray *JarFile::get_next_file_contents() if (method == 8 || flags & 0x0008) { unsigned int file_length = 0;//uncompressed file length - lseek(fd, eflen, SEEK_CUR); + fseek(fd, eflen, SEEK_CUR); guint8 *file_data = get_compressed_file(compressed_size, file_length, crc, flags); if (file_data == NULL) { @@ -275,7 +275,7 @@ GByteArray *JarFile::get_next_file_contents() } g_byte_array_append(gba, file_data, compressed_size); } else { - lseek(fd, compressed_size+eflen, SEEK_CUR); + fseek(fd, compressed_size+eflen, SEEK_CUR); g_byte_array_free(gba, FALSE); return NULL; } @@ -314,7 +314,7 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, std::printf("%u bytes written\n", out_a); #endif } - lseek(fd, eflen, SEEK_CUR); + fseek(fd, eflen, SEEK_CUR); g_free(bytes); if (!check_crc(crc, crc2, flags)) { @@ -329,7 +329,7 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, int JarFile::read(guint8 *buf, int count) { int nbytes; - if ((nbytes = ::read(fd, buf, count)) != count) { + if ((nbytes = fread(buf, 1, count, fd)) != count) { fprintf(stderr, "read error\n"); exit(1); return 0; @@ -358,8 +358,8 @@ guint8 *JarFile::get_compressed_file(guint32 compressed_size, if (!_zs.avail_in) { - if ((nbytes = ::read(fd, in_buffer, - (leftover_in < RDSZ ? leftover_in : RDSZ))) + if ((nbytes = fread(in_buffer, 1, + (leftover_in < RDSZ ? leftover_in : RDSZ), fd)) < 0) { fprintf(stderr, "jarfile read error"); } diff --git a/src/io/inkjar.h b/src/io/inkjar.h index ea4b0ee32..ee6e33526 100644 --- a/src/io/inkjar.h +++ b/src/io/inkjar.h @@ -27,6 +27,7 @@ #endif #include <glib.h> +#include <cstdio> namespace Inkjar { @@ -87,11 +88,10 @@ typedef uint32_t ub4; * * All memory allocations are done with g_malloc. */ - class JarFile { public: - JarFile() : fd(-1), _filename(NULL), _last_filename(NULL) {} + JarFile() : fd(NULL), _filename(NULL), _last_filename(NULL) {} virtual ~JarFile(); JarFile(gchar const *new_filename); @@ -106,7 +106,7 @@ public: private: - int fd; + FILE *fd; // File descriptor gchar *_filename; z_stream _zs; gchar *_last_filename; |
