Skip to content

Commit

Permalink
Merge pull request #374 from lmagyar/pr-rosaf-mime-type
Browse files Browse the repository at this point in the history
Use the built-in string constant for SAF directory MIME type
  • Loading branch information
wolpi authored Sep 7, 2024
2 parents dfe32dc + 8e02d18 commit a2a20e0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions primitiveFTPd/src/org/primftpd/filesystem/RoSafFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public abstract class RoSafFile<T> extends AbstractFile {
private boolean writable;
private boolean deletable;

private static final String MIME_TYPE_DIRECTORY = "vnd.android.document/directory";

static final int CURSOR_INDEX_NAME = 1;
static final String[] SAF_QUERY_COLUMNS = {
DocumentsContract.Document.COLUMN_DOCUMENT_ID,
Expand Down Expand Up @@ -161,7 +159,7 @@ private void initByCursor(Cursor cursor) {
exists = true;

String mime = cursor.getString(4);
isDirectory = MIME_TYPE_DIRECTORY.equals(mime);
isDirectory = DocumentsContract.Document.MIME_TYPE_DIR.equals(mime);

int flags = cursor.getInt(5);
writable = flagPresent(flags, DocumentsContract.Document.FLAG_SUPPORTS_WRITE);
Expand Down Expand Up @@ -222,7 +220,7 @@ public boolean mkdir() {
}
logger.trace("mkdir(): parent uri: '{}'", parentUri);
try {
Uri newDirUri = DocumentsContract.createDocument(contentResolver, parentUri, MIME_TYPE_DIRECTORY, name);
Uri newDirUri = DocumentsContract.createDocument(contentResolver, parentUri, DocumentsContract.Document.MIME_TYPE_DIR, name);
return newDirUri != null;
} catch (FileNotFoundException e) {
logger.error("could not create dir " + name, e);
Expand Down

0 comments on commit a2a20e0

Please sign in to comment.