Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
c0ec8d9f
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c0ec8d9f
编写于
6月 01, 2018
作者:
S
Stanislav Baranov
提交者:
GitHub
6月 01, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore archive support removed in #5305. Codepush bundles use zip. (#5441)
上级
0470f1c8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
184 addition
and
0 deletion
+184
-0
assets/BUILD.gn
assets/BUILD.gn
+7
-0
assets/zip_asset_store.cc
assets/zip_asset_store.cc
+124
-0
assets/zip_asset_store.h
assets/zip_asset_store.h
+51
-0
travis/licenses_golden/licenses_flutter
travis/licenses_golden/licenses_flutter
+2
-0
未找到文件。
assets/BUILD.gn
浏览文件 @
c0ec8d9f
...
...
@@ -9,6 +9,8 @@ source_set("assets") {
"asset_resolver.h",
"directory_asset_bundle.cc",
"directory_asset_bundle.h",
"zip_asset_store.cc",
"zip_asset_store.h",
]
deps = [
...
...
@@ -16,6 +18,11 @@ source_set("assets") {
"$flutter_root/fml",
"$flutter_root/glue",
"//garnet/public/lib/fxl",
"//garnet/public/lib/zip",
]
public_deps = [
"//third_party/zlib:minizip",
]
public_configs = [ "$flutter_root:config" ]
...
...
assets/zip_asset_store.cc
0 → 100644
浏览文件 @
c0ec8d9f
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/assets/zip_asset_store.h"
#include "lib/fxl/build_config.h"
#include <fcntl.h>
#if !defined(OS_WIN)
#include <unistd.h>
#endif
#include <string>
#include <utility>
#include "flutter/glue/trace_event.h"
namespace
blink
{
ZipAssetStore
::
ZipAssetStore
(
std
::
string
file_path
)
:
file_path_
(
std
::
move
(
file_path
))
{
BuildStatCache
();
}
ZipAssetStore
::~
ZipAssetStore
()
=
default
;
zip
::
UniqueUnzipper
ZipAssetStore
::
CreateUnzipper
()
const
{
return
zip
::
UniqueUnzipper
{
::
unzOpen2
(
file_path_
.
c_str
(),
nullptr
)};
}
// |blink::AssetResolver|
bool
ZipAssetStore
::
IsValid
()
const
{
return
stat_cache_
.
size
()
>
0
;
}
// |blink::AssetResolver|
bool
ZipAssetStore
::
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
)
const
{
TRACE_EVENT0
(
"flutter"
,
"ZipAssetStore::GetAsBuffer"
);
auto
found
=
stat_cache_
.
find
(
asset_name
);
if
(
found
==
stat_cache_
.
end
())
{
return
false
;
}
auto
unzipper
=
CreateUnzipper
();
if
(
!
unzipper
.
is_valid
())
{
return
false
;
}
int
result
=
UNZ_OK
;
result
=
unzGoToFilePos
(
unzipper
.
get
(),
&
(
found
->
second
.
file_pos
));
if
(
result
!=
UNZ_OK
)
{
FXL_LOG
(
WARNING
)
<<
"unzGetCurrentFileInfo failed, error="
<<
result
;
return
false
;
}
result
=
unzOpenCurrentFile
(
unzipper
.
get
());
if
(
result
!=
UNZ_OK
)
{
FXL_LOG
(
WARNING
)
<<
"unzOpenCurrentFile failed, error="
<<
result
;
return
false
;
}
data
->
resize
(
found
->
second
.
uncompressed_size
);
int
total_read
=
0
;
while
(
total_read
<
static_cast
<
int
>
(
data
->
size
()))
{
int
bytes_read
=
unzReadCurrentFile
(
unzipper
.
get
(),
data
->
data
()
+
total_read
,
data
->
size
()
-
total_read
);
if
(
bytes_read
<=
0
)
{
return
false
;
}
total_read
+=
bytes_read
;
}
return
true
;
}
void
ZipAssetStore
::
BuildStatCache
()
{
TRACE_EVENT0
(
"flutter"
,
"ZipAssetStore::BuildStatCache"
);
auto
unzipper
=
CreateUnzipper
();
if
(
!
unzipper
.
is_valid
())
{
return
;
}
if
(
unzGoToFirstFile
(
unzipper
.
get
())
!=
UNZ_OK
)
{
return
;
}
do
{
int
result
=
UNZ_OK
;
// Get the current file name.
unz_file_info
file_info
=
{};
char
file_name
[
255
];
result
=
unzGetCurrentFileInfo
(
unzipper
.
get
(),
&
file_info
,
file_name
,
sizeof
(
file_name
),
nullptr
,
0
,
nullptr
,
0
);
if
(
result
!=
UNZ_OK
)
{
continue
;
}
if
(
file_info
.
uncompressed_size
==
0
)
{
continue
;
}
// Get the current file position.
unz_file_pos
file_pos
=
{};
result
=
unzGetFilePos
(
unzipper
.
get
(),
&
file_pos
);
if
(
result
!=
UNZ_OK
)
{
continue
;
}
std
::
string
file_name_key
(
file_name
,
file_info
.
size_filename
);
CacheEntry
entry
(
file_pos
,
file_info
.
uncompressed_size
);
stat_cache_
.
emplace
(
std
::
move
(
file_name_key
),
std
::
move
(
entry
));
}
while
(
unzGoToNextFile
(
unzipper
.
get
())
==
UNZ_OK
);
}
}
// namespace blink
assets/zip_asset_store.h
0 → 100644
浏览文件 @
c0ec8d9f
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_ASSETS_ZIP_ASSET_STORE_H_
#define FLUTTER_ASSETS_ZIP_ASSET_STORE_H_
#include <map>
#include "flutter/assets/asset_resolver.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
#include "lib/zip/unique_unzipper.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
namespace
blink
{
class
ZipAssetStore
final
:
public
AssetResolver
{
public:
ZipAssetStore
(
std
::
string
file_path
);
~
ZipAssetStore
()
override
;
private:
struct
CacheEntry
{
unz_file_pos
file_pos
;
size_t
uncompressed_size
;
CacheEntry
(
unz_file_pos
p_file_pos
,
size_t
p_uncompressed_size
)
:
file_pos
(
p_file_pos
),
uncompressed_size
(
p_uncompressed_size
)
{}
};
std
::
string
file_path_
;
mutable
std
::
map
<
std
::
string
,
CacheEntry
>
stat_cache_
;
// |blink::AssetResolver|
bool
IsValid
()
const
override
;
// |blink::AssetResolver|
bool
GetAsBuffer
(
const
std
::
string
&
asset_name
,
std
::
vector
<
uint8_t
>*
data
)
const
override
;
void
BuildStatCache
();
zip
::
UniqueUnzipper
CreateUnzipper
()
const
;
FXL_DISALLOW_COPY_AND_ASSIGN
(
ZipAssetStore
);
};
}
// namespace blink
#endif // FLUTTER_ASSETS_ZIP_ASSET_STORE_H_
travis/licenses_golden/licenses_flutter
浏览文件 @
c0ec8d9f
...
...
@@ -322,6 +322,8 @@ ORIGIN: ../../../flutter/assets/directory_asset_bundle.cc + ../../../LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/assets/directory_asset_bundle.cc
FILE: ../../../flutter/assets/directory_asset_bundle.h
FILE: ../../../flutter/assets/zip_asset_store.cc
FILE: ../../../flutter/assets/zip_asset_store.h
FILE: ../../../flutter/common/settings.cc
FILE: ../../../flutter/common/settings.h
FILE: ../../../flutter/flow/export_node.cc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录