Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat/add-ignore-r…
Browse files Browse the repository at this point in the history
…ules

* upstream/master:
  chore: remove dead code
  Bump travis to go 1.14
  Remove last portion of gx
  • Loading branch information
corntoole committed Mar 18, 2020
2 parents efedc00 + a2d52b5 commit 8de2da5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 38 deletions.
1 change: 0 additions & 1 deletion .gx/lastpubver

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
language: go

go:
- 1.11.x
- 1.14.x

env:
global:
Expand Down
38 changes: 2 additions & 36 deletions serialfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package files
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
)

// 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
Expand Down Expand Up @@ -53,7 +51,7 @@ func NewSerialFileWithFilter(path string, filter *Filter, stat os.FileInfo) (Nod
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
Expand Down Expand Up @@ -124,38 +122,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.filter.ShouldExclude(stat) {
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 := NewSerialFileWithFilter(filePath, f.filter, stat)
if err != nil {
return "", nil, err
}

return stat.Name(), sf, nil
}

func (f *serialFile) Close() error {
return nil
}
Expand Down

0 comments on commit 8de2da5

Please sign in to comment.