Skip to content

Commit

Permalink
add List
Browse files Browse the repository at this point in the history
  • Loading branch information
linyows committed May 28, 2018
1 parent b35b19b commit b08f32f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kvs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 72,18 @@ func (f *File) Delete(key string) error {
return nil
}

func (f *File) List() []string {
return []string{""}
func (f *File) List() ([]string, error) {
files, err := ioutil.ReadDir(f.dir)
if err != nil {
return nil, err
}

var list []string
for _, file := range files {
list = append(list, file.Name())
}

return list, nil
}

func isFileExist(p string) bool {
Expand Down

0 comments on commit b08f32f

Please sign in to comment.