Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Energy ADE
ADE Xjc
Commits
8fff6436
Commit
8fff6436
authored
Mar 23, 2017
by
Claus Nagel
Browse files
added possibility to use jaxb-basics in schema compilation
parent
9561fd15
Changes
22
Hide whitespace changes
Inline
Side-by-side
src/org/citygml4j/ade_xjc/FileDeleter.java
0 → 100644
View file @
8fff6436
package
org.citygml4j.ade_xjc
;
import
java.io.IOException
;
import
java.nio.file.DirectoryStream
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.SimpleFileVisitor
;
import
java.nio.file.attribute.BasicFileAttributes
;
public
class
FileDeleter
extends
SimpleFileVisitor
<
Path
>
{
private
boolean
recursive
;
private
boolean
onlyEmptyDirs
;
public
FileDeleter
(
boolean
recursive
)
{
this
(
recursive
,
false
);
}
public
FileDeleter
(
boolean
recursive
,
boolean
onlyEmptyDirs
)
{
this
.
recursive
=
recursive
;
this
.
onlyEmptyDirs
=
onlyEmptyDirs
;
}
boolean
deleteFile
(
Path
file
)
throws
IOException
{
return
Files
.
deleteIfExists
(
file
);
}
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
if
(!
onlyEmptyDirs
)
deleteFile
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
throws
IOException
{
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
e
)
throws
IOException
{
if
(
e
!=
null
)
throw
e
;
boolean
delete
=
true
;
if
(
onlyEmptyDirs
)
{
try
(
DirectoryStream
<
Path
>
stream
=
Files
.
newDirectoryStream
(
dir
))
{
delete
=
!
stream
.
iterator
().
hasNext
();
}
}
if
(
delete
)
deleteFile
(
dir
);
return
recursive
?
FileVisitResult
.
CONTINUE
:
FileVisitResult
.
SKIP_SUBTREE
;
}
@Override
public
FileVisitResult
visitFileFailed
(
Path
file
,
IOException
exc
)
throws
IOException
{
return
FileVisitResult
.
CONTINUE
;
}
}
src/org/citygml4j/ade_xjc/Util.java
View file @
8fff6436
...
@@ -88,21 +88,5 @@ public class Util {
...
@@ -88,21 +88,5 @@ public class Util {
return
md5
.
xor
(
new
BigInteger
(
1
,
md5sum
));
return
md5
.
xor
(
new
BigInteger
(
1
,
md5sum
));
}
}
public
static
void
rmdir
(
File
folder
,
boolean
force
)
{
if
(!
folder
.
exists
())
return
;
File
[]
children
=
folder
.
listFiles
();
for
(
File
file
:
children
)
{
if
(
file
.
isDirectory
())
rmdir
(
file
,
force
);
if
(
force
)
file
.
delete
();
}
folder
.
delete
();
}
}
}
Prev
1
2
Next
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