MCPcopy
hub / github.com/pocketbase/pocketbase / IsEmptyDir

Method IsEmptyDir

tools/filesystem/filesystem.go:386–398  ·  view source on GitHub ↗

Checks if the provided dir prefix doesn't have any files. A trailing slash will be appended to a non-empty dir string argument to ensure that the checked prefix is a "directory". Returns "false" in case the has at least one file, otherwise - "true".

(dir string)

Source from the content-addressed store, hash-verified

384//
385// Returns "false" in case the has at least one file, otherwise - "true".
386func (s *System) IsEmptyDir(dir string) bool {
387 if dir != "" && !strings.HasSuffix(dir, "/") {
388 dir += "/"
389 }
390
391 iter := s.bucket.List(&blob.ListOptions{
392 Prefix: dir,
393 })
394
395 _, err := iter.Next(s.ctx)
396
397 return err != nil && errors.Is(err, io.EOF)
398}
399
400var inlineServeContentTypes = []string{
401 // image

Callers 2

TestFileSystemIsEmptyDirFunction · 0.80
deleteEmptyRecordDirMethod · 0.80

Calls 3

IsMethod · 0.80
NextMethod · 0.65
ListMethod · 0.45

Tested by 1

TestFileSystemIsEmptyDirFunction · 0.64