From 6627388dc3f3848e9f6133ecbeec689700894f35 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Tue, 10 May 2016 00:10:30 +0530 Subject: [PATCH] posix: remove dead code related to posix reserved suffixes. (#1555) --- posix-list-dir-nix.go | 2 +- posix-list-dir-others.go | 2 +- posix-utils.go | 22 ++++------------------ 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/posix-list-dir-nix.go b/posix-list-dir-nix.go index 24818fa15..37321ceb0 100644 --- a/posix-list-dir-nix.go +++ b/posix-list-dir-nix.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 } diff --git a/posix-list-dir-others.go b/posix-list-dir-others.go index 2a0b7ebf7..c9445e76a 100644 --- a/posix-list-dir-others.go +++ b/posix-list-dir-others.go @@ -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() { diff --git a/posix-utils.go b/posix-utils.go index be26822a2..7fa8570c9 100644 --- a/posix-utils.go +++ b/posix-utils.go @@ -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