Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile-Cn-Ko-En
Commits
f1d6e3bb
Commit
f1d6e3bb
authored
Mar 22, 2020
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重置资源时清空script文件夹
parent
f50771be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
20 deletions
+39
-20
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+4
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+35
-18
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
f1d6e3bb
...
...
@@ -28,12 +28,11 @@ import cn.garymb.ygomobile.ui.activities.WebActivity;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.ComponentUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.NetUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
com.ourygo.assistant.util.PermissionUtil
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ACTION_RELOAD
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
NETWORK_IMAGE
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
ResCheckTask
.
ResCheckListener
;
...
...
@@ -219,6 +218,9 @@ public class MainActivity extends HomeActivity {
Log
.
e
(
"MainActivity"
,
"开始复制"
);
try
{
IOUtils
.
createNoMedia
(
AppsSettings
.
get
().
getResourcePath
());
FileUtils
.
delFile
(
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_SCRIPT_PATH
);
if
(
IOUtils
.
hasAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
f1d6e3bb
...
...
@@ -15,11 +15,11 @@ import java.util.List;
public
class
FileUtils
{
public
static
boolean
deleteFile
(
File
file
){
if
(
file
.
isFile
())
{
public
static
boolean
deleteFile
(
File
file
)
{
if
(
file
.
isFile
())
{
try
{
file
.
delete
();
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
return
false
;
}
}
...
...
@@ -83,14 +83,14 @@ public class FileUtils {
FileOutputStream
outputStream
=
null
;
try
{
File
dir
=
out
.
getParentFile
();
if
(!
dir
.
exists
())
{
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
outputStream
=
new
FileOutputStream
(
out
);
copy
(
in
,
outputStream
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
finally
{
}
finally
{
IOUtils
.
close
(
outputStream
);
IOUtils
.
close
(
in
);
}
...
...
@@ -101,7 +101,7 @@ public class FileUtils {
FileInputStream
inputStream
=
null
;
try
{
File
dir
=
out
.
getParentFile
();
if
(!
dir
.
exists
())
{
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
inputStream
=
new
FileInputStream
(
in
);
...
...
@@ -109,7 +109,7 @@ public class FileUtils {
copy
(
inputStream
,
outputStream
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
finally
{
}
finally
{
IOUtils
.
close
(
outputStream
);
IOUtils
.
close
(
inputStream
);
}
...
...
@@ -120,14 +120,14 @@ public class FileUtils {
//判断复制后的路径是否含有文件名,如果没有则加上
if
(!
isName
)
{
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String
abb
[]
=
oldPath
.
split
(
"/"
);
String
abb
[]
=
oldPath
.
split
(
"/"
);
newPath
=
newPath
+
"/"
+
abb
[
abb
.
length
-
1
];
}
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
fis
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
...
...
@@ -142,21 +142,21 @@ public class FileUtils {
//判断复制后的路径是否含有文件名,如果没有则加上
if
(!
isName
)
{
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String
abb
[]
=
oldPath
.
split
(
"/"
);
String
abb
[]
=
oldPath
.
split
(
"/"
);
newPath
=
newPath
+
"/"
+
abb
[
abb
.
length
-
1
];
}
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
fis
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
fos
.
close
();
fis
.
close
();
//删除文件
File
file
=
new
File
(
oldPath
);
File
file
=
new
File
(
oldPath
);
if
(
file
.
exists
()
&&
file
.
isFile
())
{
file
.
delete
();
}
...
...
@@ -170,4 +170,21 @@ public class FileUtils {
out
.
write
(
data
,
0
,
len
);
}
}
//删除文件(String Path)
public
static
void
delFile
(
String
s
)
{
File
file
=
new
File
(
s
);
if
(
file
.
isDirectory
())
{
File
[]
files
=
file
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
File
f
=
files
[
i
];
deleteFile
(
f
);
}
//file.delete();
}
else
if
(
file
.
exists
())
{
file
.
delete
();
}
}
}
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