public GVRAndroidResource openResource ( String filePath ) throws IOException { // Error tolerance: Remove initial '/' introduced by file::///filename // In this case, the path is interpreted as relative to defaultPath, // which is the root of the filesystem. if ( filePath . startsWith ( File . separator ) ) { filePath = filePath . substring ( File . separator . length ( ) ) ; } filePath = adaptFilePath ( filePath ) ; String path ; int resourceId ; GVRAndroidResource resourceKey ; switch ( volumeType ) { case ANDROID_ASSETS : // Resolve '..' and '.' path = getFullPath ( defaultPath , filePath ) ; path = new File ( path ) . getCanonicalPath ( ) ; if ( path . startsWith ( File . separator ) ) { path = path . substring ( 1 ) ; } resourceKey = new GVRAndroidResource ( gvrContext , path ) ; break ; case ANDROID_RESOURCE : path = FileNameUtils . getBaseName ( filePath ) ; resourceId = gvrContext . getContext ( ) . getResources ( ) . getIdentifier ( path , "raw" , gvrContext . getContext ( ) . getPackageName ( ) ) ; if ( resourceId == 0 ) { throw new FileNotFoundException ( filePath + " resource not found" ) ; } resourceKey = new GVRAndroidResource ( gvrContext , resourceId ) ; break ; case LINUX_FILESYSTEM : resourceKey = new GVRAndroidResource ( getFullPath ( defaultPath , filePath ) ) ; break ; case ANDROID_SDCARD : String linuxPath = Environment . getExternalStorageDirectory ( ) . getAbsolutePath ( ) ; resourceKey = new GVRAndroidResource ( getFullPath ( linuxPath , defaultPath , filePath ) ) ; break ; case INPUT_STREAM : resourceKey = new GVRAndroidResource ( getFullPath ( defaultPath , filePath ) , volumeInputStream ) ; break ; case NETWORK : resourceKey = new GVRAndroidResource ( gvrContext , getFullURL ( defaultPath , filePath ) , enableUrlLocalCache ) ; break ; default : throw new IOException ( String . format ( "Unrecognized volumeType %s" , volumeType ) ) ; } return addResource ( resourceKey ) ; }
Opens a file from the volume . The filePath is relative to the defaultPath .