IdentifyType.

This commit is contained in:
Blallo 2019-05-16 21:00:04 +02:00
parent 769a59c713
commit 1650750fd0
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

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