Skip to content

Commit

Permalink
Rewrite file size code in Swift
Browse files Browse the repository at this point in the history
  • Loading branch information
LebJe committed Dec 15, 2020
1 parent a00e5d7 commit e7c03e8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 42 deletions.
2 changes: 0 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ let package = Package(
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(name: "FileSize", path: "Sources/FileSize"),
.target(
name: "LFSPointersKit",
dependencies: [
"Files",
"FileSize",
.product(name: "Crypto", package: "swift-crypto")
]
),
Expand Down
29 changes: 0 additions & 29 deletions Sources/FileSize/impl.c

This file was deleted.

6 changes: 0 additions & 6 deletions Sources/FileSize/include/FileSize/FileSize.h

This file was deleted.

3 changes: 0 additions & 3 deletions Sources/FileSize/include/FileSize/module.modulemap

This file was deleted.

9 changes: 7 additions & 2 deletions Sources/LFSPointersKit/Pointers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation
import Files
import Crypto
import FileSize

/// Represents a Git LFS pointer for a file.
///
Expand Down Expand Up @@ -88,7 +87,13 @@ public struct LFSPointer: Codable, Equatable, Hashable {

try handle.close()

self.size = file.path.withCString({ getFileSize(UnsafeMutablePointer(mutating: $0)) })
let fp = fopen(file.path, "r")

fseek(fp, 0, SEEK_END)

self.size = ftell(fp)

fclose(fp)

self.filename = file.name
self.filePath = file.path
Expand Down

0 comments on commit e7c03e8

Please sign in to comment.