JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_AndroidDocument.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
39{
40public:
41 AndroidDocumentInfo() = default;
42
44 bool exists() const { return isJuceFlagSet (flagExists); }
45
47 bool isDirectory() const;
48
50 bool isFile() const { return type.isNotEmpty() && ! isDirectory(); }
51
57 bool canRead() const { return isJuceFlagSet (flagHasReadPermission) && type.isNotEmpty(); }
58
64 bool canWrite() const
65 {
66 return isJuceFlagSet (flagHasWritePermission)
67 && type.isNotEmpty()
68 && (isNativeFlagSet (flagSupportsWrite)
69 || isNativeFlagSet (flagSupportsDelete)
70 || isNativeFlagSet (flagDirSupportsCreate));
71 }
72
74 bool canDelete() const { return isNativeFlagSet (flagSupportsDelete); }
75
77 bool canCreateChildren() const { return isNativeFlagSet (flagDirSupportsCreate); }
78
80 bool canRename() const { return isNativeFlagSet (flagSupportsRename); }
81
83 bool canCopy() const { return isNativeFlagSet (flagSupportsCopy); }
84
86 bool canMove() const { return isNativeFlagSet (flagSupportsMove); }
87
89 bool isVirtual() const { return isNativeFlagSet (flagVirtualDocument); }
90
96 String getName() const { return name; }
97
99 String getType() const { return isDirectory() ? String{} : type; }
100
106 int64 getLastModified() const { return isJuceFlagSet (flagValidModified) ? lastModified : 0; }
107
109 bool isLastModifiedValid() const { return isJuceFlagSet (flagValidModified); }
110
116 int64 getSizeInBytes() const { return isJuceFlagSet (flagValidSize) ? sizeInBytes : 0; }
117
119 bool isSizeInBytesValid() const { return isJuceFlagSet (flagValidSize); }
120
122 class Args;
123
124private:
125 explicit AndroidDocumentInfo (Args);
126
127 bool isNativeFlagSet (int flag) const { return (nativeFlags & flag) != 0; }
128 bool isJuceFlagSet (int flag) const { return (juceFlags & flag) != 0; }
129
130 /* Native Android flags that might be set in the COLUMN_FLAGS for a particular document */
131 enum
132 {
133 flagSupportsWrite = 0x0002,
134 flagSupportsDelete = 0x0004,
135 flagDirSupportsCreate = 0x0008,
136 flagSupportsRename = 0x0040,
137 flagSupportsCopy = 0x0080,
138 flagSupportsMove = 0x0100,
139 flagVirtualDocument = 0x0200,
140 };
141
142 /* Flags for other binary properties that aren't exposed in COLUMN_FLAGS */
143 enum
144 {
145 flagExists = 1 << 0,
146 flagValidModified = 1 << 1,
147 flagValidSize = 1 << 2,
148 flagHasReadPermission = 1 << 3,
149 flagHasWritePermission = 1 << 4,
150 };
151
152 String name;
153 String type;
154 int64 lastModified = 0;
155 int64 sizeInBytes = 0;
156 int nativeFlags = 0, juceFlags = 0;
157};
158
159//==============================================================================
170{
171public:
173 URL getUrl() const { return url; }
174
176 int64 getPersistedTime() const { return time; }
177
179 bool isReadPermission() const { return read; }
180
182 bool isWritePermission() const { return write; }
183
191 static void takePersistentReadWriteAccess (const URL&);
192
194 static void releasePersistentReadWriteAccess (const URL&);
195
200
201private:
202 URL url;
203 int64 time = 0;
204 bool read = false, write = false;
205};
206
207//==============================================================================
242{
243public:
246
257 static AndroidDocument fromFile (const File& filePath);
258
271
294 static AndroidDocument fromTree (const URL& treeUrl);
295
297 AndroidDocument (AndroidDocument&&) noexcept;
298
301
303
306
309
311 bool deleteDocument() const;
312
320
332
338
344 bool hasValue() const { return pimpl != nullptr; }
345
347 explicit operator bool() const { return hasValue(); }
348
351
354
356 URL getUrl() const;
357
360
375
388
390 struct NativeInfo;
391
393 NativeInfo getNativeInfo() const;
394
395private:
396 struct Utils;
397 class Pimpl;
398
400
401 void swap (AndroidDocument& other) noexcept { std::swap (other.pimpl, pimpl); }
402
404};
405
406//==============================================================================
437{
438public:
440 using pointer = void;
442
445
448
451
452 bool operator== (const AndroidDocumentIterator& other) const noexcept { return pimpl == nullptr && other.pimpl == nullptr; }
453 bool operator!= (const AndroidDocumentIterator& other) const noexcept { return ! operator== (other); }
454
456 AndroidDocument operator*() const;
457
460
462 AndroidDocumentIterator begin() const { return *this; }
463
466
467private:
468 struct Utils;
469 struct Pimpl;
470
472
474};
475
476} // namespace juce
Some information about a document.
bool canWrite() const
True if this is a document that can be written, or a directory that can be modified.
bool isLastModifiedValid() const
True if the filesystem provided a modification time.
String getType() const
The MIME type of this document.
bool canCreateChildren() const
True if this is a directory and adding child documents is supported.
int64 getLastModified() const
Timestamp when a document was last modified, in milliseconds since January 1, 1970 00:00:00....
bool exists() const
True if this file really exists.
bool canRename() const
True if this document can be renamed.
bool canDelete() const
True if this document can be removed completely from the filesystem.
String getName() const
The user-facing name.
bool isVirtual() const
True if this document isn't a physical file on storage.
bool canRead() const
True if this process has permission to read this file.
bool canMove() const
True if this document can be moved.
bool isFile() const
True if this is a file rather than a directory.
int64 getSizeInBytes() const
The size of the document in bytes, if known.
bool isSizeInBytesValid() const
True if the filesystem provided a size in bytes.
bool isDirectory() const
True if this is a directory rather than a file.
bool canCopy() const
True if this document can be copied.
An iterator that visits child documents in a directory.
AndroidDocument operator*() const
Returns the document to which this iterator points.
AndroidDocumentIterator begin() const
Allows this iterator to be used directly in a range-for.
static AndroidDocumentIterator makeRecursive(const AndroidDocument &)
Create an iterator that will visit each item in this directory, and all nested directories.
AndroidDocumentIterator & operator++()
Moves this iterator to the next position.
static AndroidDocumentIterator makeNonRecursive(const AndroidDocument &)
Create an iterator that will visit each item in this directory.
AndroidDocumentIterator end() const
Allows this iterator to be used directly in a range-for.
AndroidDocumentIterator()=default
Creates an end/sentinel iterator.
Represents a permission granted to an application to read and/or write to a particular document or tr...
bool isReadPermission() const
True if the permission allows read access.
URL getUrl() const
The url of the document with persisted permissions.
static void takePersistentReadWriteAccess(const URL &)
Gives your app access to a particular document or tree, even after the device is rebooted.
static void releasePersistentReadWriteAccess(const URL &)
Revokes persistent access to a document or tree.
bool isWritePermission() const
True if the permission allows write access.
int64 getPersistedTime() const
The time when the permissions were persisted, in milliseconds since January 1, 1970 00:00:00....
static std::vector< AndroidDocumentPermission > getPersistedPermissions()
Returns all of the permissions that have previously been granted to the app, via takePersistentReadWr...
Provides access to a document on Android devices.
static AndroidDocument fromFile(const File &filePath)
Create an AndroidDocument representing a file or directory at a particular path.
bool moveDocumentFromParentToParent(const AndroidDocument &currentParent, const AndroidDocument &newParent)
Experimental: Attempts to move this document from one parent to another, and returns true on success.
AndroidDocument()
Create a null document.
AndroidDocumentInfo getInfo() const
Fetches information about this document.
std::unique_ptr< InputStream > createInputStream() const
Creates a stream for reading from this document.
static AndroidDocument fromTree(const URL &treeUrl)
Create an AndroidDocument representing the root of a tree of files.
AndroidDocument createChildDirectory(const String &name) const
Attempts to create a new nested directory with a particular name.
AndroidDocument copyDocumentToParentDocument(const AndroidDocument &target) const
Experimental: Attempts to copy this document to a new parent, and returns an AndroidDocument represen...
bool renameTo(const String &newDisplayName)
Renames the document, and returns true on success.
bool deleteDocument() const
Attempts to delete this document, and returns true on success.
bool hasValue() const
True if this object actually refers to a document.
AndroidDocument createChildDocumentWithTypeAndName(const String &type, const String &name) const
Attempts to create a new nested document with a particular type and name.
static AndroidDocument fromDocument(const URL &documentUrl)
Create an AndroidDocument representing a single document.
URL getUrl() const
Returns the content URL describing this document.
std::unique_ptr< OutputStream > createOutputStream() const
Creates a stream for writing to this document.
Represents a local file or directory.
Definition juce_File.h:45
The JUCE String class!
Definition juce_String.h:53
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
Represents a URL and has a bunch of useful functions to manipulate it.
Definition juce_URL.h:38
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
long long int64
A platform-independent 64-bit integer type.
T swap(T... args)