Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
cdc6fd14
Commit
cdc6fd14
authored
3 months ago
by
Riegel
Browse files
Options
Download
Email Patches
Plain Diff
Fix: Make parsing of path OS-agnostic
parent
283e0d57
master
dev
dev_cpp_code_conversion
dev_gui_features_zip_loading
3.17.0
archive/dev_gui_features_zip_loading
2 merge requests
!28
Version 3.17.0 Release
,
!26
Add ZIP-archive support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
+2
-1
.../hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/utils/ArchivePacker.java
+12
-12
.../stuttgart/citydoctor2/ziploader/utils/ArchivePacker.java
with
14 additions
and
13 deletions
+14
-13
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java
+
2
-
1
View file @
cdc6fd14
...
...
@@ -9,6 +9,7 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
...
...
@@ -45,7 +46,7 @@ public class CityGmlZipEntry {
try
{
Files
.
copy
(
is
,
Path
.
of
(
tempDir
.
toString
(),
entry
.
getName
()));
CityGmlParser
.
gagLogger
(
true
);
cgzEntry
.
model
=
CityGmlParser
.
parseCityGmlFile
(
tempDir
.
toString
()
+
"\\"
+
entry
.
getName
(),
config
);
cgzEntry
.
model
=
CityGmlParser
.
parseCityGmlFile
(
tempDir
.
toString
()
+
File
.
separator
+
entry
.
getName
(),
config
);
}
catch
(
CityGmlParseException
|
InvalidGmlFileException
e
)
{
logger
.
error
(
e
);
cgzEntry
.
erroneousEntry
=
true
;
...
...
This diff is collapsed.
Click to expand it.
CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/utils/ArchivePacker.java
+
12
-
12
View file @
cdc6fd14
...
...
@@ -11,6 +11,7 @@ import java.io.*;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -34,7 +35,7 @@ public class ArchivePacker {
continue
;
}
CityDoctorModel
model
=
entry
.
getModel
();
String
filename
=
tmpDir
.
toString
()
+
"\\"
+
entry
.
getFileName
();
String
filename
=
tmpDir
.
toString
()
+
File
.
separator
+
entry
.
getFileName
();
model
.
saveAs
(
filename
,
entry
.
isValidated
());
}
zipDirectory
(
targetPath
,
tmpDir
.
toString
());
...
...
@@ -53,15 +54,11 @@ public class ArchivePacker {
}
private
static
void
zipDirectory
(
String
targetPath
,
String
sourcePath
){
List
<
String
>
fileList
=
new
ArrayList
<>();
File
directory
=
new
File
(
sourcePath
);
for
(
String
file
:
directory
.
list
()){
fileList
.
add
(
file
);
}
List
<
String
>
fileList
=
new
ArrayList
<>(
Arrays
.
asList
(
directory
.
list
()));
byte
[]
buffer
=
new
byte
[
1024
];
String
source
=
new
File
(
sourcePath
).
getName
();
FileOutputStream
fos
=
null
;
FileOutputStream
fos
;
ZipOutputStream
zos
=
null
;
try
{
fos
=
new
FileOutputStream
(
targetPath
);
...
...
@@ -71,7 +68,8 @@ public class ArchivePacker {
ZipEntry
ze
=
new
ZipEntry
(
file
);
zos
.
putNextEntry
(
ze
);
try
{
in
=
new
FileInputStream
(
sourcePath
+
"\\"
+
file
);
Path
sourceFile
=
Path
.
of
(
sourcePath
+
File
.
separator
+
file
);
in
=
new
FileInputStream
(
sourceFile
.
toAbsolutePath
().
toString
());
int
len
;
while
((
len
=
in
.
read
(
buffer
))
>
0
)
{
zos
.
write
(
buffer
,
0
,
len
);
...
...
@@ -87,10 +85,12 @@ public class ArchivePacker {
}
catch
(
IOException
e
)
{
logger
.
error
(
e
);
}
finally
{
try
{
zos
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
);
if
(
zos
!=
null
)
{
try
{
zos
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets