IdentifyType.
This commit is contained in:
parent
769a59c713
commit
1650750fd0
1 changed files with 13 additions and 3 deletions
|
@ -84,9 +84,19 @@ func (i *INode) Name() string {
|
|||
return name
|
||||
}
|
||||
|
||||
// IdentifyType classifies a file-like object in one of the FileTypes.
|
||||
func IdentifyType(path string) (int, error) {
|
||||
return -1, ErrNotIdenfiedType
|
||||
// IdentifyType classifies a file-like object in one of the FileType.
|
||||
func IdentifyType(path string) (int, int64, error) {
|
||||
f, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return -1, 0, err
|
||||
}
|
||||
switch mode := f.Mode(); {
|
||||
case mode.IsDir():
|
||||
return DirType, f.Size(), nil
|
||||
case mode.IsRegular():
|
||||
return FileType, f.Size(), nil
|
||||
}
|
||||
return -1, 0, ErrNotIdenfiedType
|
||||
}
|
||||
|
||||
func ls(path string) ([]string, error) {
|
||||
|
|
Loading…
Reference in a new issue