fusefrontend_reverse: collapse getFileType
This commit is contained in:
parent
1867fdaef4
commit
dd3d8c100b
@ -115,19 +115,24 @@ const (
|
|||||||
typeRegular fileType = iota
|
typeRegular fileType = iota
|
||||||
// A DirIV (gocryptfs.diriv) file
|
// A DirIV (gocryptfs.diriv) file
|
||||||
typeDiriv
|
typeDiriv
|
||||||
// A .name file for a file with a long name
|
// A gocryptfs.longname.*.name file for a file with a long name
|
||||||
typeName
|
typeName
|
||||||
// The config file
|
// The config file gocryptfs.conf
|
||||||
typeConfig
|
typeConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
// getFileType returns the type of file. Only the name is checked
|
// getFileType returns the type of file (one of the fileType constants above).
|
||||||
func (rfs *ReverseFS) getFileType(cPath string) fileType {
|
func (rfs *ReverseFS) getFileType(cPath string) fileType {
|
||||||
if rfs.isDirIV(cPath) {
|
if !rfs.args.PlaintextNames {
|
||||||
return typeDiriv
|
cName := filepath.Base(cPath)
|
||||||
}
|
// Is it a gocryptfs.diriv file?
|
||||||
if rfs.isNameFile(cPath) {
|
if cName == nametransform.DirIVFilename {
|
||||||
return typeName
|
return typeDiriv
|
||||||
|
}
|
||||||
|
// Is it a gocryptfs.longname.*.name file?
|
||||||
|
if t := nametransform.NameType(cName); t == nametransform.LongNameFilename {
|
||||||
|
return typeName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if rfs.isTranslatedConfig(cPath) {
|
if rfs.isTranslatedConfig(cPath) {
|
||||||
return typeConfig
|
return typeConfig
|
||||||
@ -135,24 +140,6 @@ func (rfs *ReverseFS) getFileType(cPath string) fileType {
|
|||||||
return typeRegular
|
return typeRegular
|
||||||
}
|
}
|
||||||
|
|
||||||
// isDirIV determines if the path points to a gocryptfs.diriv file
|
|
||||||
func (rfs *ReverseFS) isDirIV(relPath string) bool {
|
|
||||||
if rfs.args.PlaintextNames {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return filepath.Base(relPath) == nametransform.DirIVFilename
|
|
||||||
}
|
|
||||||
|
|
||||||
// isNameFile determines if the path points to a gocryptfs.longname.*.name
|
|
||||||
// file
|
|
||||||
func (rfs *ReverseFS) isNameFile(relPath string) bool {
|
|
||||||
if rfs.args.PlaintextNames {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
fileType := nametransform.NameType(filepath.Base(relPath))
|
|
||||||
return fileType == nametransform.LongNameFilename
|
|
||||||
}
|
|
||||||
|
|
||||||
// isTranslatedConfig returns true if the default config file name is in use
|
// isTranslatedConfig returns true if the default config file name is in use
|
||||||
// and the ciphertext path is "gocryptfs.conf".
|
// and the ciphertext path is "gocryptfs.conf".
|
||||||
// "gocryptfs.conf" then maps to ".gocryptfs.reverse.conf" in the plaintext
|
// "gocryptfs.conf" then maps to ".gocryptfs.reverse.conf" in the plaintext
|
||||||
|
Loading…
Reference in New Issue
Block a user