From 931e21008bb079b4bb1e74b7c1e2618c98837cd7 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Wed, 8 Feb 2017 19:27:57 +0800 Subject: [PATCH] add utils class --- pass.xcodeproj/project.pbxproj | 4 ++++ pass/Utils.swift | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 pass/Utils.swift diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 89a46f0..0fd99cb 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ DC193FFC1E49E0340077E0A3 /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC193FFB1E49E0340077E0A3 /* PasscodeLock.framework */; }; DC193FFE1E49E0760077E0A3 /* PasscodeLockRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC193FFD1E49E0760077E0A3 /* PasscodeLockRepository.swift */; }; DC1940001E49E1A60077E0A3 /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC193FFF1E49E1A60077E0A3 /* PasscodeLockConfiguration.swift */; }; + DC19400B1E4B36B60077E0A3 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC19400A1E4B36B60077E0A3 /* Utils.swift */; }; DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; }; DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; }; DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */; }; @@ -47,6 +48,7 @@ DC193FFB1E49E0340077E0A3 /* PasscodeLock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PasscodeLock.framework; path = Carthage/Build/iOS/PasscodeLock.framework; sourceTree = ""; }; DC193FFD1E49E0760077E0A3 /* PasscodeLockRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockRepository.swift; sourceTree = ""; }; DC193FFF1E49E1A60077E0A3 /* PasscodeLockConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockConfiguration.swift; sourceTree = ""; }; + DC19400A1E4B36B60077E0A3 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = ""; }; DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = ""; }; DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Objective-CBridgingHeader.h"; sourceTree = ""; }; @@ -138,6 +140,7 @@ DC7E6EE91E432E48006C2443 /* Password.swift */, DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */, DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */, + DC19400A1E4B36B60077E0A3 /* Utils.swift */, DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */, DCA0499B1E3362F400522E8F /* PGPKeySettingTableViewController.swift */, DC8963BF1E38EEB900828B09 /* SSHKeySettingTableViewController.swift */, @@ -326,6 +329,7 @@ DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */, DC193FFE1E49E0760077E0A3 /* PasscodeLockRepository.swift in Sources */, DCA049981E33586A00522E8F /* DefaultKeys.swift in Sources */, + DC19400B1E4B36B60077E0A3 /* Utils.swift in Sources */, DCA0499E1E33BAC100522E8F /* Globals.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/pass/Utils.swift b/pass/Utils.swift new file mode 100644 index 0000000..6745d4f --- /dev/null +++ b/pass/Utils.swift @@ -0,0 +1,25 @@ +// +// Utils.swift +// pass +// +// Created by Mingshen Sun on 8/2/2017. +// Copyright © 2017 Bob Sun. All rights reserved. +// + +import Foundation + +class Utils { + static func removeFileIfExists(atPath path: String) { + let fm = FileManager.default + do { + if fm.fileExists(atPath: path) { + try fm.removeItem(atPath: path) + } + } catch { + print(error) + } + } + static func removeFileIfExists(at url: URL) { + removeFileIfExists(atPath: url.path) + } +}