Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
7711efbf
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
7711efbf
编写于
8月 13, 2019
作者:
J
Jason Simmons
提交者:
GitHub
8月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return an empty mapping for an empty file asset (#10815)
Fixes
https://github.com/flutter/flutter/issues/36574
上级
663f9a9e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
4 deletion
+37
-4
assets/directory_asset_bundle.cc
assets/directory_asset_bundle.cc
+1
-1
fml/file_unittest.cc
fml/file_unittest.cc
+14
-0
fml/mapping.cc
fml/mapping.cc
+2
-2
fml/mapping.h
fml/mapping.h
+3
-0
fml/platform/posix/mapping_posix.cc
fml/platform/posix/mapping_posix.cc
+7
-1
fml/platform/win/mapping_win.cc
fml/platform/win/mapping_win.cc
+10
-0
未找到文件。
assets/directory_asset_bundle.cc
浏览文件 @
7711efbf
...
...
@@ -38,7 +38,7 @@ std::unique_ptr<fml::Mapping> DirectoryAssetBundle::GetAsMapping(
auto
mapping
=
std
::
make_unique
<
fml
::
FileMapping
>
(
fml
::
OpenFile
(
descriptor_
,
asset_name
.
c_str
(),
false
,
fml
::
FilePermission
::
kRead
));
if
(
mapping
->
GetMapping
()
==
nullptr
)
{
if
(
!
mapping
->
IsValid
()
)
{
return
nullptr
;
}
...
...
fml/file_unittest.cc
浏览文件 @
7711efbf
...
...
@@ -155,3 +155,17 @@ TEST(FileTest, AtomicWriteTest) {
// Cleanup.
ASSERT_TRUE
(
fml
::
UnlinkFile
(
dir
.
fd
(),
"precious_data"
));
}
TEST
(
FileTest
,
EmptyMappingTest
)
{
fml
::
ScopedTemporaryDirectory
dir
;
auto
file
=
fml
::
OpenFile
(
dir
.
fd
(),
"my_contents"
,
true
,
fml
::
FilePermission
::
kReadWrite
);
fml
::
FileMapping
mapping
(
file
);
ASSERT_TRUE
(
mapping
.
IsValid
());
ASSERT_EQ
(
mapping
.
GetSize
(),
0ul
);
ASSERT_EQ
(
mapping
.
GetMapping
(),
nullptr
);
ASSERT_TRUE
(
fml
::
UnlinkFile
(
dir
.
fd
(),
"my_contents"
));
}
fml/mapping.cc
浏览文件 @
7711efbf
...
...
@@ -31,7 +31,7 @@ std::unique_ptr<FileMapping> FileMapping::CreateReadOnly(
auto
mapping
=
std
::
make_unique
<
FileMapping
>
(
base_fd
,
std
::
initializer_list
<
Protection
>
{
Protection
::
kRead
});
if
(
mapping
->
GetSize
()
==
0
||
mapping
->
GetMapping
()
==
nullptr
)
{
if
(
!
mapping
->
IsValid
()
)
{
return
nullptr
;
}
...
...
@@ -56,7 +56,7 @@ std::unique_ptr<FileMapping> FileMapping::CreateReadExecute(
base_fd
,
std
::
initializer_list
<
Protection
>
{
Protection
::
kRead
,
Protection
::
kExecute
});
if
(
mapping
->
GetSize
()
==
0
||
mapping
->
GetMapping
()
==
nullptr
)
{
if
(
!
mapping
->
IsValid
()
)
{
return
nullptr
;
}
...
...
fml/mapping.h
浏览文件 @
7711efbf
...
...
@@ -67,7 +67,10 @@ class FileMapping final : public Mapping {
uint8_t
*
GetMutableMapping
();
bool
IsValid
()
const
;
private:
bool
valid_
=
false
;
size_t
size_
=
0
;
uint8_t
*
mapping_
=
nullptr
;
uint8_t
*
mutable_mapping_
=
nullptr
;
...
...
fml/platform/posix/mapping_posix.cc
浏览文件 @
7711efbf
...
...
@@ -63,7 +63,8 @@ FileMapping::FileMapping(const fml::UniqueFD& handle,
return
;
}
if
(
stat_buffer
.
st_size
<=
0
)
{
if
(
stat_buffer
.
st_size
==
0
)
{
valid_
=
true
;
return
;
}
...
...
@@ -79,6 +80,7 @@ FileMapping::FileMapping(const fml::UniqueFD& handle,
mapping_
=
static_cast
<
uint8_t
*>
(
mapping
);
size_
=
stat_buffer
.
st_size
;
valid_
=
true
;
if
(
is_writable
)
{
mutable_mapping_
=
mapping_
;
}
...
...
@@ -98,4 +100,8 @@ const uint8_t* FileMapping::GetMapping() const {
return
mapping_
;
}
bool
FileMapping
::
IsValid
()
const
{
return
valid_
;
}
}
// namespace fml
fml/platform/win/mapping_win.cc
浏览文件 @
7711efbf
...
...
@@ -54,6 +54,11 @@ FileMapping::FileMapping(const fml::UniqueFD& fd,
return
;
}
if
(
mapping_size
==
0
)
{
valid_
=
true
;
return
;
}
DWORD
protect_flags
=
0
;
bool
read_only
=
!
IsWritable
(
protections
);
...
...
@@ -90,6 +95,7 @@ FileMapping::FileMapping(const fml::UniqueFD& fd,
mapping_
=
mapping
;
size_
=
mapping_size
;
valid_
=
true
;
if
(
IsWritable
(
protections
))
{
mutable_mapping_
=
mapping_
;
}
...
...
@@ -109,4 +115,8 @@ const uint8_t* FileMapping::GetMapping() const {
return
mapping_
;
}
bool
FileMapping
::
IsValid
()
const
{
return
valid_
;
}
}
// namespace fml
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录