当前位置: 首页>>代码示例>>Java>>正文


Java InvalidModificationException类代码示例

本文整理汇总了Java中org.apache.cordova.file.InvalidModificationException的典型用法代码示例。如果您正苦于以下问题:Java InvalidModificationException类的具体用法?Java InvalidModificationException怎么用?Java InvalidModificationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidModificationException类属于org.apache.cordova.file包,在下文中一共展示了InvalidModificationException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyDirectory

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private JSONObject copyDirectory(File paramFile1, File paramFile2)
  throws JSONException, IOException, NoModificationAllowedException, InvalidModificationException
{
  if ((paramFile2.exists()) && (paramFile2.isFile()))
    throw new InvalidModificationException("Can't rename a file to a directory");
  if (isCopyOnItself(paramFile1.getAbsolutePath(), paramFile2.getAbsolutePath()))
    throw new InvalidModificationException("Can't copy itself into itself");
  if ((!paramFile2.exists()) && (!paramFile2.mkdir()))
    throw new NoModificationAllowedException("Couldn't create the destination directory");
  File[] arrayOfFile = paramFile1.listFiles();
  int i = arrayOfFile.length;
  int j = 0;
  if (j < i)
  {
    File localFile = arrayOfFile[j];
    if (localFile.isDirectory())
      copyDirectory(localFile, paramFile2);
    while (true)
    {
      j++;
      break;
      copyFile(localFile, new File(paramFile2.getAbsoluteFile() + File.separator + localFile.getName()));
    }
  }
  return getEntry(paramFile2);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:27,代码来源:FileUtils.java

示例2: moveDirectory

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private JSONObject moveDirectory(File paramFile1, File paramFile2)
  throws IOException, JSONException, InvalidModificationException, NoModificationAllowedException, FileExistsException
{
  if ((paramFile2.exists()) && (paramFile2.isFile()))
    throw new InvalidModificationException("Can't rename a file to a directory");
  if (isCopyOnItself(paramFile1.getAbsolutePath(), paramFile2.getAbsolutePath()))
    throw new InvalidModificationException("Can't move itself into itself");
  if ((paramFile2.exists()) && (paramFile2.list().length > 0))
    throw new InvalidModificationException("directory is not empty");
  if (!paramFile1.renameTo(paramFile2))
  {
    copyDirectory(paramFile1, paramFile2);
    if (paramFile2.exists())
      removeDirRecursively(paramFile1);
  }
  else
  {
    return getEntry(paramFile2);
  }
  throw new IOException("moved failed");
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:FileUtils.java

示例3: moveFile

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private JSONObject moveFile(File paramFile1, File paramFile2)
  throws IOException, JSONException, InvalidModificationException
{
  if ((paramFile2.exists()) && (paramFile2.isDirectory()))
    throw new InvalidModificationException("Can't rename a file to a directory");
  if (!paramFile1.renameTo(paramFile2))
  {
    copyAction(paramFile1, paramFile2);
    if (paramFile2.exists())
      paramFile1.delete();
  }
  else
  {
    return getEntry(paramFile2);
  }
  throw new IOException("moved failed");
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:18,代码来源:FileUtils.java

示例4: moveFile

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * Move a file
 *
 * @param srcFile file to be copied
 * @param destFile destination to be copied to
 * @return a FileEntry object
 * @throws IOException
 * @throws InvalidModificationException
 * @throws JSONException
 */
private JSONObject moveFile(File srcFile, File destFile) throws IOException, JSONException, InvalidModificationException {
    // Renaming a file to an existing directory should fail
    if (destFile.exists() && destFile.isDirectory()) {
        throw new InvalidModificationException("Can't rename a file to a directory");
    }

    // Try to rename the file
    if (!srcFile.renameTo(destFile)) {
        // Trying to rename the file failed.  Possibly because we moved across file system on the device.
        // Now we have to do things the hard way
        // 1) Copy all the old file
        // 2) delete the src file
        copyAction(srcFile, destFile);
        if (destFile.exists()) {
            srcFile.delete();
        } else {
            throw new IOException("moved failed");
        }
    }

    return getEntry(destFile);
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:33,代码来源:FileUtils.java

示例5: remove

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty.
 * It is an error to attempt to delete the root directory of a filesystem.
 *
 * @param filePath file or directory to be removed
 * @return a boolean representing success of failure
 * @throws NoModificationAllowedException
 * @throws InvalidModificationException
 */
private boolean remove(String filePath) throws NoModificationAllowedException, InvalidModificationException {
    File fp = createFileObject(filePath);

    // You can't delete the root directory.
    if (atRootDirectory(filePath)) {
        throw new NoModificationAllowedException("You can't delete the root directory");
    }

    // You can't delete a directory that is not empty
    if (fp.isDirectory() && fp.list().length > 0) {
        throw new InvalidModificationException("You can't delete a directory that is not empty.");
    }

    return fp.delete();
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:25,代码来源:FileUtils.java

示例6: copyFile

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private JSONObject copyFile(File paramFile1, File paramFile2)
  throws IOException, InvalidModificationException, JSONException
{
  if ((paramFile2.exists()) && (paramFile2.isDirectory()))
    throw new InvalidModificationException("Can't rename a file to a directory");
  copyAction(paramFile1, paramFile2);
  return getEntry(paramFile2);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:9,代码来源:FileUtils.java

示例7: remove

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private boolean remove(String paramString)
  throws NoModificationAllowedException, InvalidModificationException
{
  File localFile = createFileObject(paramString);
  if (atRootDirectory(paramString))
    throw new NoModificationAllowedException("You can't delete the root directory");
  if ((localFile.isDirectory()) && (localFile.list().length > 0))
    throw new InvalidModificationException("You can't delete a directory that is not empty.");
  return localFile.delete();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:11,代码来源:FileUtils.java

示例8: transferTo

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
private JSONObject transferTo(String paramString1, String paramString2, String paramString3, boolean paramBoolean)
  throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException
{
  String str1 = FileHelper.getRealPath(paramString1, this.cordova);
  String str2 = FileHelper.getRealPath(paramString2, this.cordova);
  if ((paramString3 != null) && (paramString3.contains(":")))
    throw new EncodingException("Bad file name");
  File localFile1 = new File(str1);
  if (!localFile1.exists())
    throw new FileNotFoundException("The source does not exist");
  File localFile2 = new File(str2);
  if (!localFile2.exists())
    throw new FileNotFoundException("The source does not exist");
  File localFile3 = createDestination(paramString3, localFile1, localFile2);
  if (localFile1.getAbsolutePath().equals(localFile3.getAbsolutePath()))
    throw new InvalidModificationException("Can't copy a file onto itself");
  JSONObject localJSONObject;
  if (localFile1.isDirectory())
    if (paramBoolean)
      localJSONObject = moveDirectory(localFile1, localFile3);
  while (true)
  {
    return localJSONObject;
    return copyDirectory(localFile1, localFile3);
    if (!paramBoolean)
      break;
    localJSONObject = moveFile(localFile1, localFile3);
    if (!paramString1.startsWith("content://"))
      continue;
    notifyDelete(paramString1);
    return localJSONObject;
  }
  return copyFile(localFile1, localFile3);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:35,代码来源:FileUtils.java

示例9: copyFile

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * Copy a file
 *
 * @param srcFile file to be copied
 * @param destFile destination to be copied to
 * @return a FileEntry object
 * @throws IOException
 * @throws InvalidModificationException
 * @throws JSONException
 */
private JSONObject copyFile(File srcFile, File destFile) throws IOException, InvalidModificationException, JSONException {
    // Renaming a file to an existing directory should fail
    if (destFile.exists() && destFile.isDirectory()) {
        throw new InvalidModificationException("Can't rename a file to a directory");
    }

    copyAction(srcFile, destFile);

    return getEntry(destFile);
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:21,代码来源:FileUtils.java

示例10: copyDirectory

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * Copy a directory
 *
 * @param srcDir directory to be copied
 * @param destinationDir destination to be copied to
 * @return a DirectoryEntry object
 * @throws JSONException
 * @throws IOException
 * @throws NoModificationAllowedException
 * @throws InvalidModificationException
 */
private JSONObject copyDirectory(File srcDir, File destinationDir) throws JSONException, IOException, NoModificationAllowedException, InvalidModificationException {
    // Renaming a file to an existing directory should fail
    if (destinationDir.exists() && destinationDir.isFile()) {
        throw new InvalidModificationException("Can't rename a file to a directory");
    }

    // Check to make sure we are not copying the directory into itself
    if (isCopyOnItself(srcDir.getAbsolutePath(), destinationDir.getAbsolutePath())) {
        throw new InvalidModificationException("Can't copy itself into itself");
    }

    // See if the destination directory exists. If not create it.
    if (!destinationDir.exists()) {
        if (!destinationDir.mkdir()) {
            // If we can't create the directory then fail
            throw new NoModificationAllowedException("Couldn't create the destination directory");
        }
    }

    for (File file : srcDir.listFiles()) {
        if (file.isDirectory()) {
            copyDirectory(file, destinationDir);
        } else {
            File destination = new File(destinationDir.getAbsoluteFile() + File.separator + file.getName());
            copyFile(file, destination);
        }
    }

    return getEntry(destinationDir);
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:42,代码来源:FileUtils.java

示例11: moveDirectory

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * Move a directory
 *
 * @param srcDir directory to be copied
 * @param destinationDir destination to be copied to
 * @return a DirectoryEntry object
 * @throws JSONException
 * @throws IOException
 * @throws InvalidModificationException
 * @throws NoModificationAllowedException
 * @throws FileExistsException
 */
private JSONObject moveDirectory(File srcDir, File destinationDir) throws IOException, JSONException, InvalidModificationException, NoModificationAllowedException, FileExistsException {
    // Renaming a file to an existing directory should fail
    if (destinationDir.exists() && destinationDir.isFile()) {
        throw new InvalidModificationException("Can't rename a file to a directory");
    }

    // Check to make sure we are not copying the directory into itself
    if (isCopyOnItself(srcDir.getAbsolutePath(), destinationDir.getAbsolutePath())) {
        throw new InvalidModificationException("Can't move itself into itself");
    }

    // If the destination directory already exists and is empty then delete it.  This is according to spec.
    if (destinationDir.exists()) {
        if (destinationDir.list().length > 0) {
            throw new InvalidModificationException("directory is not empty");
        }
    }

    // Try to rename the directory
    if (!srcDir.renameTo(destinationDir)) {
        // Trying to rename the directory failed.  Possibly because we moved across file system on the device.
        // Now we have to do things the hard way
        // 1) Copy all the old files
        // 2) delete the src directory
        copyDirectory(srcDir, destinationDir);
        if (destinationDir.exists()) {
            removeDirRecursively(srcDir);
        } else {
            throw new IOException("moved failed");
        }
    }

    return getEntry(destinationDir);
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:47,代码来源:FileUtils.java

示例12: transferTo

import org.apache.cordova.file.InvalidModificationException; //导入依赖的package包/类
/**
 * A setup method that handles the move/copy of files/directories
 *
 * @param fileName to be copied/moved
 * @param newParent is the location where the file will be copied/moved to
 * @param newName for the file directory to be called, if null use existing file name
 * @param move if false do a copy, if true do a move
 * @return a Entry object
 * @throws NoModificationAllowedException
 * @throws IOException
 * @throws InvalidModificationException
 * @throws EncodingException
 * @throws JSONException
 * @throws FileExistsException
 */
private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
    String newFileName = FileHelper.getRealPath(fileName, cordova);
    newParent = FileHelper.getRealPath(newParent, cordova);

    // Check for invalid file name
    if (newName != null && newName.contains(":")) {
        throw new EncodingException("Bad file name");
    }

    File source = new File(newFileName);

    if (!source.exists()) {
        // The file/directory we are copying doesn't exist so we should fail.
        throw new FileNotFoundException("The source does not exist");
    }

    File destinationDir = new File(newParent);
    if (!destinationDir.exists()) {
        // The destination does not exist so we should fail.
        throw new FileNotFoundException("The source does not exist");
    }

    // Figure out where we should be copying to
    File destination = createDestination(newName, source, destinationDir);

    //Log.d(LOG_TAG, "Source: " + source.getAbsolutePath());
    //Log.d(LOG_TAG, "Destin: " + destination.getAbsolutePath());

    // Check to see if source and destination are the same file
    if (source.getAbsolutePath().equals(destination.getAbsolutePath())) {
        throw new InvalidModificationException("Can't copy a file onto itself");
    }

    if (source.isDirectory()) {
        if (move) {
            return moveDirectory(source, destination);
        } else {
            return copyDirectory(source, destination);
        }
    } else {
        if (move) {
            JSONObject newFileEntry = moveFile(source, destination);

            // If we've moved a file given its content URI, we need to clean up.
            if (fileName.startsWith("content://")) {
                notifyDelete(fileName);
            }

            return newFileEntry;
        } else {
            return copyFile(source, destination);
        }
    }
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:70,代码来源:FileUtils.java


注:本文中的org.apache.cordova.file.InvalidModificationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。