FilePath - linhay/Stem GitHub Wiki
FilePath
public class FilePath: Equatable
Inheritance
Equatable
Initializers
init(path:inSanbox:type:)
convenience init(path: String, inSanbox rootPath: SanboxRootPath, type: Type? = nil) throws
init(path:type:)
生成 FilePath
public convenience init(path: String, type: Type? = nil) throws
Parameters
- path: - path: 文件路径
- type: - type: 指定文件类型, nil: 自动检测
Throws
FilePathError - path解析错误 | 目标路径不是文件路径 | 目标路径不存在
init(url:type:)
生成 FilePath
public init(url: URL, type: Type? = nil) throws
Parameters
- url: - url: 文件路径
- type: - type: 指定文件类型, nil: 自动检测
Throws
FilePathError - 目标路径不是文件路径 | 目标路径不存在
Properties
manager
let manager
manager
let manager
attributes
let attributes: Attributes
url
当前路径
var url: URL
path
当前路径
var path: String
type
文件类型
var type: Type
isExist
当前路径是否存在
var isExist: Bool
Methods
data()
文件数据
func data() throws -> Data
Throws
Data error
Returns
data
create(with:)
根据当前[FilePath]创建文件/文件夹
func create(with data: Data? = nil) throws
Throws
FilePathError - 文件/文件夹 存在, 无法创建
create(folder:)
在当前路径下创建文件夹
@discardableResult func create(folder name: String) throws -> FilePath
Parameters
- name: - name: 文件夹名
Throws
FileManager error
Returns
创建文件夹的 FilePath
move(to:)
移动至目标路径
func move(to path: FilePath) throws
Parameters
- path: - path: 目标路径
Throws
FileManagerError -
delete()
删除
func delete() throws
Throws
FileManager error
copy(to:)
拷贝至目标路径
func copy(to path: FilePath) throws
Parameters
- path: - path: 目标路径
Throws
FilePathError - 文件重复 | 无法 [文件夹 -> 文件] 拷贝
allSubFilePaths()
递归获取文件夹中所有文件/文件夹
func allSubFilePaths() throws -> [FilePath]
Throws
FilePathError - "目标路径不是文件夹类型"
Returns
[FilePath]
subFilePaths()
获取文件夹中文件/文件夹
func subFilePaths() throws -> [FilePath]
Throws
FilePathError - "目标路径不是文件夹类型"
Returns
[FilePath]
checkType(url:)
文件/文件夹类型
static func checkType(url: URL) throws -> Type
Parameters
- url: - url: 文件路径
Throws
FilePathError - "目标路径文件不存在: url"
Returns
类型
==(lhs:rhs:)
static func ==(lhs: FilePath, rhs: FilePath) -> Bool