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-files
Commits
a2d52b51
Unverified
Commit
a2d52b51
authored
Mar 16, 2020
by
Steven Allen
Committed by
GitHub
Mar 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #29 from ipfs/chore/remove-dead-code
chore: remove dead code
parents
6e4b6160
ec25a68e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
serialfile.go
serialfile.go
+2
-37
No files found.
serialfile.go
View file @
a2d52b51
...
@@ -3,16 +3,13 @@ package files
...
@@ -3,16 +3,13 @@ package files
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
)
)
// serialFile implements Node, and reads from a path on the OS filesystem.
// serialFile implements Node, and reads from a path on the OS filesystem.
// No more than one file will be opened at a time (directories will advance
// No more than one file will be opened at a time.
// to the next file when NextFile() is called).
type
serialFile
struct
{
type
serialFile
struct
{
path
string
path
string
files
[]
os
.
FileInfo
files
[]
os
.
FileInfo
...
@@ -42,7 +39,7 @@ func NewSerialFile(path string, hidden bool, stat os.FileInfo) (Node, error) {
...
@@ -42,7 +39,7 @@ func NewSerialFile(path string, hidden bool, stat os.FileInfo) (Node, error) {
return
NewReaderPathFile
(
path
,
file
,
stat
)
return
NewReaderPathFile
(
path
,
file
,
stat
)
case
mode
.
IsDir
()
:
case
mode
.
IsDir
()
:
// for directories, stat all of the contents first, so we know what files to
// for directories, stat all of the contents first, so we know what files to
// open when
NextFile
() is called
// open when
Entries
() is called
contents
,
err
:=
ioutil
.
ReadDir
(
path
)
contents
,
err
:=
ioutil
.
ReadDir
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -113,38 +110,6 @@ func (f *serialFile) Entries() DirIterator {
...
@@ -113,38 +110,6 @@ func (f *serialFile) Entries() DirIterator {
}
}
}
}
func
(
f
*
serialFile
)
NextFile
()
(
string
,
Node
,
error
)
{
// if there aren't any files left in the root directory, we're done
if
len
(
f
.
files
)
==
0
{
return
""
,
nil
,
io
.
EOF
}
stat
:=
f
.
files
[
0
]
f
.
files
=
f
.
files
[
1
:
]
for
!
f
.
handleHiddenFiles
&&
strings
.
HasPrefix
(
stat
.
Name
(),
"."
)
{
if
len
(
f
.
files
)
==
0
{
return
""
,
nil
,
io
.
EOF
}
stat
=
f
.
files
[
0
]
f
.
files
=
f
.
files
[
1
:
]
}
// open the next file
filePath
:=
filepath
.
ToSlash
(
filepath
.
Join
(
f
.
path
,
stat
.
Name
()))
// recursively call the constructor on the next file
// if it's a regular file, we will open it as a ReaderFile
// if it's a directory, files in it will be opened serially
sf
,
err
:=
NewSerialFile
(
filePath
,
f
.
handleHiddenFiles
,
stat
)
if
err
!=
nil
{
return
""
,
nil
,
err
}
return
stat
.
Name
(),
sf
,
nil
}
func
(
f
*
serialFile
)
Close
()
error
{
func
(
f
*
serialFile
)
Close
()
error
{
return
nil
return
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