Skip to content

Commit

Permalink
fix(ios)!: make filesystem return ctime and mtime as numbers (ionic-t…
Browse files Browse the repository at this point in the history
…eam#1947)

Co-authored-by: Dan Giralté (Ionic) <[email protected]>
  • Loading branch information
2 people authored and LaravelFreelancerNL committed Dec 19, 2023
1 parent ca8937e commit b65a836
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions filesystem/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ public class FilesystemPlugin: CAPPlugin, CAPBridgedPlugin {
let directoryContents = try implementation.readdir(at: fileUrl)
let directoryContent = try directoryContents.map {(url: URL) -> [String: Any] in
let attr = try implementation.stat(at: url)
var ctime = ""
var mtime = ""
var ctime: UInt64 = 0
var mtime: UInt64 = 0

if let ctimeSeconds = (attr[.creationDate] as? Date)?.timeIntervalSince1970 {
ctime = String(format: "%.0f", ctimeSeconds * 1000)
ctime = UInt64((ctimeSeconds * 1000).rounded())
}

if let mtimeSeconds = (attr[.modificationDate] as? Date)?.timeIntervalSince1970 {
mtime = String(format: "%.0f", mtimeSeconds * 1000)
mtime = UInt64((mtimeSeconds * 1000).rounded())
}
return [
"name": url.lastPathComponent,
Expand Down Expand Up @@ -250,15 +250,15 @@ public class FilesystemPlugin: CAPPlugin, CAPBridgedPlugin {
do {
let attr = try implementation.stat(at: fileUrl)

var ctime = ""
var mtime = ""
var ctime: UInt64 = 0
var mtime: UInt64 = 0

if let ctimeSeconds = (attr[.creationDate] as? Date)?.timeIntervalSince1970 {
ctime = String(format: "%.0f", ctimeSeconds * 1000)
ctime = UInt64((ctimeSeconds * 1000).rounded())
}

if let mtimeSeconds = (attr[.modificationDate] as? Date)?.timeIntervalSince1970 {
mtime = String(format: "%.0f", mtimeSeconds * 1000)
mtime = UInt64((mtimeSeconds * 1000).rounded())
}

call.resolve([
Expand Down

0 comments on commit b65a836

Please sign in to comment.