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
ec25a68e
Commit
ec25a68e
authored
Mar 16, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove dead code
This code was from a previous incarnation of this interface.
parent
6e4b6160
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 @
ec25a68e
...
...
@@ -3,16 +3,13 @@ package files
import
(
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
// 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
// to the next file when NextFile() is called).
// No more than one file will be opened at a time.
type
serialFile
struct
{
path
string
files
[]
os
.
FileInfo
...
...
@@ -42,7 +39,7 @@ func NewSerialFile(path string, hidden bool, stat os.FileInfo) (Node, error) {
return
NewReaderPathFile
(
path
,
file
,
stat
)
case
mode
.
IsDir
()
:
// 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
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -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
{
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