コード例 #1
0
ファイル: DeviceImpl.java プロジェクト: aprasa/project
  protected void revertFileName(TranscodeFileImpl tf) throws TranscodeException {

    File cache_file = tf.getCacheFile();

    if (cache_file.exists()) {

      Debug.out("Cache file already allocated, can't rename");

      return;
    }

    File source_file = tf.getSourceFile().getFile(true);

    String original_name = source_file.getName();

    int pos = original_name.indexOf('.');

    if (pos == -1) {

      return;
    }

    String cf_name = cache_file.getName();

    if (cf_name.endsWith(original_name.substring(pos))) {

      return;
    }

    try {
      synchronized (this) {
        if (device_files == null) {

          loadDeviceFile();
        }

        String reverted_name = allocateUniqueFileName(original_name);

        tf.setCacheFile(new File(cache_file.getParentFile(), reverted_name));
      }
    } catch (Throwable e) {

      throw (new TranscodeException("File name revertion failed", e));
    }
  }