X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/df4d0355f25795914dd0fcb9d53a9113da047c15..ec19a11a385ff21d3e85a94e618d48d8be9ef20d:/src/com/owncloud/android/utils/FileStorageUtils.java diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 1894e74b..3895821d 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -18,10 +18,6 @@ package com.owncloud.android.utils; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -30,6 +26,8 @@ import com.owncloud.android.lib.resources.files.RemoteFile; import android.annotation.SuppressLint; import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.net.Uri; import android.os.Environment; import android.os.StatFs; @@ -77,7 +75,9 @@ public class FileStorageUtils { } public static String getInstantUploadFilePath(Context context, String fileName) { - String uploadPath = context.getString(R.string.instant_upload_path); + SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); + String uploadPathdef = context.getString(R.string.instant_upload_path); + String uploadPath = pref.getString("instant_upload_path", uploadPathdef); String value = uploadPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); return value; } @@ -101,7 +101,8 @@ public class FileStorageUtils { file.setMimetype(remote.getMimeType()); file.setModificationTimestamp(remote.getModifiedTimestamp()); file.setEtag(remote.getEtag()); - + file.setPermissions(remote.getPermissions()); + file.setRemoteId(remote.getRemoteId()); return file; } @@ -118,48 +119,9 @@ public class FileStorageUtils { file.setMimeType(ocFile.getMimetype()); file.setModifiedTimestamp(ocFile.getModificationTimestamp()); file.setEtag(ocFile.getEtag()); + file.setPermissions(ocFile.getPermissions()); + file.setRemoteId(ocFile.getRemoteId()); return file; } - - /** - * Copy file src in dst - * @param src - * @param dst - * @throws IOException - */ - @SuppressWarnings("resource") - public static void copyFile(File src, File dst) throws IOException { - FileChannel inChannel = new FileInputStream(src).getChannel(); - FileChannel outChannel = new FileOutputStream(dst).getChannel(); - try { - inChannel.transferTo(0, inChannel.size(), outChannel); - } finally { - if (inChannel != null) - inChannel.close(); - if (outChannel != null) - outChannel.close(); - } - } - - - /** - * Delete folder - * @param folder - * @return true if folder is deleted - */ - public static boolean deleteFolder(File folder){ - if (folder.isDirectory()) { - String[] children = folder.list(); - for (int i=0; i