openshot-audio  0.1.7
juce_FileOutputStream.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_FILEOUTPUTSTREAM_H_INCLUDED
30 #define JUCE_FILEOUTPUTSTREAM_H_INCLUDED
31 
32 
33 //==============================================================================
40 {
41 public:
42  //==============================================================================
56  FileOutputStream (const File& fileToWriteTo,
57  size_t bufferSizeToUse = 16384);
58 
61 
62  //==============================================================================
65  const File& getFile() const { return file; }
66 
71  const Result& getStatus() const noexcept { return status; }
72 
76  bool failedToOpen() const noexcept { return status.failed(); }
77 
81  bool openedOk() const noexcept { return status.wasOk(); }
82 
87  Result truncate();
88 
89  //==============================================================================
90  void flush() override;
91  int64 getPosition() override;
92  bool setPosition (int64) override;
93  bool write (const void*, size_t) override;
94  bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override;
95 
96 
97 private:
98  //==============================================================================
99  File file;
100  void* fileHandle;
101  Result status;
102  int64 currentPosition;
103  size_t bufferSize, bytesInBuffer;
104  HeapBlock <char> buffer;
105 
106  void openHandle();
107  void closeHandle();
108  void flushInternal();
109  bool flushBuffer();
110  int64 setPositionInternal (int64);
111  ssize_t writeInternal (const void*, size_t);
112 
114 };
115 
116 #endif // JUCE_FILEOUTPUTSTREAM_H_INCLUDED
OutputStream::flush
virtual void flush()=0
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
FileOutputStream::getFile
const File & getFile() const
Definition: juce_FileOutputStream.h:65
FileOutputStream::getStatus
const Result & getStatus() const noexcept
Definition: juce_FileOutputStream.h:71
JUCE_API
#define JUCE_API
Definition: juce_StandardHeader.h:139
FileOutputStream::openedOk
bool openedOk() const noexcept
Definition: juce_FileOutputStream.h:81
FileOutputStream::failedToOpen
bool failedToOpen() const noexcept
Definition: juce_FileOutputStream.h:76
noexcept
#define noexcept
Definition: juce_CompilerSupport.h:141
File
Definition: juce_File.h:45
OutputStream::setPosition
virtual bool setPosition(int64 newPosition)=0
Result
Definition: juce_Result.h:61
uint8
unsigned char uint8
Definition: juce_MathsFunctions.h:43
OutputStream
Definition: juce_OutputStream.h:42
OutputStream::getPosition
virtual int64 getPosition()=0
HeapBlock< char >
FileOutputStream
Definition: juce_FileOutputStream.h:39
int64
long long int64
Definition: juce_MathsFunctions.h:60
OutputStream::write
virtual bool write(const void *dataToWrite, size_t numberOfBytes)=0
OutputStream::writeRepeatedByte
virtual bool writeRepeatedByte(uint8 byte, size_t numTimesToRepeat)
Definition: juce_OutputStream.cpp:80