Skip to content

Commit

Permalink
add GetEntriesByDirectory method to the index (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 23, 2023
1 parent c3bf589 commit e3bc6a5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/store/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ func (idx *Index) GetEntry(path []byte) (int, *Entry, bool) {
return newEntryFlag, nil, false
}

func (idx *Index) GetEntriesByDirectory(dirName string) []*Entry {
var entries []*Entry

dirRegexp := regexp.MustCompile(fmt.Sprintf(`%s\/.+`, dirName))
for _, entry := range idx.Entries {
if dirRegexp.Match(entry.Path) {
entries = append(entries, entry)
}
}

return entries
}

func (idx *Index) IsRegisteredAsDirectory(dirName string) bool {
if idx.EntryNum == 0 {
return false
Expand Down

0 comments on commit e3bc6a5

Please sign in to comment.