Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 114a722

Browse files
committed
Use constants instead of hardcoded values for dir mimetypes
1 parent 6253f1e commit 114a722

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
public class FileUtils {
3232
public static final String FINAL_CHUNKS_FILE = ".file";
33+
public static final String MIME_DIR = "DIR";
34+
public static final String MIME_DIR_UNIX = "httpd/unix-directory";
3335

3436
static String getParentPath(String remotePath) {
3537
String parentPath = new File(remotePath).getParent();

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@
2929

3030
import at.bitfire.dav4jvm.Property;
3131
import at.bitfire.dav4jvm.Response;
32-
import at.bitfire.dav4jvm.property.*;
32+
import at.bitfire.dav4jvm.property.CreationDate;
33+
import at.bitfire.dav4jvm.property.GetContentLength;
34+
import at.bitfire.dav4jvm.property.GetContentType;
35+
import at.bitfire.dav4jvm.property.GetETag;
36+
import at.bitfire.dav4jvm.property.GetLastModified;
37+
import at.bitfire.dav4jvm.property.OCId;
38+
import at.bitfire.dav4jvm.property.OCPermissions;
39+
import at.bitfire.dav4jvm.property.OCPrivatelink;
40+
import at.bitfire.dav4jvm.property.OCSize;
41+
import at.bitfire.dav4jvm.property.QuotaAvailableBytes;
42+
import at.bitfire.dav4jvm.property.QuotaUsedBytes;
3343

3444
import java.io.File;
3545
import java.io.Serializable;
@@ -83,7 +93,8 @@ public RemoteFile() {
8393
/**
8494
* Create new {@link RemoteFile} with given path.
8595
* <p>
86-
* The path received must be URL-decoded. Path separator must be File.separator, and it must be the first character in 'path'.
96+
* The path received must be URL-decoded. Path separator must be File.separator, and it must be the first
97+
* character in 'path'.
8798
*
8899
* @param path The remote path of the file.
89100
*/
@@ -95,7 +106,7 @@ public RemoteFile(String path) {
95106
mRemotePath = path;
96107
mCreationTimestamp = 0;
97108
mLength = 0;
98-
mMimeType = "DIR";
109+
mMimeType = FileUtils.MIME_DIR;
99110
mQuotaUsedBytes = BigDecimal.ZERO;
100111
mQuotaAvailableBytes = BigDecimal.ZERO;
101112
mPrivateLink = null;
@@ -154,6 +165,14 @@ protected RemoteFile(Parcel source) {
154165
readFromParcel(source);
155166
}
156167

168+
/**
169+
* Use this to find out if this file is a folder.
170+
*
171+
* @return true if it is a folder
172+
*/
173+
public boolean isFolder() {
174+
return mMimeType != null && (mMimeType.equals(FileUtils.MIME_DIR) || mMimeType.equals(FileUtils.MIME_DIR_UNIX));
175+
}
157176

158177
/**
159178
* Getters and Setters

0 commit comments

Comments
 (0)