Esempio n. 1
1
 /*
  * public static void StartCopyFile(HashSet<FileInfo> fileInfos, String
  * dest, Handler handler){ new CopyFileThread(fileInfos, dest,
  * handler).start(); }
  */
 public static void CopyFile(FileInfo fileInfo, String dest) {
   if (fileInfo == null || dest == null) {
     Log.e(TAG, "CopyFile: null parameter");
   }
   File file = fileInfo.getFile();
   Log.v(TAG, "CopyFile file = " + file.getName() + " isDir = " + file.isDirectory());
   if (file.isDirectory()) {
     String destPath = makePath(dest, file.getName());
     File destFile = new File(destPath);
     int i = 0;
     while (destFile.exists()) {
       destPath = makePath(dest, file.getName() + " " + i);
       destFile = new File(destPath);
       i++;
     }
     for (File fileInDirectory : file.listFiles(new SolarexFilter())) {
       FileInfo tmpFileInfo = new FileInfo(fileInDirectory, false);
       CopyFile(tmpFileInfo, destPath);
     }
   } else {
     String destFilePath = copyRawFile(file, dest);
     /*
      * Message msg = Message.obtain(); msg.what = COPY_FILE_RESULT; if
      * (null == destFilePath) { msg.obj = "Copy raw file " +
      * file.getAbsolutePath() + " failed"; } else { msg.obj =
      * "Copy raw file success, new file is " + destFilePath; }
      * handler.sendMessage(msg);
      */
   }
 }
Esempio n. 2
0
 public static boolean MoveFile(FileInfo fileInfo, String dest) {
   if (fileInfo == null || dest == null) {
     Log.v(TAG, "MoveFile: null parameter");
     return false;
   }
   File file = fileInfo.getFile();
   String newPath = makePath(dest, file.getName());
   try {
     boolean isSuccess = file.renameTo(new File(newPath));
     Log.v(
         TAG,
         "file = "
             + file.getAbsolutePath()
             + " newFile = "
             + newPath
             + " isSuccess = "
             + isSuccess);
     return isSuccess;
   } catch (Exception e) {
     Log.v(
         TAG,
         "MoveFile: failed to move " + file.getAbsolutePath() + " exception = " + e.getMessage());
   }
   return false;
 }
Esempio n. 3
0
  public static boolean DeleteFiles(FileInfo fileInfo) {
    if (fileInfo == null) {
      return false;
    }
    File file = fileInfo.getFile();
    if (!file.exists()) {
      return false;
    }

    if (file.isDirectory()) {
      for (File file2 : file.listFiles()) {
        DeleteFiles(new FileInfo(file2, false));
      }
    }

    boolean isSuccess = file.delete();
    Log.v(TAG, "file = " + file.getAbsolutePath() + " delete isSuccess = " + isSuccess);
    return isSuccess;
  }