LFSPointersKit Documentation Beta

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
%3 LFSPointer LFSPointer Codable Codable LFSPointer->Codable CustomDebugStringConvertible CustomDebugStringConvertible LFSPointer->CustomDebugStringConvertible Equatable Equatable LFSPointer->Equatable Hashable Hashable LFSPointer->Hashable

Conforms To

Codable
CustomDebugStringConvertible
Equatable
Hashable

Initializers

init(from​File:​)

public init(fromFile path: URL) throws

Initializes self from a file.

Parameters

path URL

The path to the file.

Throws

LocationError if the file path is invalid.

Properties

debug​Description

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.

file​Path

let filePath: String

The full path of the file.

string​Rep

var stringRep: String

String representation of this pointer.

Methods

encode(to:​)

public func encode(to encoder: Encoder) throws

pointers(for​Directory:​search​Type:​recursive:​status​Closure:​)

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

directory URL

The directory to iterate over.

recursive Bool

Whether to include subdirectories when iterating.

type Search​Types

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 URL of the file or folder being operated on, as well as an enum representing the status of this function.

Throws

LocationError if the directory path is invalid.

Returns

An array of LFSPointer.

write(to​File:​should​Append:​status​Closure:​)

public func write(toFile file: URL, shouldAppend: Bool = false, statusClosure status: ((URL, Status) -> Void)? = nil) throws

Write self (LFSPointer) to a file.

Parameters

file URL

The file to write or append to.

should​Append 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 URL of the file or folder being operated on, as well as an enum representing the status of this function.

Throws

LocationError if the file path is invalid, or WriteError if the file could not be written.