Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
317eb781
Commit
317eb781
authored
Oct 15, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BTreeData: Implements more posix-ish sparse file
Writing 0 bytes or truncating past file end increases file length.
parent
5fbe2885
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
product/ERP5Type/BTreeData.py
product/ERP5Type/BTreeData.py
+22
-1
No files found.
product/ERP5Type/BTreeData.py
View file @
317eb781
...
...
@@ -75,7 +75,17 @@ class BTreeData(Persistent):
if
lower_key
+
value_len
>
offset
:
key
=
lower_key
buf
=
chunk
.
value
[:
offset
-
key
]
+
buf
while
buf
:
try
:
tree
.
minKey
(
len
(
buf
)
+
offset
)
except
ValueError
:
try
:
eof
=
tree
.
maxKey
()
except
ValueError
:
pass
else
:
if
not
tree
[
eof
].
value
:
del
tree
[
eof
]
while
buf
or
offset
>
len
(
self
):
try
:
next_key
=
tree
.
minKey
(
key
+
1
)
except
ValueError
:
...
...
@@ -190,6 +200,7 @@ class BTreeData(Persistent):
except
ValueError
:
break
del
tree
[
next_key
]
self
.
write
(
''
,
offset
)
if
__name__
==
'__main__'
:
...
...
@@ -207,6 +218,9 @@ if __name__ == '__main__':
data
=
BTreeData
()
data
.
write
(
''
,
10
)
check
(
data
,
10
,
0
,
20
,
'
\
x00
'
*
10
,
[
10
])
data
.
truncate
(
0
)
check
(
data
,
0
,
0
,
20
,
''
,
[])
data
.
write
(
'a'
,
5
)
...
...
@@ -242,3 +256,10 @@ if __name__ == '__main__':
check
(
data
,
3
,
0
,
3
,
'012'
,
[
0
])
data
.
truncate
(
0
)
check
(
data
,
0
,
0
,
0
,
''
,
[])
data
.
truncate
(
10
)
check
(
data
,
10
,
0
,
10
,
'
\
x00
'
*
10
,
[
10
])
data
.
write
(
'a'
,
15
)
check
(
data
,
16
,
0
,
16
,
'
\
x00
'
*
15
+
'a'
,
[
15
])
data
.
write
(
'bc'
,
9
)
check
(
data
,
16
,
0
,
16
,
'
\
x00
'
*
9
+
'bc'
+
'
\
x00
'
*
4
+
'a'
,
[
9
,
15
])
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