| Index: utils/archive/reader.c
|
| diff --git a/utils/archive/reader.c b/utils/archive/reader.c
|
| index be768b66ca689d80d64b3abbdfec7f966b4846f4..bd016c547ab12baa7c813d2497b2558833f44573 100644
|
| --- a/utils/archive/reader.c
|
| +++ b/utils/archive/reader.c
|
| @@ -2,14 +2,12 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| +#include "entry.h"
|
| #include "messaging.h"
|
| #include "reader.h"
|
|
|
| void archiveReadNew(Dart_Port p) {
|
| - struct archive* a = archive_read_new();
|
| - DART_INT64(result, (intptr_t) a)
|
| - postSuccess(p, &result);
|
| - return;
|
| + checkPointerResult(p, archive_read_new(), "archive input stream");
|
| }
|
|
|
| void archiveReadSupportFilterAll(Dart_Port p, struct archive* a) {
|
| @@ -145,170 +143,24 @@ void archiveReadOpenMemory(Dart_Port p, struct archive* a,
|
| checkResult(p, a, result);
|
| }
|
|
|
| -#define RAW_ARCHIVE_SIZE 32
|
| -
|
| void archiveReadNextHeader(Dart_Port p, struct archive* a) {
|
| // TODO(nweiz): At some point, we'll want to attach the actual archive pointer
|
| // to the struct we send to Dart so that it can later be modified, passed in
|
| // to other functions, etc. When we do so, we'll need to use archive_entry_new
|
| // to create it and we'll have to attach a finalizer to the Dart object to
|
| // ensure that it gets freed.
|
| - struct archive_entry* entry;
|
| - int result = archive_read_next_header(a, &entry);
|
| + struct archive_entry* entry = archive_entry_new();
|
| + if (checkPointerError(p, entry, "archive entry")) return;
|
| +
|
| + int result = archive_read_next_header2(a, entry);
|
| if (result == ARCHIVE_EOF) {
|
| postSuccess(p, NULL);
|
| - return;
|
| - }
|
| - if (checkError(p, a, result)) return;
|
| -
|
| - Dart_CObject* archive_entry_array[RAW_ARCHIVE_SIZE];
|
| -
|
| - // archive_entry_paths(3)
|
| - DART_STRING(hardlink, (char*) archive_entry_hardlink(entry))
|
| - archive_entry_array[0] = &hardlink;
|
| - DART_STRING(pathname, (char*) archive_entry_pathname(entry))
|
| - archive_entry_array[1] = &pathname;
|
| - DART_STRING(sourcepath, (char*) archive_entry_sourcepath(entry))
|
| - archive_entry_array[2] = &sourcepath;
|
| - DART_STRING(symlink, (char*) archive_entry_symlink(entry))
|
| - archive_entry_array[3] = &symlink;
|
| -
|
| - // archive_entry_perms(3)
|
| - DART_INT32(gid, archive_entry_gid(entry))
|
| - archive_entry_array[4] = &gid;
|
| - DART_INT32(uid, archive_entry_uid(entry))
|
| - archive_entry_array[5] = &uid;
|
| - DART_INT32(perm, archive_entry_perm(entry))
|
| - archive_entry_array[6] = &perm;
|
| - DART_STRING(strmode, (char*) archive_entry_strmode(entry))
|
| - archive_entry_array[7] = &strmode;
|
| - DART_STRING(gname, (char*) archive_entry_gname(entry))
|
| - archive_entry_array[8] = &gname;
|
| - DART_STRING(uname, (char*) archive_entry_uname(entry))
|
| - archive_entry_array[9] = &uname;
|
| -
|
| - unsigned long fflags_set;
|
| - unsigned long fflags_clear;
|
| - archive_entry_fflags(entry, &fflags_set, &fflags_clear);
|
| - DART_INT64(wrapped_fflags_set, fflags_set)
|
| - archive_entry_array[10] = &wrapped_fflags_set;
|
| - DART_INT64(wrapped_fflags_clear, fflags_clear)
|
| - archive_entry_array[11] = &wrapped_fflags_clear;
|
| -
|
| - DART_STRING(fflags_text, (char*) archive_entry_fflags_text(entry))
|
| - archive_entry_array[12] = &fflags_text;
|
| -
|
| - // archive_entry_stat(3)
|
| - DART_INT32(filetype, archive_entry_filetype(entry))
|
| - archive_entry_array[13] = &filetype;
|
| - DART_INT32(mode, archive_entry_mode(entry))
|
| - archive_entry_array[14] = &mode;
|
| -
|
| - Dart_CObject size;
|
| - if (archive_entry_size_is_set(entry)) {
|
| - size.type = kInt64;
|
| - size.value.as_int64 = archive_entry_size(entry);
|
| + archive_entry_free(entry);
|
| + } else if (checkError(p, a, result)) {
|
| + archive_entry_free(entry);
|
| } else {
|
| - size.type = kNull;
|
| + postArchiveEntryArray(p, entry);
|
| }
|
| - archive_entry_array[15] = &size;
|
| -
|
| - Dart_CObject dev;
|
| - if (archive_entry_dev_is_set(entry)) {
|
| - dev.type = kInt64;
|
| - dev.value.as_int64 = archive_entry_dev(entry);
|
| - } else {
|
| - dev.type = kNull;
|
| - }
|
| - archive_entry_array[16] = &dev;
|
| -
|
| - DART_INT64(devmajor, archive_entry_devmajor(entry))
|
| - archive_entry_array[17] = &devmajor;
|
| - DART_INT64(devminor, archive_entry_devminor(entry))
|
| - archive_entry_array[18] = &devminor;
|
| -
|
| - Dart_CObject ino;
|
| - if (archive_entry_ino_is_set(entry)) {
|
| - ino.type = kInt64;
|
| - ino.value.as_int64 = archive_entry_ino64(entry);
|
| - } else {
|
| - ino.type = kNull;
|
| - }
|
| - archive_entry_array[19] = &ino;
|
| -
|
| - DART_INT64(nlink, archive_entry_nlink(entry))
|
| - archive_entry_array[20] = &nlink;
|
| - DART_INT64(rdev, archive_entry_rdev(entry))
|
| - archive_entry_array[21] = &rdev;
|
| - DART_INT64(rdevmajor, archive_entry_rdevmajor(entry))
|
| - archive_entry_array[22] = &rdevmajor;
|
| - DART_INT64(rdevminor, archive_entry_rdevminor(entry))
|
| - archive_entry_array[23] = &rdevminor;
|
| -
|
| - // archive_entry_time(3)
|
| - Dart_CObject atime;
|
| - Dart_CObject atime_nsec;
|
| - if (archive_entry_atime_is_set(entry)) {
|
| - atime.type = kInt64;
|
| - atime.value.as_int64 = archive_entry_atime(entry);
|
| - atime_nsec.type = kInt64;
|
| - atime_nsec.value.as_int64 = archive_entry_atime_nsec(entry);
|
| - } else {
|
| - atime.type = kNull;
|
| - atime_nsec.type = kNull;
|
| - }
|
| - archive_entry_array[24] = &atime;
|
| - archive_entry_array[25] = &atime_nsec;
|
| -
|
| - Dart_CObject birthtime;
|
| - Dart_CObject birthtime_nsec;
|
| - if (archive_entry_birthtime_is_set(entry)) {
|
| - birthtime.type = kInt64;
|
| - birthtime.value.as_int64 = archive_entry_birthtime(entry);
|
| - birthtime_nsec.type = kInt64;
|
| - birthtime_nsec.value.as_int64 = archive_entry_birthtime_nsec(entry);
|
| - } else {
|
| - birthtime.type = kNull;
|
| - birthtime_nsec.type = kNull;
|
| - }
|
| - archive_entry_array[26] = &birthtime;
|
| - archive_entry_array[27] = &birthtime_nsec;
|
| -
|
| - Dart_CObject ctime;
|
| - Dart_CObject ctime_nsec;
|
| - if (archive_entry_ctime_is_set(entry)) {
|
| - ctime.type = kInt64;
|
| - ctime.value.as_int64 = archive_entry_ctime(entry);
|
| - ctime_nsec.type = kInt64;
|
| - ctime_nsec.value.as_int64 = archive_entry_ctime_nsec(entry);
|
| - } else {
|
| - ctime.type = kNull;
|
| - ctime_nsec.type = kNull;
|
| - }
|
| - archive_entry_array[28] = &ctime;
|
| - archive_entry_array[29] = &ctime_nsec;
|
| -
|
| - Dart_CObject mtime;
|
| - Dart_CObject mtime_nsec;
|
| - if (archive_entry_mtime_is_set(entry)) {
|
| - mtime.type = kInt64;
|
| - mtime.value.as_int64 = archive_entry_mtime(entry);
|
| - mtime_nsec.type = kInt64;
|
| - mtime_nsec.value.as_int64 = archive_entry_mtime_nsec(entry);
|
| - } else {
|
| - mtime.type = kNull;
|
| - mtime_nsec.type = kNull;
|
| - }
|
| - archive_entry_array[30] = &mtime;
|
| - archive_entry_array[31] = &mtime_nsec;
|
| - // If you add entries, don't forget to increase RAW_ARCHIVE_SIZE.
|
| -
|
| - Dart_CObject wrapped_archive_entry;
|
| - wrapped_archive_entry.type = kArray;
|
| - wrapped_archive_entry.value.as_array.values = archive_entry_array;
|
| - wrapped_archive_entry.value.as_array.length = RAW_ARCHIVE_SIZE;
|
| -
|
| - postSuccess(p, &wrapped_archive_entry);
|
| }
|
|
|
| void archiveReadDataBlock(Dart_Port p, struct archive* a) {
|
|
|