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
}
// Skip special files.
if hasReservedPrefix(name) || hasReservedSuffix(name) {
if hasPosixReservedPrefix(name) {
continue
}

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

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

Loading…
Cancel
Save