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
Hide 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 {
}
func
(
f
*
serialFile
)
Size
()
(
int64
,
error
)
{
return
size
(
f
.
stat
,
f
.
FileName
())
}
func
size
(
stat
os
.
FileInfo
,
filename
string
)
(
int64
,
error
)
{
if
!
stat
.
IsDir
()
{
return
stat
.
Size
(),
nil
if
!
f
.
stat
.
IsDir
()
{
return
f
.
stat
.
Size
(),
nil
}
file
,
err
:=
os
.
Open
(
filename
)
if
err
!=
nil
{
return
0
,
err
}
files
,
err
:=
file
.
Readdir
(
0
)
if
err
!=
nil
{
return
0
,
err
}
file
.
Close
()
var
output
int64
for
_
,
child
:=
range
files
{
s
,
err
:=
size
(
child
,
fp
.
Join
(
filename
,
child
.
Name
()))
if
err
!=
nil
{
return
0
,
err
var
du
int64
err
:=
fp
.
Walk
(
f
.
FileName
(),
func
(
p
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
fi
!=
nil
&&
fi
.
Mode
()
&
(
os
.
ModeSymlink
|
os
.
ModeNamedPipe
)
==
0
{
du
+=
fi
.
Size
()
}
output
+=
s
}
return
output
,
nil
return
nil
}
)
return
du
,
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