Loading...
Searching...
No Matches
juce_MemoryMappedFile.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API MemoryMappedFile
{
public:
enum AccessMode
{
readOnly,
readWrite
};
MemoryMappedFile (const File& file, AccessMode mode, bool exclusive = false);
MemoryMappedFile (const File& file,
const Range<int64>& fileRange,
AccessMode mode,
bool exclusive = false);
~MemoryMappedFile();
void* getData() const noexcept { return address; }
size_t getSize() const noexcept { return (size_t) range.getLength(); }
Range<int64> getRange() const noexcept { return range; }
private:
//==============================================================================
void* address = nullptr;
Range<int64> range;
#if JUCE_WINDOWS
void* fileHandle = nullptr;
#else
int fileHandle = 0;
#endif
void openInternal (const File&, AccessMode, bool);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedFile)
};
} // namespace juce
juce::File
Definition juce_File.h:45
juce::MemoryMappedFile
Definition juce_MemoryMappedFile.h:33
juce::MemoryMappedFile::getRange
Range< int64 > getRange() const noexcept
Definition juce_MemoryMappedFile.h:97
juce::MemoryMappedFile::~MemoryMappedFile
~MemoryMappedFile()
juce::MemoryMappedFile::getData
void * getData() const noexcept
Definition juce_MemoryMappedFile.h:89
juce::MemoryMappedFile::MemoryMappedFile
MemoryMappedFile(const File &file, AccessMode mode, bool exclusive=false)
Definition juce_File.cpp:1031
juce::MemoryMappedFile::getSize
size_t getSize() const noexcept
Definition juce_MemoryMappedFile.h:94
juce::MemoryMappedFile::AccessMode
AccessMode
Definition juce_MemoryMappedFile.h:37
juce::MemoryMappedFile::readWrite
@ readWrite
Definition juce_MemoryMappedFile.h:39
juce::MemoryMappedFile::readOnly
@ readOnly
Definition juce_MemoryMappedFile.h:38
juce::Range
Definition juce_Range.h:40