Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
e34d0310
Commit
e34d0310
authored
9 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
more robust unzip (previous version would fail with directories containing only subdirs)
parent
ac730ddf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java
+23
-24
23 additions, 24 deletions
contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java
with
23 additions
and
24 deletions
contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java
+
23
−
24
View file @
e34d0310
...
@@ -73,36 +73,35 @@ public class SplashScreen extends Activity{
...
@@ -73,36 +73,35 @@ public class SplashScreen extends Activity{
/**
/**
* Uncompress zip archive into the files directory of the application.
* Uncompress zip archive into the files directory of the application.
*/
*/
private
void
ImportZipArchive
(
InputStream
stream
)
private
boolean
ImportZipArchive
(
InputStream
stream
)
{
{
try
{
try
{
ZipInputStream
zipStream
=
new
ZipInputStream
(
stream
);
String
path
=
this
.
getFilesDir
().
getAbsolutePath
()
+
File
.
separator
;
ZipEntry
entry
;
ZipInputStream
zis
=
new
ZipInputStream
(
stream
);
while
((
entry
=
zipStream
.
getNextEntry
())
!=
null
)
{
byte
[]
buffer
=
new
byte
[
1024
];
String
name
=
entry
.
getName
();
ZipEntry
ze
;
FileOutputStream
outputStream
;
while
((
ze
=
zis
.
getNextEntry
())
!=
null
)
{
if
(
name
.
charAt
(
name
.
length
()-
1
)
==
'/'
)
{
String
filename
=
ze
.
getName
();
if
(
ze
.
isDirectory
())
{
File
fmd
=
new
File
(
path
+
filename
);
fmd
.
mkdirs
();
continue
;
continue
;
}
}
else
if
(
name
.
lastIndexOf
(
"/"
)
>
0
)
{
FileOutputStream
fout
=
new
FileOutputStream
(
path
+
filename
);
File
document
=
this
.
getFilesDir
();
int
count
;
File
currentDirectory
=
new
File
(
document
,
name
.
substring
(
0
,
name
.
lastIndexOf
(
"/"
)));
while
((
count
=
zis
.
read
(
buffer
))
!=
-
1
)
{
currentDirectory
.
mkdir
();
fout
.
write
(
buffer
,
0
,
count
);
File
currentFile
=
new
File
(
currentDirectory
,
name
.
substring
(
name
.
lastIndexOf
(
"/"
)+
1
));
outputStream
=
new
FileOutputStream
(
currentFile
);
}
}
else
{
fout
.
close
();
outputStream
=
openFileOutput
(
name
,
Context
.
MODE_PRIVATE
);
zis
.
closeEntry
(
);
}
}
byte
[]
buffer
=
new
byte
[
2048
];
zis
.
close
();
for
(
int
i
=
zipStream
.
read
(
buffer
,
0
,
buffer
.
length
);
i
>
0
;
i
=
zipStream
.
read
(
buffer
,
0
,
buffer
.
length
))
outputStream
.
write
(
buffer
,
0
,
i
);
}
}
zipStream
.
close
();
catch
(
IOException
e
)
{
}
e
.
printStackTrace
();
catch
(
IOException
e1
)
{
return
false
;
e1
.
printStackTrace
();
}
}
return
true
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment