From b65a8368a6cea14a3880efbeda1997bf6f62e9ac Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Fri, 8 Dec 2023 17:01:30 +0100 Subject: [PATCH] fix(ios)!: make filesystem return ctime and mtime as numbers (#1947) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dan Giralté (Ionic) --- .../FilesystemPlugin/FilesystemPlugin.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/filesystem/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift b/filesystem/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift index e4524194f..2ffe4f42b 100644 --- a/filesystem/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift +++ b/filesystem/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift @@ -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, @@ -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([