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-dms3-cmds
Commits
aa47006f
Commit
aa47006f
authored
Aug 31, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serialfile: localize os.Open into NewSerialFile
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
2966aa62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
20 deletions
+13
-20
cli/parse.go
cli/parse.go
+1
-16
files/serialfile.go
files/serialfile.go
+12
-4
No files found.
cli/parse.go
View file @
aa47006f
...
...
@@ -356,21 +356,6 @@ func appendFile(args []files.File, inputs []string, argDef *cmds.Argument, recur
return
nil
,
nil
,
err
}
if
stat
.
Mode
()
&
os
.
ModeSymlink
!=
0
{
target
,
err
:=
os
.
Readlink
(
fpath
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
arg
:=
files
.
NewLinkFile
(
""
,
fpath
,
target
,
stat
)
return
append
(
args
,
arg
),
inputs
[
1
:
],
nil
}
file
,
err
:=
os
.
Open
(
fpath
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
if
stat
.
IsDir
()
{
if
!
argDef
.
Recursive
{
err
=
fmt
.
Errorf
(
"Invalid path '%s', argument '%s' does not support directories"
,
...
...
@@ -384,7 +369,7 @@ func appendFile(args []files.File, inputs []string, argDef *cmds.Argument, recur
}
}
arg
,
err
:=
files
.
NewSerialFile
(
path
.
Base
(
fpath
),
fpath
,
file
)
arg
,
err
:=
files
.
NewSerialFile
(
path
.
Base
(
fpath
),
fpath
,
stat
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
files/serialfile.go
View file @
aa47006f
...
...
@@ -25,8 +25,17 @@ type serialFile struct {
current
*
os
.
File
}
func
NewSerialFile
(
name
,
path
string
,
file
*
os
.
File
)
(
File
,
error
)
{
stat
,
err
:=
file
.
Stat
()
func
NewSerialFile
(
name
,
path
string
,
stat
os
.
FileInfo
)
(
File
,
error
)
{
if
stat
.
Mode
()
&
os
.
ModeSymlink
!=
0
{
target
,
err
:=
os
.
Readlink
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
return
NewLinkFile
(
""
,
path
,
target
,
stat
),
nil
}
file
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -49,8 +58,7 @@ func newSerialFile(name, path string, file *os.File, stat os.FileInfo) (File, er
// we no longer need our root directory file (we already statted the contents),
// so close it
err
=
file
.
Close
()
if
err
!=
nil
{
if
err
:=
file
.
Close
();
err
!=
nil
{
return
nil
,
err
}
...
...
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