Permalink
Browse files

zip, break: deprecated ZipInfo object.

  • Loading branch information...
xicilion committed Oct 31, 2017
1 parent 590b76a commit c445485c984de61669f539c975ad71bccb4f2d49
View
@@ -288,7 +288,6 @@
<ClInclude Include="include\ifs\XmlProcessingInstruction.h" />
<ClInclude Include="include\ifs\XmlText.h" />
<ClInclude Include="include\ifs\ZipFile.h" />
<ClInclude Include="include\ifs\ZipInfo.h" />
<ClInclude Include="include\ifs\ZmqSocket.h" />
<ClInclude Include="include\ifs\assert.h" />
<ClInclude Include="include\ifs\base32.h" />
@@ -702,9 +702,6 @@
<ClInclude Include="include\ifs\ZipFile.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
<ClInclude Include="include\ifs\ZipInfo.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
<ClInclude Include="include\ifs\ZmqSocket.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
View
@@ -288,7 +288,6 @@
<ClInclude Include="include\ifs\XmlProcessingInstruction.h" />
<ClInclude Include="include\ifs\XmlText.h" />
<ClInclude Include="include\ifs\ZipFile.h" />
<ClInclude Include="include\ifs\ZipInfo.h" />
<ClInclude Include="include\ifs\ZmqSocket.h" />
<ClInclude Include="include\ifs\assert.h" />
<ClInclude Include="include\ifs\base32.h" />
@@ -702,9 +702,6 @@
<ClInclude Include="include\ifs\ZipFile.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
<ClInclude Include="include\ifs\ZipInfo.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
<ClInclude Include="include\ifs\ZmqSocket.h">
<Filter>Header Files\ifs</Filter>
</ClInclude>
View
@@ -6,7 +6,6 @@
*/
#include "ifs/ZipFile.h"
#include "ifs/ZipInfo.h"
#include "ifs/SeekableStream.h"
#include "unzip/include/unzip.h"
#include "unzip/include/zip.h"
@@ -18,19 +17,87 @@ namespace fibjs {
class ZipFile : public ZipFile_base {
public:
class Info : public ZipInfo_base {
class Info : public NObject {
public:
Info(exlib::string name, unz_file_info64& info);
Info(exlib::string name, unz_file_info64& info)
{
m_name = name;
m_date.fromDosTime(info.dosDate);
if (info.compression_method == 0)
m_compress_type = "Stored";
else if (info.compression_method == Z_DEFLATED)
m_compress_type = "Deflate";
else if (info.compression_method == Z_BZIP2ED)
m_compress_type = "BZip2";
else
m_compress_type = "Unknown";
m_file_size = info.uncompressed_size;
m_compress_size = info.compressed_size;
m_password = info.flag & 1;
}
public:
// ZipInfo_base
virtual result_t get_filename(exlib::string& retVal);
virtual result_t get_date(date_t& retVal);
virtual result_t get_compress_type(exlib::string& retVal);
virtual result_t get_compress_size(int64_t& retVal);
virtual result_t get_file_size(int64_t& retVal);
virtual result_t get_password(bool& retVal);
virtual result_t get_data(obj_ptr<Buffer_base>& retVal);
result_t get_filename(exlib::string& retVal)
{
retVal = m_name;
return 0;
}
result_t get_date(date_t& retVal)
{
retVal = m_date;
return 0;
}
result_t get_compress_type(exlib::string& retVal)
{
retVal = m_compress_type;
return 0;
}
result_t get_compress_size(int64_t& retVal)
{
retVal = m_compress_size;
return 0;
}
result_t get_file_size(int64_t& retVal)
{
retVal = m_file_size;
return 0;
}
result_t get_password(bool& retVal)
{
retVal = m_password;
return 0;
}
result_t get_data(obj_ptr<Buffer_base>& retVal)
{
if (!m_data)
return CALL_RETURN_NULL;
retVal = m_data;
return 0;
}
public:
// object_base
virtual result_t valueOf(v8::Local<v8::Value>& retVal)
{
add("filename", m_name);
add("date", m_date);
add("compress_type", m_compress_type);
add("compress_size", m_compress_size);
add("file_size", m_file_size);
add("password", m_password);
add("data", m_data);
return NObject::valueOf(retVal);
}
public:
exlib::string m_name;
@@ -49,7 +116,7 @@ class ZipFile : public ZipFile_base {
// ZipFile_base
virtual result_t namelist(obj_ptr<NArray>& retVal, AsyncEvent* ac);
virtual result_t infolist(obj_ptr<NArray>& retVal, AsyncEvent* ac);
virtual result_t getinfo(exlib::string member, obj_ptr<ZipInfo_base>& retVal, AsyncEvent* ac);
virtual result_t getinfo(exlib::string member, obj_ptr<NObject>& retVal, AsyncEvent* ac);
virtual result_t read(exlib::string member, exlib::string password, obj_ptr<Buffer_base>& retVal, AsyncEvent* ac);
virtual result_t readAll(exlib::string password, obj_ptr<NArray>& retVal, AsyncEvent* ac);
virtual result_t extract(exlib::string member, exlib::string path, exlib::string password, AsyncEvent* ac);
@@ -16,7 +16,6 @@
namespace fibjs {
class ZipInfo_base;
class Buffer_base;
class SeekableStream_base;
@@ -27,7 +26,7 @@ class ZipFile_base : public object_base {
// ZipFile_base
virtual result_t namelist(obj_ptr<NArray>& retVal, AsyncEvent* ac) = 0;
virtual result_t infolist(obj_ptr<NArray>& retVal, AsyncEvent* ac) = 0;
virtual result_t getinfo(exlib::string member, obj_ptr<ZipInfo_base>& retVal, AsyncEvent* ac) = 0;
virtual result_t getinfo(exlib::string member, obj_ptr<NObject>& retVal, AsyncEvent* ac) = 0;
virtual result_t read(exlib::string member, exlib::string password, obj_ptr<Buffer_base>& retVal, AsyncEvent* ac) = 0;
virtual result_t readAll(exlib::string password, obj_ptr<NArray>& retVal, AsyncEvent* ac) = 0;
virtual result_t extract(exlib::string member, exlib::string path, exlib::string password, AsyncEvent* ac) = 0;
@@ -63,7 +62,7 @@ class ZipFile_base : public object_base {
public:
ASYNC_MEMBERVALUE1(ZipFile_base, namelist, obj_ptr<NArray>);
ASYNC_MEMBERVALUE1(ZipFile_base, infolist, obj_ptr<NArray>);
ASYNC_MEMBERVALUE2(ZipFile_base, getinfo, exlib::string, obj_ptr<ZipInfo_base>);
ASYNC_MEMBERVALUE2(ZipFile_base, getinfo, exlib::string, obj_ptr<NObject>);
ASYNC_MEMBERVALUE3(ZipFile_base, read, exlib::string, exlib::string, obj_ptr<Buffer_base>);
ASYNC_MEMBERVALUE2(ZipFile_base, readAll, exlib::string, obj_ptr<NArray>);
ASYNC_MEMBER3(ZipFile_base, extract, exlib::string, exlib::string, exlib::string);
@@ -76,7 +75,6 @@ class ZipFile_base : public object_base {
};
}
#include "ZipInfo.h"
#include "Buffer.h"
#include "SeekableStream.h"
@@ -154,7 +152,7 @@ inline void ZipFile_base::s_infolist(const v8::FunctionCallbackInfo<v8::Value>&
inline void ZipFile_base::s_getinfo(const v8::FunctionCallbackInfo<v8::Value>& args)
{
obj_ptr<ZipInfo_base> vr;
obj_ptr<NObject> vr;
METHOD_NAME("ZipFile.getinfo");
METHOD_INSTANCE(ZipFile_base);
View

This file was deleted.

Oops, something went wrong.
View
@@ -13,6 +13,7 @@
#include "File.h"
#include "BufferedStream.h"
#include "MemoryStream.h"
#include "ZipFile.h"
#ifndef _WIN32
#include <dirent.h>
@@ -145,7 +146,7 @@ result_t fs_base::openFile(exlib::string fname, exlib::string flags,
int32_t len, i;
bool bFound = false;
obj_ptr<ZipInfo_base> zi;
obj_ptr<ZipFile::Info> zi;
_node->m_list->get_length(len);
@@ -154,7 +155,7 @@ result_t fs_base::openFile(exlib::string fname, exlib::string flags,
exlib::string s;
_node->m_list->_indexed_getter(i, v);
zi = ZipInfo_base::getInstance(v.object());
zi = (ZipFile::Info*)v.object();
zi->get_filename(s);
Oops, something went wrong.

0 comments on commit c445485

Please sign in to comment.