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
dfd98f27
Commit
dfd98f27
authored
Apr 06, 2016
by
Stephen Whitmore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfs.Mkdir returns the final Directory it creates
License: MIT Signed-off-by:
Stephen Whitmore
<
noffle@ipfs.io
>
parent
ca50f0d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
core/commands/files/files.go
core/commands/files/files.go
+1
-1
core/coreunix/add.go
core/coreunix/add.go
+2
-2
mfs/ops.go
mfs/ops.go
+10
-10
No files found.
core/commands/files/files.go
View file @
dfd98f27
...
...
@@ -650,7 +650,7 @@ Examples:
flush
=
true
}
err
=
mfs
.
Mkdir
(
n
.
FilesRoot
,
dirtomake
,
dashp
,
flush
)
_
,
err
=
mfs
.
Mkdir
(
n
.
FilesRoot
,
dirtomake
,
dashp
,
flush
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
...
...
core/coreunix/add.go
View file @
dfd98f27
...
...
@@ -328,7 +328,7 @@ func (adder *Adder) addNode(node *dag.Node, path string) error {
dir
:=
gopath
.
Dir
(
path
)
if
dir
!=
"."
{
if
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
,
true
,
false
);
err
!=
nil
{
if
_
,
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
,
true
,
false
);
err
!=
nil
{
return
err
}
}
...
...
@@ -399,7 +399,7 @@ func (adder *Adder) addFile(file files.File) error {
func
(
adder
*
Adder
)
addDir
(
dir
files
.
File
)
error
{
log
.
Infof
(
"adding directory: %s"
,
dir
.
FileName
())
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
.
FileName
(),
true
,
false
)
_
,
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
.
FileName
(),
true
,
false
)
if
err
!=
nil
{
return
err
}
...
...
mfs/ops.go
View file @
dfd98f27
...
...
@@ -100,9 +100,9 @@ func PutNode(r *Root, path string, nd *dag.Node) error {
// Mkdir creates a directory at 'path' under the directory 'd', creating
// intermediary directories as needed if 'mkparents' is set to true
func
Mkdir
(
r
*
Root
,
pth
string
,
mkparents
bool
,
flush
bool
)
error
{
func
Mkdir
(
r
*
Root
,
pth
string
,
mkparents
bool
,
flush
bool
)
(
*
Directory
,
error
)
{
if
pth
==
""
{
return
nil
return
nil
,
nil
}
parts
:=
path
.
SplitList
(
pth
)
if
parts
[
0
]
==
""
{
...
...
@@ -117,9 +117,9 @@ func Mkdir(r *Root, pth string, mkparents bool, flush bool) error {
if
len
(
parts
)
==
0
{
// this will only happen on 'mkdir /'
if
mkparents
{
return
nil
return
nil
,
nil
}
return
fmt
.
Errorf
(
"cannot create directory '/': Already exists"
)
return
nil
,
fmt
.
Errorf
(
"cannot create directory '/': Already exists"
)
}
cur
:=
r
.
GetValue
()
.
(
*
Directory
)
...
...
@@ -128,16 +128,16 @@ func Mkdir(r *Root, pth string, mkparents bool, flush bool) error {
if
err
==
os
.
ErrNotExist
&&
mkparents
{
mkd
,
err
:=
cur
.
Mkdir
(
d
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
fsn
=
mkd
}
else
if
err
!=
nil
{
return
err
return
nil
,
err
}
next
,
ok
:=
fsn
.
(
*
Directory
)
if
!
ok
{
return
fmt
.
Errorf
(
"%s was not a directory"
,
path
.
Join
(
parts
[
:
i
]))
return
nil
,
fmt
.
Errorf
(
"%s was not a directory"
,
path
.
Join
(
parts
[
:
i
]))
}
cur
=
next
}
...
...
@@ -145,18 +145,18 @@ func Mkdir(r *Root, pth string, mkparents bool, flush bool) error {
final
,
err
:=
cur
.
Mkdir
(
parts
[
len
(
parts
)
-
1
])
if
err
!=
nil
{
if
!
mkparents
||
err
!=
os
.
ErrExist
||
final
==
nil
{
return
err
return
nil
,
err
}
}
if
flush
{
err
:=
final
.
Flush
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
return
nil
return
final
,
nil
}
func
Lookup
(
r
*
Root
,
path
string
)
(
FSNode
,
error
)
{
...
...
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