Exemplo n.º 1
0
    // Gets a volume type from a string. For example, when loading
    // a script from a bundle file, the volume type attribute needs
    // to be converted to a VolumeType.
    public static VolumeType fromString(String name) {
      for (VolumeType type : VolumeType.values()) {
        if (type.getName().equalsIgnoreCase(name)) // case insensitive
        return type;
      }

      return null;
    }
Exemplo n.º 2
0
  /**
   * Adapt a file path to the current file system.
   *
   * @param filePath The input file path string.
   * @return File path compatible with the file system of this {@link GVRResourceVolume}.
   */
  protected String adaptFilePath(String filePath) {
    // Convert windows file path to target FS
    String targetPath = filePath.replaceAll("\\\\", volumeType.getSeparator());

    // FS-specific
    switch (volumeType) {
      case NETWORK:
        try {
          targetPath = URLEncoder.encode(targetPath, "UTF-8");
        } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
        }
        break;
      default:
        break;
    }

    return targetPath;
  }