upgrade to JUCE 5.4.3. Remove (probably) unused JUCE modules. Remove VST2 target (it's been end-of-life'd by Steinberg and by JUCE)
This commit is contained in:
		@ -118,9 +118,8 @@ public:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    //==============================================================================
 | 
			
		||||
    class NativeIterator
 | 
			
		||||
    struct NativeIterator
 | 
			
		||||
    {
 | 
			
		||||
    public:
 | 
			
		||||
        NativeIterator (const File& directory, const String& wildCard);
 | 
			
		||||
        ~NativeIterator();
 | 
			
		||||
 | 
			
		||||
@ -129,16 +128,11 @@ private:
 | 
			
		||||
                   Time* modTime, Time* creationTime, bool* isReadOnly);
 | 
			
		||||
 | 
			
		||||
        class Pimpl;
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        friend class DirectoryIterator;
 | 
			
		||||
        friend struct ContainerDeletePolicy<Pimpl>;
 | 
			
		||||
        std::unique_ptr<Pimpl> pimpl;
 | 
			
		||||
 | 
			
		||||
        JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeIterator)
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    friend struct ContainerDeletePolicy<NativeIterator::Pimpl>;
 | 
			
		||||
    StringArray wildCards;
 | 
			
		||||
    NativeIterator fileFinder;
 | 
			
		||||
    String wildCard, path;
 | 
			
		||||
 | 
			
		||||
@ -53,17 +53,17 @@ File& File::operator= (const File& other)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
File::File (File&& other) noexcept
 | 
			
		||||
    : fullPath (static_cast<String&&> (other.fullPath))
 | 
			
		||||
    : fullPath (std::move (other.fullPath))
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
File& File::operator= (File&& other) noexcept
 | 
			
		||||
{
 | 
			
		||||
    fullPath = static_cast<String&&> (other.fullPath);
 | 
			
		||||
    fullPath = std::move (other.fullPath);
 | 
			
		||||
    return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent;)
 | 
			
		||||
JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent{};)
 | 
			
		||||
 | 
			
		||||
//==============================================================================
 | 
			
		||||
static String removeEllipsis (const String& path)
 | 
			
		||||
@ -256,13 +256,13 @@ bool File::setExecutePermission (bool shouldBeExecutable) const
 | 
			
		||||
    return setFileExecutableInternal (shouldBeExecutable);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool File::deleteRecursively() const
 | 
			
		||||
bool File::deleteRecursively (bool followSymlinks) const
 | 
			
		||||
{
 | 
			
		||||
    bool worked = true;
 | 
			
		||||
 | 
			
		||||
    if (isDirectory())
 | 
			
		||||
    if (isDirectory() && (followSymlinks || ! isSymbolicLink()))
 | 
			
		||||
        for (auto& f : findChildFiles (File::findFilesAndDirectories, false))
 | 
			
		||||
            worked = f.deleteRecursively() && worked;
 | 
			
		||||
            worked = f.deleteRecursively (followSymlinks) && worked;
 | 
			
		||||
 | 
			
		||||
    return deleteFile() && worked;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -48,7 +48,7 @@ public:
 | 
			
		||||
 | 
			
		||||
        You can use its operator= method to point it at a proper file.
 | 
			
		||||
    */
 | 
			
		||||
    File() noexcept  {}
 | 
			
		||||
    File() = default;
 | 
			
		||||
 | 
			
		||||
    /** Creates a file from an absolute path.
 | 
			
		||||
 | 
			
		||||
@ -66,7 +66,7 @@ public:
 | 
			
		||||
    File (const File&);
 | 
			
		||||
 | 
			
		||||
    /** Destructor. */
 | 
			
		||||
    ~File() noexcept  {}
 | 
			
		||||
    ~File() = default;
 | 
			
		||||
 | 
			
		||||
    /** Sets the file based on an absolute pathname.
 | 
			
		||||
 | 
			
		||||
@ -114,7 +114,7 @@ public:
 | 
			
		||||
    bool isDirectory() const;
 | 
			
		||||
 | 
			
		||||
    /** Checks whether the path of this file represents the root of a file system,
 | 
			
		||||
        irrespective of its existance.
 | 
			
		||||
        irrespective of its existence.
 | 
			
		||||
 | 
			
		||||
        This will return true for "C:", "D:", etc on Windows and "/" on other
 | 
			
		||||
        platforms.
 | 
			
		||||
@ -457,6 +457,9 @@ public:
 | 
			
		||||
        If this file is actually a directory, it may not be deleted correctly if it
 | 
			
		||||
        contains files. See deleteRecursively() as a better way of deleting directories.
 | 
			
		||||
 | 
			
		||||
        If this file is a symlink, then the symlink will be deleted and not the target
 | 
			
		||||
        of the symlink.
 | 
			
		||||
 | 
			
		||||
        @returns    true if the file has been successfully deleted (or if it didn't exist to
 | 
			
		||||
                    begin with).
 | 
			
		||||
        @see deleteRecursively
 | 
			
		||||
@ -468,11 +471,14 @@ public:
 | 
			
		||||
        If this file is a directory, this will try to delete it and all its subfolders. If
 | 
			
		||||
        it's just a file, it will just try to delete the file.
 | 
			
		||||
 | 
			
		||||
        @returns    true if the file and all its subfolders have been successfully deleted
 | 
			
		||||
                    (or if it didn't exist to begin with).
 | 
			
		||||
 | 
			
		||||
        @param followSymlinks If true, then any symlink pointing to a directory will also
 | 
			
		||||
                              recursively delete the contents of that directory
 | 
			
		||||
        @returns              true if the file and all its subfolders have been successfully
 | 
			
		||||
                              deleted (or if it didn't exist to begin with).
 | 
			
		||||
        @see deleteFile
 | 
			
		||||
    */
 | 
			
		||||
    bool deleteRecursively() const;
 | 
			
		||||
    bool deleteRecursively (bool followSymlinks = false) const;
 | 
			
		||||
 | 
			
		||||
    /** Moves this file or folder to the trash.
 | 
			
		||||
 | 
			
		||||
@ -601,6 +607,17 @@ public:
 | 
			
		||||
    //==============================================================================
 | 
			
		||||
    /** Creates a stream to read from this file.
 | 
			
		||||
 | 
			
		||||
        Note that this is an old method, and actually it's usually best to avoid it and
 | 
			
		||||
        instead use an RAII pattern with an FileInputStream directly, e.g.
 | 
			
		||||
        @code
 | 
			
		||||
        FileInputStream input (fileToOpen);
 | 
			
		||||
 | 
			
		||||
        if (input.openedOk())
 | 
			
		||||
        {
 | 
			
		||||
            input.read (etc...
 | 
			
		||||
        }
 | 
			
		||||
        @endcode
 | 
			
		||||
 | 
			
		||||
        @returns    a stream that will read from this file (initially positioned at the
 | 
			
		||||
                    start of the file), or nullptr if the file can't be opened for some reason
 | 
			
		||||
        @see createOutputStream, loadFileAsData
 | 
			
		||||
@ -609,9 +626,30 @@ public:
 | 
			
		||||
 | 
			
		||||
    /** Creates a stream to write to this file.
 | 
			
		||||
 | 
			
		||||
        Note that this is an old method, and actually it's usually best to avoid it and
 | 
			
		||||
        instead use an RAII pattern with an FileOutputStream directly, e.g.
 | 
			
		||||
        @code
 | 
			
		||||
        FileOutputStream output (fileToOpen);
 | 
			
		||||
 | 
			
		||||
        if (output.openedOk())
 | 
			
		||||
        {
 | 
			
		||||
            output.read etc...
 | 
			
		||||
        }
 | 
			
		||||
        @endcode
 | 
			
		||||
 | 
			
		||||
        If the file exists, the stream that is returned will be positioned ready for
 | 
			
		||||
        writing at the end of the file, so you might want to use deleteFile() first
 | 
			
		||||
        to write to an empty file.
 | 
			
		||||
        writing at the end of the file. If you want to write to the start of the file,
 | 
			
		||||
        replacing the existing content, then you can do the following:
 | 
			
		||||
        @code
 | 
			
		||||
        FileOutputStream output (fileToOverwrite);
 | 
			
		||||
 | 
			
		||||
        if (output.openedOk())
 | 
			
		||||
        {
 | 
			
		||||
            output.setPosition (0);
 | 
			
		||||
            output.truncate();
 | 
			
		||||
            ...
 | 
			
		||||
        }
 | 
			
		||||
        @endcode
 | 
			
		||||
 | 
			
		||||
        @returns    a stream that will write to this file (initially positioned at the
 | 
			
		||||
                    end of the file), or nullptr if the file can't be opened for some reason
 | 
			
		||||
 | 
			
		||||
@ -76,4 +76,79 @@ bool FileInputStream::setPosition (int64 pos)
 | 
			
		||||
    return currentPosition == pos;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//==============================================================================
 | 
			
		||||
#if JUCE_UNIT_TESTS
 | 
			
		||||
 | 
			
		||||
struct FileInputStreamTests   : public UnitTest
 | 
			
		||||
{
 | 
			
		||||
    FileInputStreamTests()
 | 
			
		||||
        : UnitTest ("FileInputStream", "Streams")
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    void runTest() override
 | 
			
		||||
    {
 | 
			
		||||
        const MemoryBlock data ("abcdefghijklmnopqrstuvwxyz", 26);
 | 
			
		||||
        File f (File::createTempFile (".txt"));
 | 
			
		||||
        f.appendData (data.getData(), data.getSize());
 | 
			
		||||
        FileInputStream stream (f);
 | 
			
		||||
 | 
			
		||||
        beginTest ("Read");
 | 
			
		||||
 | 
			
		||||
        expectEquals (stream.getPosition(), (int64) 0);
 | 
			
		||||
        expectEquals (stream.getTotalLength(), (int64) data.getSize());
 | 
			
		||||
        expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
 | 
			
		||||
        expect (! stream.isExhausted());
 | 
			
		||||
 | 
			
		||||
        size_t numBytesRead = 0;
 | 
			
		||||
        MemoryBlock readBuffer (data.getSize());
 | 
			
		||||
 | 
			
		||||
        while (numBytesRead < data.getSize())
 | 
			
		||||
        {
 | 
			
		||||
            numBytesRead += (size_t) stream.read (&readBuffer[numBytesRead], 3);
 | 
			
		||||
 | 
			
		||||
            expectEquals (stream.getPosition(), (int64) numBytesRead);
 | 
			
		||||
            expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
 | 
			
		||||
            expect (stream.isExhausted() == (numBytesRead == data.getSize()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        expectEquals (stream.getPosition(), (int64) data.getSize());
 | 
			
		||||
        expectEquals (stream.getNumBytesRemaining(), (int64) 0);
 | 
			
		||||
        expect (stream.isExhausted());
 | 
			
		||||
 | 
			
		||||
        expect (readBuffer == data);
 | 
			
		||||
 | 
			
		||||
        beginTest ("Skip");
 | 
			
		||||
 | 
			
		||||
        stream.setPosition (0);
 | 
			
		||||
        expectEquals (stream.getPosition(), (int64) 0);
 | 
			
		||||
        expectEquals (stream.getTotalLength(), (int64) data.getSize());
 | 
			
		||||
        expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
 | 
			
		||||
        expect (! stream.isExhausted());
 | 
			
		||||
 | 
			
		||||
        numBytesRead = 0;
 | 
			
		||||
        const int numBytesToSkip = 5;
 | 
			
		||||
 | 
			
		||||
        while (numBytesRead < data.getSize())
 | 
			
		||||
        {
 | 
			
		||||
            stream.skipNextBytes (numBytesToSkip);
 | 
			
		||||
            numBytesRead += numBytesToSkip;
 | 
			
		||||
            numBytesRead = std::min (numBytesRead, data.getSize());
 | 
			
		||||
 | 
			
		||||
            expectEquals (stream.getPosition(), (int64) numBytesRead);
 | 
			
		||||
            expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
 | 
			
		||||
            expect (stream.isExhausted() == (numBytesRead == data.getSize()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        expectEquals (stream.getPosition(), (int64) data.getSize());
 | 
			
		||||
        expectEquals (stream.getNumBytesRemaining(), (int64) 0);
 | 
			
		||||
        expect (stream.isExhausted());
 | 
			
		||||
 | 
			
		||||
        f.deleteFile();
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static FileInputStreamTests fileInputStreamTests;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
} // namespace juce
 | 
			
		||||
 | 
			
		||||
@ -44,7 +44,7 @@ public:
 | 
			
		||||
    explicit FileInputStream (const File& fileToRead);
 | 
			
		||||
 | 
			
		||||
    /** Destructor. */
 | 
			
		||||
    ~FileInputStream();
 | 
			
		||||
    ~FileInputStream() override;
 | 
			
		||||
 | 
			
		||||
    //==============================================================================
 | 
			
		||||
    /** Returns the file that this stream is reading from. */
 | 
			
		||||
 | 
			
		||||
@ -42,9 +42,20 @@ public:
 | 
			
		||||
        does not exist), the failedToOpen() method will return true.
 | 
			
		||||
 | 
			
		||||
        If the file already exists when opened, the stream's write-position will
 | 
			
		||||
        be set to the end of the file. To overwrite an existing file,
 | 
			
		||||
        use File::deleteFile() before opening the stream, or use setPosition(0)
 | 
			
		||||
        after it's opened (although this won't truncate the file).
 | 
			
		||||
        be set to the end of the file. To overwrite an existing file, you can truncate
 | 
			
		||||
        it like this:
 | 
			
		||||
 | 
			
		||||
        @code
 | 
			
		||||
        FileOutputStream stream (file);
 | 
			
		||||
 | 
			
		||||
        if (stream.openedOk())
 | 
			
		||||
        {
 | 
			
		||||
            stream.setPosition (0);
 | 
			
		||||
            stream.truncate();
 | 
			
		||||
            ...
 | 
			
		||||
        }
 | 
			
		||||
        @endcode
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Destroying a FileOutputStream object does not force the operating system
 | 
			
		||||
        to write the buffered data to disk immediately. If this is required you
 | 
			
		||||
@ -56,7 +67,7 @@ public:
 | 
			
		||||
                      size_t bufferSizeToUse = 16384);
 | 
			
		||||
 | 
			
		||||
    /** Destructor. */
 | 
			
		||||
    ~FileOutputStream();
 | 
			
		||||
    ~FileOutputStream() override;
 | 
			
		||||
 | 
			
		||||
    //==============================================================================
 | 
			
		||||
    /** Returns the file that this stream is writing to.
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,7 @@ public:
 | 
			
		||||
 | 
			
		||||
        If the file can't be opened for some reason, the getData() method will return a null pointer.
 | 
			
		||||
 | 
			
		||||
        NOTE: the start of the actual range used may be rounded-down to a multiple of the OS's page-size,
 | 
			
		||||
        NOTE: The start of the actual range used may be rounded-down to a multiple of the OS's page-size,
 | 
			
		||||
        so do not assume that the mapped memory will begin at exactly the position you requested - always
 | 
			
		||||
        use getRange() to check the actual range that is being used.
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,8 @@ static File createTempFile (const File& parentDirectory, String name,
 | 
			
		||||
TemporaryFile::TemporaryFile (const String& suffix, const int optionFlags)
 | 
			
		||||
    : temporaryFile (createTempFile (File::getSpecialLocation (File::tempDirectory),
 | 
			
		||||
                                     "temp_" + String::toHexString (Random::getSystemRandom().nextInt()),
 | 
			
		||||
                                     suffix, optionFlags))
 | 
			
		||||
                                     suffix, optionFlags)),
 | 
			
		||||
      targetFile()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -41,12 +41,10 @@ namespace juce
 | 
			
		||||
        TemporaryFile temp (myTargetFile);
 | 
			
		||||
 | 
			
		||||
        // create a stream to the temporary file, and write some data to it...
 | 
			
		||||
        std::unique_ptr<FileOutputStream> out (temp.getFile().createOutputStream());
 | 
			
		||||
 | 
			
		||||
        if (out != nullptr)
 | 
			
		||||
        if (auto out = std::unique_ptr<FileOutputStream> (temp.getFile().createOutputStream()))
 | 
			
		||||
        {
 | 
			
		||||
            out->write ( ...etc )
 | 
			
		||||
            out = nullptr; // (deletes the stream)
 | 
			
		||||
            out.reset(); // (deletes the stream)
 | 
			
		||||
 | 
			
		||||
            // ..now we've finished writing, this will rename the temp file to
 | 
			
		||||
            // make it replace the target file we specified above.
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ public:
 | 
			
		||||
                        const String& description);
 | 
			
		||||
 | 
			
		||||
    /** Destructor. */
 | 
			
		||||
    ~WildcardFileFilter();
 | 
			
		||||
    ~WildcardFileFilter() override;
 | 
			
		||||
 | 
			
		||||
    //==============================================================================
 | 
			
		||||
    /** Returns true if the filename matches one of the patterns specified. */
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user