func NewFile(path string, info os.FileInfo) (*File, error) {
	f := File{
		Path:        path,
		IsDirectory: info.IsDir(),
		Name:        strings.TrimSuffix(info.Name(), filepath.Ext(path)),
		Extension:   strings.TrimPrefix(filepath.Ext(path), "."),
		Age:         time.Since(info.ModTime()),
	}

	if f.IsDirectory {
		err := f.directorySize()
		if err != nil {
			return nil, err
		}
	} else {
		f.SizeBytes = info.Size()
	}
	return &f, nil
}
// NewFile initializes and returns a new file.
NewFile initializes and returns a new file.
// NewFile initializes and returns a new file .
func NewFile(path string, info os.FileInfo) (*File, error) {
	f := File{
		Path:        path,
		IsDirectory: info.IsDir(),
		Name:        strings.TrimSuffix(info.Name(), filepath.Ext(path)),
		Extension:   strings.TrimPrefix(filepath.Ext(path), "."),
		Age:         time.Since(info.ModTime()),
	}
	if f.IsDirectory {
		err := f.directorySize()
		if err != nil {
			return nil, err
		}
	} else {
		f.SizeBytes = info.Size()
	}
	return &f, nil
}
func NewFile ( path string , info os . FileInfo ) ( * File , error ) { f := File { Path : path , IsDirectory : info . IsDir ( ) , Name : strings . TrimSuffix ( info . Name ( ) , filepath . Ext ( path ) ) , Extension : strings . TrimPrefix ( filepath . Ext ( path ) , " " ) , Age : time . Since ( info . ModTime ( ) ) , } if f . IsDirectory { err := f . directorySize ( ) if err != nil { return nil , err } } else { f . SizeBytes = info . Size ( ) } return & f , nil }
NewFile initializes and returns a new file.
NewFile initializes and returns a new file .