@@ -656,6 +656,12 @@ void extractResources(Path resourcesDirectory) throws IOException {
656
656
@ Deprecated
657
657
public Path parsePath (URI uri ) {
658
658
if (uri .getScheme ().equals ("file" )) {
659
+ Path ret = Paths .get (uri );
660
+ if (!pathIsInVfs (ret )) {
661
+ if (delegate != null ) {
662
+ return delegate .parsePath (uri );
663
+ }
664
+ }
659
665
return Paths .get (uri );
660
666
} else {
661
667
throw new UnsupportedOperationException ("Not supported yet." );
@@ -665,51 +671,73 @@ public Path parsePath(URI uri) {
665
671
@ Override
666
672
@ Deprecated
667
673
public Path parsePath (String path ) {
668
- return Paths .get (path );
674
+ Path p = Paths .get (path );
675
+ if (!pathIsInVfs (p )) {
676
+ if (delegate != null ) {
677
+ return delegate .parsePath (path );
678
+ }
679
+ }
680
+ return p ;
669
681
}
670
682
671
683
@ Override
672
684
@ Deprecated
673
685
public void checkAccess (Path path , Set <? extends AccessMode > modes , LinkOption ... linkOptions ) throws IOException {
674
- if (pathIsInVfs (path )) {
686
+ if (!pathIsInVfs (path )) {
687
+ if (delegate != null ) {
688
+ delegate .checkAccess (path , modes , linkOptions );
689
+ return ;
690
+ } else {
691
+ throw new SecurityException ("filesystem without host IO: " + path );
692
+ }
693
+ } else {
675
694
if (modes .contains (AccessMode .WRITE )) {
676
695
throw new SecurityException ("read-only filesystem" );
677
696
}
678
697
if (getEntry (path ) == null ) {
679
698
throw new NoSuchFileException ("no such file or directory" );
680
699
}
681
- } else if (delegate != null ) {
682
- delegate .checkAccess (path , modes , linkOptions );
683
- } else {
684
- throw new SecurityException ("read-only filesystem" );
685
700
}
686
701
}
687
702
688
703
@ Override
689
704
@ Deprecated
690
705
public void createDirectory (Path dir , FileAttribute <?>... attrs ) throws IOException {
691
- if (delegate == null || pathIsInVfs (dir )) {
692
- throw new SecurityException ("read-only filesystem" );
706
+ if (!pathIsInVfs (dir )) {
707
+ if (delegate != null ) {
708
+ delegate .createDirectory (dir , attrs );
709
+ } else {
710
+ throw new SecurityException ("filesystem without host IO: " + dir );
711
+ }
693
712
} else {
694
- delegate . createDirectory ( dir , attrs );
713
+ throw new SecurityException ( "read-only filesystem" );
695
714
}
696
715
}
697
716
698
717
@ Override
699
718
@ Deprecated
700
719
public void delete (Path path ) throws IOException {
701
- if (delegate == null || pathIsInVfs (path )) {
702
- throw new SecurityException ("read-only filesystem" );
720
+ if (!pathIsInVfs (path )) {
721
+ if (delegate != null ) {
722
+ delegate .delete (path );
723
+ return ;
724
+ } else {
725
+ throw new SecurityException ("filesystem without host IO: " + path );
726
+ }
703
727
} else {
704
- delegate . delete ( path );
728
+ throw new SecurityException ( "read-only filesystem" );
705
729
}
706
730
}
707
731
708
732
@ Override
709
733
@ Deprecated
710
734
public SeekableByteChannel newByteChannel (Path path , Set <? extends OpenOption > options , FileAttribute <?>... attrs ) throws IOException {
711
- if (delegate != null && !pathIsInVfs (path )) {
712
- return delegate .newByteChannel (path , options , attrs );
735
+ if (!pathIsInVfs (path )) {
736
+ if (delegate != null ) {
737
+ return delegate .newByteChannel (path , options , attrs );
738
+ } else {
739
+ throw new SecurityException ("filesystem without host IO: " + path );
740
+ }
713
741
}
714
742
715
743
if (options .isEmpty () || (options .size () == 1 && options .contains (StandardOpenOption .READ ))) {
@@ -787,8 +815,12 @@ public void close() throws IOException {
787
815
@ Override
788
816
@ Deprecated
789
817
public DirectoryStream <Path > newDirectoryStream (Path dir , DirectoryStream .Filter <? super Path > filter ) throws IOException {
790
- if (delegate != null && !pathIsInVfs (dir )) {
791
- return delegate .newDirectoryStream (dir , filter );
818
+ if (!pathIsInVfs (dir )) {
819
+ if (delegate != null ) {
820
+ return delegate .newDirectoryStream (dir , filter );
821
+ } else {
822
+ throw new SecurityException ("filesystem without host IO: " + dir );
823
+ }
792
824
}
793
825
BaseEntry entry = getEntry (dir );
794
826
if (entry instanceof FileEntry ) {
@@ -813,32 +845,48 @@ public Iterator<Path> iterator() {
813
845
@ Override
814
846
@ Deprecated
815
847
public Path toAbsolutePath (Path path ) {
816
- Path result ;
817
- if (shouldExtract (path )) {
848
+ boolean pathIsInVFS = pathIsInVfs (path );
849
+ if (!pathIsInVFS ) {
850
+ if (delegate != null ) {
851
+ return delegate .toAbsolutePath (path );
852
+ } else {
853
+ throw new SecurityException ("filesystem without host IO: " + path );
854
+ }
855
+ }
856
+ Path result = path ;
857
+ if (pathIsInVFS && shouldExtract (path )) {
818
858
result = getExtractedPath (path );
819
- } else {
820
- result = path ;
821
859
}
822
860
return toAbsolutePathInternal (result );
823
861
}
824
862
825
863
@ Override
826
864
@ Deprecated
827
865
public Path toRealPath (Path path , LinkOption ... linkOptions ) throws IOException {
828
- Path result ;
829
- if (shouldExtract (path )) {
866
+ boolean pathIsInVFS = pathIsInVfs (path );
867
+ if (!pathIsInVFS ) {
868
+ if (delegate != null ) {
869
+ return delegate .toRealPath (path );
870
+ } else {
871
+ throw new SecurityException ("filesystem without host IO: " + path );
872
+ }
873
+ }
874
+ Path result = path ;
875
+ if (pathIsInVFS && shouldExtract (path )) {
830
876
result = getExtractedPath (path );
831
- } else {
832
- result = path ;
833
877
}
834
878
return result .normalize ();
835
879
}
836
880
837
881
@ Override
838
882
@ Deprecated
839
883
public Map <String , Object > readAttributes (Path path , String attributes , LinkOption ... options ) throws IOException {
840
- if (delegate != null && !pathIsInVfs (path )) {
841
- return delegate .readAttributes (path , attributes , options );
884
+ if (!pathIsInVfs (path )) {
885
+ if (delegate != null ) {
886
+ return delegate .readAttributes (path , attributes , options );
887
+ } else {
888
+ throw new SecurityException ("filesystem without host IO: " + path );
889
+ }
842
890
}
843
891
BaseEntry entry = getEntry (path );
844
892
if (entry == null ) {
0 commit comments