Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2fc314fe
authored
Oct 19, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正文件存在判断逻辑
parent
47c1daf4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
MRFramework/MRFramework/FoundationManagers/Files/MRFiles.swift
+8
-4
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
+10
-1
No files found.
MRFramework/MRFramework/FoundationManagers/Files/MRFiles.swift
View file @
2fc314fe
...
...
@@ -45,14 +45,18 @@ extension MRFiles {
/// - path: 文件路径
/// - isDirectory: 是否文件夹,传入true,则路径一定要是文件夹才会返回true。默认是false
/// - Returns: 文件是否存在,且是否跟传入的isDirectory相符
public
class
func
fileExists
(
path
:
String
,
isDirectory
:
Bool
=
false
)
->
Bool
{
public
class
func
fileExists
(
path
:
String
,
isDirectory
:
Bool
?
=
nil
)
->
Bool
{
if
let
isDir
=
isDirectory
{
var
isDic
:
ObjCBool
=
false
let
isDir
=
UnsafeMutablePointer
<
ObjCBool
>
(
&
isDic
)
let
isExists
=
FileManager
.
default
.
fileExists
(
atPath
:
path
,
isDirectory
:
isDir
)
return
isExists
&&
(
isDirectory
==
isDic
.
boolValue
)
}
else
{
return
FileManager
.
default
.
fileExists
(
atPath
:
path
)
}
}
public
class
func
fileExists
(
url
:
URL
,
isDirectory
:
Bool
=
false
)
->
Bool
{
public
class
func
fileExists
(
url
:
URL
,
isDirectory
:
Bool
?
=
nil
)
->
Bool
{
return
fileExists
(
path
:
url
.
path
,
isDirectory
:
isDirectory
)
}
}
...
...
@@ -409,7 +413,7 @@ extension MRFiles {
// MARK: - 语法糖
extension
String
{
public
func
isPathExists
(
_
isDirectory
:
Bool
=
false
)
->
Bool
{
public
func
isPathExists
(
_
isDirectory
:
Bool
?
=
nil
)
->
Bool
{
return
MRFiles
.
fileExists
(
path
:
self
,
isDirectory
:
isDirectory
)
}
...
...
@@ -436,7 +440,7 @@ extension String {
}
extension
URL
{
public
func
isURLExists
(
_
isDirectory
:
Bool
=
false
)
->
Bool
{
public
func
isURLExists
(
_
isDirectory
:
Bool
?
=
nil
)
->
Bool
{
return
MRFiles
.
fileExists
(
url
:
self
,
isDirectory
:
isDirectory
)
}
...
...
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
View file @
2fc314fe
...
...
@@ -154,7 +154,16 @@ extension MRUpdateManager {
case
.
appUpgrade
:
if
let
bundleWWW
=
bundleWWWURL
{
asyncIfNeeded
{
let
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
??
self
.
sandboxBackupURL
.
syncDelete
()
??
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
var
error
:
Error
?
if
self
.
sandboxUpdateURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
}
if
error
==
nil
&&
self
.
sandboxBackupURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxBackupURL
.
syncDelete
()
}
if
error
==
nil
{
error
=
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
}
self
.
asyncInMain
{
complate
?(
self
,
error
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment