OpenShot Audio Library | OpenShotAudio: juce_AndroidDocument.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_AndroidDocument.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2020 - 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//==============================================================================
38 class AndroidDocumentInfo
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//==============================================================================
169 class AndroidDocumentPermission
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
199 static std::vector<AndroidDocumentPermission> getPersistedPermissions();
200
201private:
202 URL url;
203 int64 time = 0;
204 bool read = false, write = false;
205};
206
207//==============================================================================
241 class AndroidDocument
242{
243public:
245 AndroidDocument();
246
257 static AndroidDocument fromFile (const File& filePath);
258
270 static AndroidDocument fromDocument (const URL& documentUrl);
271
294 static AndroidDocument fromTree (const URL& treeUrl);
295
296 AndroidDocument (const AndroidDocument&);
297 AndroidDocument (AndroidDocument&&) noexcept;
298
299 AndroidDocument& operator= (const AndroidDocument&);
300 AndroidDocument& operator= (AndroidDocument&&) noexcept;
301
302 ~AndroidDocument();
303
305 bool operator== (const AndroidDocument&) const;
306
308 bool operator!= (const AndroidDocument&) const;
309
311 bool deleteDocument() const;
312
319 bool renameTo (const String& newDisplayName);
320
331 AndroidDocument createChildDocumentWithTypeAndName (const String& type, const String& name) const;
332
337 AndroidDocument createChildDirectory (const String& name) const;
338
344 bool hasValue() const { return pimpl != nullptr; }
345
347 explicit operator bool() const { return hasValue(); }
348
350 std::unique_ptr<InputStream> createInputStream() const;
351
353 std::unique_ptr<OutputStream> createOutputStream() const;
354
356 URL getUrl() const;
357
359 AndroidDocumentInfo getInfo() const;
360
374 AndroidDocument copyDocumentToParentDocument (const AndroidDocument& target) const;
375
386 bool moveDocumentFromParentToParent (const AndroidDocument& currentParent,
387 const AndroidDocument& newParent);
388
390 struct NativeInfo;
391
393 NativeInfo getNativeInfo() const;
394
395private:
396 struct Utils;
397 class Pimpl;
398
399 explicit AndroidDocument (std::unique_ptr<Pimpl>);
400
401 void swap (AndroidDocument& other) noexcept { std::swap (other.pimpl, pimpl); }
402
403 std::unique_ptr<Pimpl> pimpl;
404};
405
406//==============================================================================
436 class AndroidDocumentIterator final
437{
438public:
439 using difference_type = std::ptrdiff_t;
440 using pointer = void;
441 using iterator_category = std::input_iterator_tag;
442
444 static AndroidDocumentIterator makeNonRecursive (const AndroidDocument&);
445
447 static AndroidDocumentIterator makeRecursive (const AndroidDocument&);
448
450 AndroidDocumentIterator() = default;
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
459 AndroidDocumentIterator& operator++();
460
462 AndroidDocumentIterator begin() const { return *this; }
463
465 AndroidDocumentIterator end() const { return AndroidDocumentIterator{}; }
466
467private:
468 struct Utils;
469 struct Pimpl;
470
471 explicit AndroidDocumentIterator (std::unique_ptr<Pimpl>);
472
473 std::shared_ptr<Pimpl> pimpl;
474};
475
476} // namespace juce
juce::AndroidDocumentInfo
Definition juce_AndroidDocument.h:39
juce::AndroidDocumentInfo::canWrite
bool canWrite() const
Definition juce_AndroidDocument.h:64
juce::AndroidDocumentInfo::isLastModifiedValid
bool isLastModifiedValid() const
Definition juce_AndroidDocument.h:109
juce::AndroidDocumentInfo::getType
String getType() const
Definition juce_AndroidDocument.h:99
juce::AndroidDocumentInfo::canCreateChildren
bool canCreateChildren() const
Definition juce_AndroidDocument.h:77
juce::AndroidDocumentInfo::getLastModified
int64 getLastModified() const
Definition juce_AndroidDocument.h:106
juce::AndroidDocumentInfo::exists
bool exists() const
Definition juce_AndroidDocument.h:44
juce::AndroidDocumentInfo::canRename
bool canRename() const
Definition juce_AndroidDocument.h:80
juce::AndroidDocumentInfo::canDelete
bool canDelete() const
Definition juce_AndroidDocument.h:74
juce::AndroidDocumentInfo::getName
String getName() const
Definition juce_AndroidDocument.h:96
juce::AndroidDocumentInfo::isVirtual
bool isVirtual() const
Definition juce_AndroidDocument.h:89
juce::AndroidDocumentInfo::canRead
bool canRead() const
Definition juce_AndroidDocument.h:57
juce::AndroidDocumentInfo::canMove
bool canMove() const
Definition juce_AndroidDocument.h:86
juce::AndroidDocumentInfo::isFile
bool isFile() const
Definition juce_AndroidDocument.h:50
juce::AndroidDocumentInfo::getSizeInBytes
int64 getSizeInBytes() const
Definition juce_AndroidDocument.h:116
juce::AndroidDocumentInfo::isSizeInBytesValid
bool isSizeInBytesValid() const
Definition juce_AndroidDocument.h:119
juce::AndroidDocumentInfo::isDirectory
bool isDirectory() const
juce::AndroidDocumentInfo::canCopy
bool canCopy() const
Definition juce_AndroidDocument.h:83
juce::AndroidDocumentIterator
Definition juce_AndroidDocument.h:437
juce::AndroidDocumentIterator::operator*
AndroidDocument operator*() const
juce::AndroidDocumentIterator::begin
AndroidDocumentIterator begin() const
Definition juce_AndroidDocument.h:462
juce::AndroidDocumentIterator::operator++
AndroidDocumentIterator & operator++()
juce::AndroidDocumentIterator::end
AndroidDocumentIterator end() const
Definition juce_AndroidDocument.h:465
juce::AndroidDocumentIterator::makeNonRecursive
static AndroidDocumentIterator makeNonRecursive(const AndroidDocument &)
juce::AndroidDocumentIterator::makeRecursive
static AndroidDocumentIterator makeRecursive(const AndroidDocument &)
juce::AndroidDocumentIterator::AndroidDocumentIterator
AndroidDocumentIterator()=default
juce::AndroidDocumentPermission
Definition juce_AndroidDocument.h:170
juce::AndroidDocumentPermission::releasePersistentReadWriteAccess
static void releasePersistentReadWriteAccess(const URL &)
juce::AndroidDocumentPermission::takePersistentReadWriteAccess
static void takePersistentReadWriteAccess(const URL &)
juce::AndroidDocumentPermission::isReadPermission
bool isReadPermission() const
Definition juce_AndroidDocument.h:179
juce::AndroidDocumentPermission::getUrl
URL getUrl() const
Definition juce_AndroidDocument.h:173
juce::AndroidDocumentPermission::getPersistedPermissions
static std::vector< AndroidDocumentPermission > getPersistedPermissions()
juce::AndroidDocumentPermission::isWritePermission
bool isWritePermission() const
Definition juce_AndroidDocument.h:182
juce::AndroidDocumentPermission::getPersistedTime
int64 getPersistedTime() const
Definition juce_AndroidDocument.h:176
juce::AndroidDocument
Definition juce_AndroidDocument.h:242
juce::AndroidDocument::moveDocumentFromParentToParent
bool moveDocumentFromParentToParent(const AndroidDocument &currentParent, const AndroidDocument &newParent)
juce::AndroidDocument::AndroidDocument
AndroidDocument()
juce::AndroidDocument::fromFile
static AndroidDocument fromFile(const File &filePath)
juce::AndroidDocument::getInfo
AndroidDocumentInfo getInfo() const
juce::AndroidDocument::fromDocument
static AndroidDocument fromDocument(const URL &documentUrl)
juce::AndroidDocument::createInputStream
std::unique_ptr< InputStream > createInputStream() const
juce::AndroidDocument::createChildDirectory
AndroidDocument createChildDirectory(const String &name) const
juce::AndroidDocument::copyDocumentToParentDocument
AndroidDocument copyDocumentToParentDocument(const AndroidDocument &target) const
juce::AndroidDocument::renameTo
bool renameTo(const String &newDisplayName)
juce::AndroidDocument::deleteDocument
bool deleteDocument() const
juce::AndroidDocument::hasValue
bool hasValue() const
Definition juce_AndroidDocument.h:344
juce::AndroidDocument::getNativeInfo
NativeInfo getNativeInfo() const
juce::AndroidDocument::createChildDocumentWithTypeAndName
AndroidDocument createChildDocumentWithTypeAndName(const String &type, const String &name) const
juce::AndroidDocument::fromTree
static AndroidDocument fromTree(const URL &treeUrl)
juce::AndroidDocument::getUrl
URL getUrl() const
juce::AndroidDocument::createOutputStream
std::unique_ptr< OutputStream > createOutputStream() const
juce::File
Definition juce_File.h:45
juce::String
Definition juce_String.h:53
juce::String::isNotEmpty
bool isNotEmpty() const noexcept
Definition juce_String.h:316
juce::URL
Definition juce_URL.h:38