From eaa88b7ca0f1209ce69abac18f3d36c863c6820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garci=CC=81a=20de=20Prada?= Date: Thu, 8 Oct 2020 09:52:19 +0200 Subject: [PATCH] Map size or length property depending on mimetype --- .../android/lib/resources/files/RemoteFile.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.kt index 728866ce..afa57368 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.kt @@ -76,12 +76,24 @@ data class RemoteFile( var sharedWithSharee: Boolean = false, ) : Parcelable { + // TODO: Quotas not used. Use or remove them. init { require(!(remotePath.isEmpty() || !remotePath.startsWith(File.separator))) { "Trying to create a OCFile with a non valid remote path: $remotePath" } } + /** + * Use this to find out if this file is a folder. + * + * @return true if it is a folder + */ + val isFolder + get() = mimeType == MIME_DIR || mimeType == MIME_DIR_UNIX + companion object { + const val MIME_DIR = "DIR" + const val MIME_DIR_UNIX = "httpd/unix-directory" + fun getRemoteFileFromDav(davResource: Response, userId: String, userName: String): RemoteFile { val remotePath = getRemotePathFromUrl(davResource.href, userId) val remoteFile = RemoteFile(remotePath = remotePath, owner = userName)