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