posix: remove dead code related to posix reserved suffixes. (#1555)

master
Krishna Srinivas 9 years ago committed by Harshavardhana
parent 9d41414fb5
commit 6627388dc3
  1. 2
      posix-list-dir-nix.go
  2. 2
      posix-list-dir-others.go
  3. 22
      posix-utils.go

@ -70,7 +70,7 @@ func parseDirents(dirPath string, buf []byte) (entries []string, err error) {
continue continue
} }
// Skip special files. // Skip special files.
if hasReservedPrefix(name) || hasReservedSuffix(name) { if hasPosixReservedPrefix(name) {
continue continue
} }

@ -57,7 +57,7 @@ func readDir(dirPath string) (entries []string, err error) {
} }
for _, fi := range fis { for _, fi := range fis {
// Skip special files. // Skip special files.
if hasReservedPrefix(fi.Name()) || hasReservedSuffix(fi.Name()) { if hasPosixReservedPrefix(fi.Name()) {
continue continue
} }
if fi.Mode().IsDir() { if fi.Mode().IsDir() {

@ -58,28 +58,14 @@ func isValidPath(path string) bool {
} }
// List of reserved words for files, includes old and new ones. // List of reserved words for files, includes old and new ones.
var reservedKeywords = []string{ var posixReservedPrefix = []string{
"$multiparts",
"$tmpobject",
"$tmpfile", "$tmpfile",
// Add new reserved words if any used in future. // Add new reserved words if any used in future.
} }
// hasReservedPrefix - returns true if name has a reserved keyword suffixed. // hasPosixReservedPrefix - has reserved prefix.
func hasReservedSuffix(name string) (isReserved bool) { func hasPosixReservedPrefix(name string) (isReserved bool) {
for _, reservedKey := range reservedKeywords { for _, reservedKey := range posixReservedPrefix {
if strings.HasSuffix(name, reservedKey) {
isReserved = true
break
}
isReserved = false
}
return isReserved
}
// hasReservedPrefix - has reserved prefix.
func hasReservedPrefix(name string) (isReserved bool) {
for _, reservedKey := range reservedKeywords {
if strings.HasPrefix(name, reservedKey) { if strings.HasPrefix(name, reservedKey) {
isReserved = true isReserved = true
break break

Loading…
Cancel
Save