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

This commit is contained in:
Krishna Srinivas 2016-05-10 00:10:30 +05:30 committed by Harshavardhana
parent 9d41414fb5
commit 6627388dc3
3 changed files with 6 additions and 20 deletions

View File

@ -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
}

View File

@ -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() {

View File

@ -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