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
58d93674
Commit
58d93674
authored
Aug 31, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use filepath.Walk to compute serialfile total size
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
59033650
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
24 deletions
+9
-24
files/serialfile.go
files/serialfile.go
+9
-24
No files found.
files/serialfile.go
View file @
58d93674
...
@@ -126,31 +126,16 @@ func (f *serialFile) Stat() os.FileInfo {
...
@@ -126,31 +126,16 @@ func (f *serialFile) Stat() os.FileInfo {
}
}
func
(
f
*
serialFile
)
Size
()
(
int64
,
error
)
{
func
(
f
*
serialFile
)
Size
()
(
int64
,
error
)
{
return
size
(
f
.
stat
,
f
.
FileName
())
if
!
f
.
stat
.
IsDir
()
{
}
return
f
.
stat
.
Size
(),
nil
func
size
(
stat
os
.
FileInfo
,
filename
string
)
(
int64
,
error
)
{
if
!
stat
.
IsDir
()
{
return
stat
.
Size
(),
nil
}
}
file
,
err
:=
os
.
Open
(
filename
)
var
du
int64
if
err
!=
nil
{
err
:=
fp
.
Walk
(
f
.
FileName
(),
func
(
p
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
return
0
,
err
if
fi
!=
nil
&&
fi
.
Mode
()
&
(
os
.
ModeSymlink
|
os
.
ModeNamedPipe
)
==
0
{
}
du
+=
fi
.
Size
()
files
,
err
:=
file
.
Readdir
(
0
)
if
err
!=
nil
{
return
0
,
err
}
}
file
.
Close
()
return
nil
})
var
output
int64
return
du
,
err
for
_
,
child
:=
range
files
{
s
,
err
:=
size
(
child
,
fp
.
Join
(
filename
,
child
.
Name
()))
if
err
!=
nil
{
return
0
,
err
}
output
+=
s
}
return
output
,
nil
}
}
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