Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
ea030b67
Commit
ea030b67
authored
May 09, 2015
by
Henry
Committed by
Juan Batiz-Benet
May 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unixfs/io: added NewEmptyDirectory()
some golinting along the way
parent
0f1dc11a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
io/dirbuilder.go
io/dirbuilder.go
+10
-2
No files found.
io/dirbuilder.go
View file @
ea030b67
...
...
@@ -15,15 +15,22 @@ type directoryBuilder struct {
dirnode
*
mdag
.
Node
}
// NewEmptyDirectory returns an empty merkledag Node with a folder Data chunk
func
NewEmptyDirectory
()
*
mdag
.
Node
{
return
&
mdag
.
Node
{
Data
:
format
.
FolderPBData
()}
}
// NewDirectory returns a directoryBuilder. It needs a DAGService to add the Children
func
NewDirectory
(
dserv
mdag
.
DAGService
)
*
directoryBuilder
{
db
:=
new
(
directoryBuilder
)
db
.
dserv
=
dserv
db
.
dirnode
=
new
(
mdag
.
Node
)
db
.
dirnode
.
Data
=
format
.
FolderPBData
()
db
.
dirnode
=
NewEmptyDirectory
()
return
db
}
// AddChild adds a (name, key)-pair to the root node.
func
(
d
*
directoryBuilder
)
AddChild
(
name
string
,
k
u
.
Key
)
error
{
// TODO(cryptix): consolidate context managment
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Minute
)
defer
cancel
()
...
...
@@ -40,6 +47,7 @@ func (d *directoryBuilder) AddChild(name string, k u.Key) error {
return
nil
}
// GetNode returns the root of this directoryBuilder
func
(
d
*
directoryBuilder
)
GetNode
()
*
mdag
.
Node
{
return
d
.
dirnode
}
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