File tree Expand file tree Collapse file tree 1 file changed +1
-22
lines changed
aspect-model-editor-service/src/main/java/org/eclipse/esmf/ame/services/utils Expand file tree Collapse file tree 1 file changed +1
-22
lines changed Original file line number Diff line number Diff line change 1616import java .io .ByteArrayInputStream ;
1717import java .io .File ;
1818import java .io .IOException ;
19- import java .io .RandomAccessFile ;
2019import java .net .URI ;
21- import java .nio .channels .FileChannel ;
22- import java .nio .channels .FileLock ;
23- import java .nio .channels .OverlappingFileLockException ;
2420import java .nio .charset .StandardCharsets ;
2521import java .nio .file .Files ;
2622import java .nio .file .Path ;
@@ -94,10 +90,8 @@ public static void deleteFileSafely( @Nonnull final File file ) {
9490 return ;
9591 }
9692
97- if ( isFileLocked ( file ) ) {
93+ if ( ! file . isDirectory ( ) ) {
9894 FileUtils .deleteQuietly ( file );
99- } else if ( !file .isDirectory () ) {
100- Files .deleteIfExists ( file .toPath () );
10195 } else {
10296 FileUtils .deleteDirectory ( file );
10397 }
@@ -106,21 +100,6 @@ public static void deleteFileSafely( @Nonnull final File file ) {
106100 }
107101 }
108102
109- private static boolean isFileLocked ( final File file ) {
110- try ( final RandomAccessFile raf = new RandomAccessFile ( file , "rw" ); final FileChannel channel = raf .getChannel () ) {
111-
112- final FileLock lock = channel .tryLock ();
113- if ( lock != null ) {
114- lock .release ();
115- return false ;
116- }
117- } catch ( final IOException | OverlappingFileLockException e ) {
118- return true ;
119- }
120-
121- return true ;
122- }
123-
124103 private static Predicate <File > filterOutUnVisibleFiles () {
125104 return file -> !file .getName ().equals ( ".DS_Store" );
126105 }
You can’t perform that action at this time.
0 commit comments