diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java index 40d1013a..d8983ed9 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java @@ -41,6 +41,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion; import okhttp3.Cookie; import timber.log.Timber; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -249,7 +250,7 @@ public class AccountUtils { .domain(serverUri.getHost()) .path( serverUri.getPath().equals("") - ? FileUtils.PATH_SEPARATOR + ? File.separator : serverUri.getPath() ) .build()); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index 0843783f..481ca168 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -29,12 +29,11 @@ import timber.log.Timber; import java.io.File; public class FileUtils { - public static final String PATH_SEPARATOR = "/"; public static final String FINAL_CHUNKS_FILE = ".file"; static String getParentPath(String remotePath) { String parentPath = new File(remotePath).getParent(); - parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR; + parentPath = parentPath.endsWith(File.separator) ? parentPath : parentPath + File.separator; return parentPath; } @@ -42,14 +41,12 @@ public class FileUtils { * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , * : , " , | , ? , * * - * @param fileName - * @return */ public static boolean isValidName(String fileName) { boolean result = true; Timber.d("fileName =======%s", fileName); - if (fileName.contains(PATH_SEPARATOR)) { + if (fileName.contains(File.separator)) { result = false; } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java index 740641aa..d52ec1d8 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -41,6 +41,7 @@ import at.bitfire.dav4android.property.owncloud.OCPermissions; import at.bitfire.dav4android.property.owncloud.OCPrivatelink; import at.bitfire.dav4android.property.owncloud.OCSize; +import java.io.File; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -92,13 +93,13 @@ public class RemoteFile implements Parcelable, Serializable { /** * Create new {@link RemoteFile} with given path. *
- * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'. + * The path received must be URL-decoded. Path separator must be File.separator, and it must be the first character in 'path'. * * @param path The remote path of the file. */ public RemoteFile(String path) { resetData(); - if (path == null || path.length() <= 0 || !path.startsWith(FileUtils.PATH_SEPARATOR)) { + if (path == null || path.length() <= 0 || !path.startsWith(File.separator)) { throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path); } mRemotePath = path; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java index 90a9c469..f27fdb53 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java @@ -68,11 +68,10 @@ public class RenameRemoteFileOperation extends RemoteOperation { mNewName = newName; String parent = (new File(mOldRemotePath)).getParent(); - parent = (parent.endsWith(FileUtils.PATH_SEPARATOR)) ? parent : parent + - FileUtils.PATH_SEPARATOR; + parent = (parent.endsWith(File.separator)) ? parent : parent + File.separator; mNewRemotePath = parent + mNewName; if (isFolder) { - mNewRemotePath += FileUtils.PATH_SEPARATOR; + mNewRemotePath += File.separator; } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java index bbc297c8..0072b5be 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java @@ -82,14 +82,12 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation } long offset = 0; - String uriPrefix = client.getUploadsWebDavUri() + FileUtils.PATH_SEPARATOR + String.valueOf(mTransferId); + String uriPrefix = client.getUploadsWebDavUri() + File.separator + mTransferId; long totalLength = fileToUpload.length(); long chunkCount = (long) Math.ceil((double) totalLength / CHUNK_SIZE); for (int chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++, offset += CHUNK_SIZE) { - mPutMethod = new PutMethod( - new URL(uriPrefix + FileUtils.PATH_SEPARATOR + chunkIndex) - ); + mPutMethod = new PutMethod(new URL(uriPrefix + File.separator + chunkIndex)); if (mRequiredEtag != null && mRequiredEtag.length() > 0) { mPutMethod.addRequestHeader(IF_MATCH_HEADER, "\"" + mRequiredEtag + "\""); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt index 12032316..20bb1ae9 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt @@ -25,6 +25,7 @@ package com.owncloud.android.lib.resources.shares import com.owncloud.android.lib.resources.files.FileUtils +import java.io.File /** * Contains the data of a Share from the Share API @@ -48,7 +49,7 @@ data class RemoteShare( var permissions: Int = DEFAULT_PERMISSION, var sharedDate: Long = INIT_SHARED_DATE, var expirationDate: Long = INIT_EXPIRATION_DATE_IN_MILLIS, - var isFolder: Boolean = path.endsWith(FileUtils.PATH_SEPARATOR), + var isFolder: Boolean = path.endsWith(File.separator), var userId: Long = 0, val isValid: Boolean = id > -1 ) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt index 0fa93482..a63c35a7 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt @@ -25,14 +25,11 @@ package com.owncloud.android.lib.resources.shares import android.util.Xml - import com.owncloud.android.lib.common.network.WebdavUtils -import com.owncloud.android.lib.resources.files.FileUtils - import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserException import org.xmlpull.v1.XmlPullParserFactory - +import java.io.File import java.io.IOException import java.io.InputStream import java.util.ArrayList @@ -330,9 +327,9 @@ class ShareXMLParser { private fun fixPathForFolder(share: RemoteShare) { if (share.isFolder && share.path.isNotEmpty() && - !share.path.endsWith(FileUtils.PATH_SEPARATOR) + !share.path.endsWith(File.separator) ) { - share.path = share.path + FileUtils.PATH_SEPARATOR + share.path = share.path + File.separator } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.kt index 3ab8cfa8..0e998ebc 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.kt @@ -30,8 +30,8 @@ import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod import com.owncloud.android.lib.common.network.WebdavUtils import com.owncloud.android.lib.common.operations.RemoteOperation import com.owncloud.android.lib.common.operations.RemoteOperationResult -import com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR import timber.log.Timber +import java.io.File import java.io.IOException import java.io.InputStream import java.net.URL @@ -49,7 +49,7 @@ class GetRemoteUserAvatarOperation(private val avatarDimension: Int) : RemoteOpe try { val endPoint = - client.baseUri.toString() + NON_OFFICIAL_AVATAR_PATH + client.credentials.username + PATH_SEPARATOR + avatarDimension + client.baseUri.toString() + NON_OFFICIAL_AVATAR_PATH + client.credentials.username + File.separator + avatarDimension Timber.d("avatar URI: %s", endPoint) val getMethod = GetMethod(URL(endPoint)) diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index bff10fed..6492b944 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -47,7 +47,6 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation; -import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation; import com.owncloud.android.lib.resources.files.RemoteFile; import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation; @@ -151,14 +150,14 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, } private void startRefresh() { - ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR); + ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(File.separator); refreshOperation.execute(mClient, this, mHandler); } private void startUpload() { File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; - String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); + String remotePath = File.separator + fileToUpload.getName(); String mimeType = getString(R.string.sample_file_mimetype); // Get the last modification date of the file from the file system @@ -174,7 +173,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, private void startRemoteDeletion() { File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; - String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); + String remotePath = File.separator + fileToUpload.getName(); RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); removeOperation.execute(mClient, this, mHandler); @@ -185,7 +184,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, downFolder.mkdir(); File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; - String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); + String remotePath = File.separator + fileToUpload.getName(); DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath());