Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
3518cf05
Commit
3518cf05
authored
Dec 03, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Windows: You must explicitly request sparse files on Windows.
Also CopyFile() doesn't preserve sparseness.
parent
3c091037
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
filesystem-disk-test.c++
c++/src/kj/filesystem-disk-test.c++
+21
-0
No files found.
c++/src/kj/filesystem-disk-test.c++
View file @
3518cf05
...
...
@@ -824,6 +824,18 @@ KJ_TEST("DiskFile holes") {
auto
dir
=
tempDir
.
get
();
auto
file
=
dir
->
openFile
(
Path
(
"holes"
),
WriteMode
::
CREATE
);
#if _WIN32
FILE_SET_SPARSE_BUFFER
sparseInfo
;
memset
(
&
sparseInfo
,
0
,
sizeof
(
sparseInfo
));
sparseInfo
.
SetSparse
=
TRUE
;
DWORD
dummy
;
KJ_WIN32
(
DeviceIoControl
(
KJ_ASSERT_NONNULL
(
file
->
getWin32Handle
()),
FSCTL_SET_SPARSE
,
&
sparseInfo
,
sizeof
(
sparseInfo
),
NULL
,
0
,
&
dummy
,
NULL
));
#endif
file
->
writeAll
(
"foobar"
);
file
->
write
(
1
<<
20
,
StringPtr
(
"foobar"
).
asBytes
());
...
...
@@ -833,6 +845,8 @@ KJ_TEST("DiskFile holes") {
KJ_EXPECT
(
meta
.
spaceUsed
<=
2
*
65536
);
byte
buf
[
7
];
#if !_WIN32 // Win32 CopyFile() does NOT preserve sparseness.
{
// Copy doesn't fill in holes.
dir
->
transfer
(
Path
(
"copy"
),
WriteMode
::
CREATE
,
Path
(
"holes"
),
TransferMode
::
COPY
);
...
...
@@ -847,12 +861,14 @@ KJ_TEST("DiskFile holes") {
KJ_EXPECT
(
copy
->
read
(
1
<<
19
,
buf
)
==
7
);
KJ_EXPECT
(
StringPtr
(
reinterpret_cast
<
char
*>
(
buf
),
6
)
==
StringPtr
(
"
\0\0\0\0\0\0
"
,
6
));
}
#endif
file
->
truncate
(
1
<<
21
);
KJ_EXPECT
(
file
->
stat
().
spaceUsed
==
meta
.
spaceUsed
);
KJ_EXPECT
(
file
->
read
(
1
<<
20
,
buf
)
==
7
);
KJ_EXPECT
(
StringPtr
(
reinterpret_cast
<
char
*>
(
buf
),
6
)
==
"foobar"
);
#if !_WIN32 // Win32 CopyFile() does NOT preserve sparseness.
{
dir
->
transfer
(
Path
(
"copy"
),
WriteMode
::
MODIFY
,
Path
(
"holes"
),
TransferMode
::
COPY
);
auto
copy
=
dir
->
openFile
(
Path
(
"copy"
));
...
...
@@ -866,6 +882,11 @@ KJ_TEST("DiskFile holes") {
KJ_EXPECT
(
copy
->
read
(
1
<<
19
,
buf
)
==
7
);
KJ_EXPECT
(
StringPtr
(
reinterpret_cast
<
char
*>
(
buf
),
6
)
==
StringPtr
(
"
\0\0\0\0\0\0
"
,
6
));
}
#endif
// Try punching a hole with zero().
file
->
zero
(
1
<<
20
,
4096
);
KJ_EXPECT
(
file
->
stat
().
spaceUsed
<
meta
.
spaceUsed
);
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment