Structure
LFSPointer
public struct LFSPointer: Codable, Equatable, Hashable
Represents a Git LFS pointer for a file.
The pointer
Git LFS pointer for file.txt
version https://git-lfs.github.com/spec/v1
oid sha256:10b2cd328e193dd4b81d921dbe91bda74bda704c37bca43f1e15f41fcd20ac2a
size 1455
would look like this:
let pointer = try LFSPointer(fromFile: URL(fileURLWithPath: "file.txt"))
pointer.oid // 10b2cd328e193dd4b81d921dbe91bda74bda704c37bca43f1e15f41fcd20ac2a
pointer.size // 1455
pointer.version // https://git-lfs.github.com/spec/v1
Relationships
Conforms To
Codable
CustomDebugStringConvertible
Equatable
Hashable
Initializers
init(fromFile:)
public init(fromFile path: URL) throws
Initializes self
from a file.
Parameters
Name | Type | Description |
---|---|---|
path | URL |
The path to the file. |
Throws
LocationError
if the file path is invalid.
Properties
debugDescription
var debugDescription: String
version
let version: String
The version of the pointer.
Example: "https://git-lfs.github.com/spec/v1".
oid
let oid: String
An SHA 256 hash for the pointer.
size
let size: Int
The size of the converted file.
filename
let filename: String
The name of the file.
filePath
let filePath: String
The full path of the file.
stringRep
var stringRep: String
String representation of this pointer.
Methods
encode(to:)
public func encode(to encoder: Encoder) throws
pointers(forDirectory:searchType:recursive:statusClosure:)
public static func pointers(forDirectory directory: URL, searchType type: SearchTypes, recursive: Bool = false, statusClosure status: ((URL, Status) -> Void)? = nil) throws -> [LFSPointer]
Iterates over all files in a directory (excluding hidden files), and generates a LFS pointer for each one.
Parameters
Name | Type | Description |
---|---|---|
directory | URL |
The directory to iterate over. |
recursive | Bool |
Whether to include subdirectories when iterating. |
type | SearchTypes |
The search method you want to use. |
status | ((URL, Status) -> Void)? |
Use this closure to determine the status of this function. It will be passed the |
Throws
LocationError
if the directory path is invalid.
Returns
An array of LFSPointer
.
write(toFile:shouldAppend:statusClosure:)
public func write(toFile file: URL, shouldAppend: Bool = false, statusClosure status: ((URL, Status) -> Void)? = nil) throws
Write self
(LFSPointer
) to a file.
Parameters
Name | Type | Description |
---|---|---|
file | URL |
The file to write or append to. |
shouldAppend | Bool |
If the file should be appended to. |
status | ((URL, Status) -> Void)? |
Use this closure to determine the status of this function. It will be passed the |
Throws
LocationError
if the file path is invalid, or WriteError
if the file could not be written.