mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +00:00
Internal refactoring of file functions and win32 com objects.
This commit is contained in:
parent
87175e988b
commit
21006fbd0a
27 changed files with 593 additions and 1285 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -2860,6 +2860,8 @@ protected:
|
|||
#endif // __JUCE_INPUTSTREAM_JUCEHEADER__
|
||||
/*** End of inlined file: juce_InputStream.h ***/
|
||||
|
||||
class File;
|
||||
|
||||
class JUCE_API OutputStream
|
||||
{
|
||||
protected:
|
||||
|
|
@ -2910,7 +2912,7 @@ public:
|
|||
bool asUnicode,
|
||||
bool writeUnicodeHeaderBytes);
|
||||
|
||||
virtual int writeFromInputStream (InputStream& source, int maxNumBytesToWrite);
|
||||
virtual int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite);
|
||||
|
||||
juce_UseDebuggingNewOperator
|
||||
};
|
||||
|
|
@ -2923,6 +2925,10 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, char character);
|
|||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* text);
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data);
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const File& fileToRead);
|
||||
|
||||
#endif // __JUCE_OUTPUTSTREAM_JUCEHEADER__
|
||||
/*** End of inlined file: juce_OutputStream.h ***/
|
||||
|
||||
|
|
@ -4544,8 +4550,15 @@ private:
|
|||
const String getPathUpToLastSlash() const;
|
||||
|
||||
void createDirectoryInternal (const String& fileName) const;
|
||||
bool copyInternal (const File& dest) const;
|
||||
bool moveInternal (const File& dest) const;
|
||||
bool setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 creationTime) const;
|
||||
void getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const;
|
||||
bool setFileReadOnlyInternal (bool shouldBeReadOnly) const;
|
||||
|
||||
static const String parseAbsolutePath (const String& path);
|
||||
static bool fileTypeMatches (int whatToLookFor, bool isDir, bool isHidden);
|
||||
|
||||
};
|
||||
|
||||
#endif // __JUCE_FILE_JUCEHEADER__
|
||||
|
|
@ -7049,6 +7062,8 @@ public:
|
|||
|
||||
static void beep();
|
||||
|
||||
static bool openDocument (const String& documentURL, const String& parameters);
|
||||
|
||||
static bool launchEmailWithAttachments (const String& targetEmailAddress,
|
||||
const String& emailSubject,
|
||||
const String& bodyText,
|
||||
|
|
@ -14276,7 +14291,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
VoidArray knownFormats;
|
||||
OwnedArray<AudioFormat> knownFormats;
|
||||
int defaultFormatIndex;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat,
|
|||
#endif
|
||||
|
||||
if (makeThisTheDefaultFormat)
|
||||
defaultFormatIndex = knownFormats.size();
|
||||
defaultFormatIndex = getNumKnownFormats();
|
||||
|
||||
knownFormats.add (newFormat);
|
||||
}
|
||||
|
|
@ -97,9 +97,6 @@ void AudioFormatManager::registerBasicFormats()
|
|||
|
||||
void AudioFormatManager::clearFormats()
|
||||
{
|
||||
for (int i = getNumKnownFormats(); --i >= 0;)
|
||||
delete getKnownFormat(i);
|
||||
|
||||
knownFormats.clear();
|
||||
defaultFormatIndex = 0;
|
||||
}
|
||||
|
|
@ -111,7 +108,7 @@ int AudioFormatManager::getNumKnownFormats() const
|
|||
|
||||
AudioFormat* AudioFormatManager::getKnownFormat (const int index) const
|
||||
{
|
||||
return (AudioFormat*) knownFormats [index];
|
||||
return knownFormats [index];
|
||||
}
|
||||
|
||||
AudioFormat* AudioFormatManager::getDefaultFormat() const
|
||||
|
|
@ -165,7 +162,7 @@ AudioFormatReader* AudioFormatManager::createReaderFor (const File& file)
|
|||
{
|
||||
// you need to actually register some formats before the manager can
|
||||
// use them to open a file!
|
||||
jassert (knownFormats.size() > 0);
|
||||
jassert (getNumKnownFormats() > 0);
|
||||
|
||||
for (int i = 0; i < getNumKnownFormats(); ++i)
|
||||
{
|
||||
|
|
@ -192,7 +189,7 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileSt
|
|||
{
|
||||
// you need to actually register some formats before the manager can
|
||||
// use them to open a file!
|
||||
jassert (knownFormats.size() > 0);
|
||||
jassert (getNumKnownFormats() > 0);
|
||||
|
||||
ScopedPointer <InputStream> in (audioFileStream);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "juce_AudioFormat.h"
|
||||
#include "../../core/juce_Singleton.h"
|
||||
#include "../../containers/juce_VoidArray.h"
|
||||
#include "../../containers/juce_OwnedArray.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -137,7 +137,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
VoidArray knownFormats;
|
||||
OwnedArray<AudioFormat> knownFormats;
|
||||
int defaultFormatIndex;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public:
|
|||
/** Plays the operating system's default alert 'beep' sound. */
|
||||
static void beep();
|
||||
|
||||
/** Tries to launch the system's default reader for a given file or URL. */
|
||||
static bool openDocument (const String& documentURL, const String& parameters);
|
||||
|
||||
/** Tries to launch the system's default email app to let the user create an email.
|
||||
*/
|
||||
static bool launchEmailWithAttachments (const String& targetEmailAddress,
|
||||
const String& emailSubject,
|
||||
const String& bodyText,
|
||||
|
|
|
|||
|
|
@ -229,7 +229,6 @@ public:
|
|||
for (int i = rowComponentItems.size(); --i >= 0;)
|
||||
{
|
||||
Component* const comp = rowComponents.getUnchecked(i);
|
||||
|
||||
bool keep = false;
|
||||
|
||||
if (isParentOf (comp))
|
||||
|
|
|
|||
|
|
@ -37,22 +37,10 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_TemporaryFile.h"
|
||||
#include "../../core/juce_SystemStats.h"
|
||||
#include "../../core/juce_Random.h"
|
||||
#include "../../core/juce_PlatformUtilities.h"
|
||||
#include "../../containers/juce_ScopedPointer.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
bool juce_canWriteToFile (const String& fileName);
|
||||
bool juce_setFileReadOnly (const String& fileName, bool isReadOnly);
|
||||
void juce_getFileTimes (const String& fileName, int64& modificationTime, int64& accessTime, int64& creationTime);
|
||||
bool juce_setFileTimes (const String& fileName, int64 modificationTime, int64 accessTime, int64 creationTime);
|
||||
bool juce_copyFile (const String& source, const String& dest);
|
||||
bool juce_moveFile (const String& source, const String& dest);
|
||||
bool juce_launchFile (const String& fileName, const String& parameters);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
const File File::nonexistent;
|
||||
|
||||
//==============================================================================
|
||||
File::File (const String& fullPathName)
|
||||
: fullPath (parseAbsolutePath (fullPathName))
|
||||
|
|
@ -86,6 +74,9 @@ File& File::operator= (const File& other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
const File File::nonexistent;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
const String File::parseAbsolutePath (const String& p)
|
||||
{
|
||||
|
|
@ -218,24 +209,6 @@ bool File::operator> (const File& other) const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool File::hasWriteAccess() const
|
||||
{
|
||||
if (exists())
|
||||
return juce_canWriteToFile (fullPath);
|
||||
|
||||
#if ! JUCE_WINDOWS
|
||||
else if ((! isDirectory()) && fullPath.containsChar (separator))
|
||||
return getParentDirectory().hasWriteAccess();
|
||||
else
|
||||
return false;
|
||||
#else
|
||||
// on windows, it seems that even read-only directories can still be written into,
|
||||
// so checking the parent directory's permissions would return the wrong result..
|
||||
else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::setReadOnly (const bool shouldBeReadOnly,
|
||||
const bool applyRecursively) const
|
||||
{
|
||||
|
|
@ -250,7 +223,7 @@ bool File::setReadOnly (const bool shouldBeReadOnly,
|
|||
worked = subFiles.getReference(i).setReadOnly (shouldBeReadOnly, true) && worked;
|
||||
}
|
||||
|
||||
return juce_setFileReadOnly (fullPath, shouldBeReadOnly) && worked;
|
||||
return setFileReadOnlyInternal (shouldBeReadOnly) && worked;
|
||||
}
|
||||
|
||||
bool File::deleteRecursively() const
|
||||
|
|
@ -280,18 +253,13 @@ bool File::moveFileTo (const File& newFile) const
|
|||
if (! newFile.deleteFile())
|
||||
return false;
|
||||
|
||||
return juce_moveFile (fullPath, newFile.fullPath);
|
||||
return moveInternal (newFile);
|
||||
}
|
||||
|
||||
bool File::copyFileTo (const File& newFile) const
|
||||
{
|
||||
if (*this == newFile)
|
||||
return true;
|
||||
|
||||
if (! newFile.deleteFile())
|
||||
return false;
|
||||
|
||||
return juce_copyFile (fullPath, newFile.fullPath);
|
||||
return (*this == newFile)
|
||||
|| (exists() && newFile.deleteFile() && copyInternal (newFile));
|
||||
}
|
||||
|
||||
bool File::copyDirectoryTo (const File& newDirectory) const
|
||||
|
|
@ -519,38 +487,27 @@ bool File::createDirectory() const
|
|||
const Time File::getCreationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
juce_getFileTimes (fullPath, m, a, c);
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (c);
|
||||
}
|
||||
|
||||
bool File::setCreationTime (const Time& t) const
|
||||
{
|
||||
return juce_setFileTimes (fullPath, 0, 0, t.toMilliseconds());
|
||||
}
|
||||
|
||||
const Time File::getLastModificationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
juce_getFileTimes (fullPath, m, a, c);
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (m);
|
||||
}
|
||||
|
||||
bool File::setLastModificationTime (const Time& t) const
|
||||
{
|
||||
return juce_setFileTimes (fullPath, t.toMilliseconds(), 0, 0);
|
||||
}
|
||||
|
||||
const Time File::getLastAccessTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
juce_getFileTimes (fullPath, m, a, c);
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (a);
|
||||
}
|
||||
|
||||
bool File::setLastAccessTime (const Time& t) const
|
||||
{
|
||||
return juce_setFileTimes (fullPath, 0, t.toMilliseconds(), 0);
|
||||
}
|
||||
bool File::setLastModificationTime (const Time& t) const { return setFileTimesInternal (t.toMilliseconds(), 0, 0); }
|
||||
bool File::setLastAccessTime (const Time& t) const { return setFileTimesInternal (0, t.toMilliseconds(), 0); }
|
||||
bool File::setCreationTime (const Time& t) const { return setFileTimesInternal (0, 0, t.toMilliseconds()); }
|
||||
|
||||
//==============================================================================
|
||||
bool File::loadFileAsData (MemoryBlock& destBlock) const
|
||||
|
|
@ -793,7 +750,7 @@ const File File::withFileExtension (const String& newExtension) const
|
|||
//==============================================================================
|
||||
bool File::startAsProcess (const String& parameters) const
|
||||
{
|
||||
return exists() && juce_launchFile (fullPath, parameters);
|
||||
return exists() && PlatformUtilities::openDocument (fullPath, parameters);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -924,8 +924,15 @@ private:
|
|||
const String getPathUpToLastSlash() const;
|
||||
|
||||
void createDirectoryInternal (const String& fileName) const;
|
||||
bool copyInternal (const File& dest) const;
|
||||
bool moveInternal (const File& dest) const;
|
||||
bool setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 creationTime) const;
|
||||
void getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const;
|
||||
bool setFileReadOnlyInternal (bool shouldBeReadOnly) const;
|
||||
|
||||
static const String parseAbsolutePath (const String& path);
|
||||
static bool fileTypeMatches (int whatToLookFor, bool isDir, bool isHidden);
|
||||
|
||||
};
|
||||
|
||||
#endif // __JUCE_FILE_JUCEHEADER__
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
#include "juce_URL.h"
|
||||
#include "../../core/juce_Random.h"
|
||||
#include "../../core/juce_PlatformUtilities.h"
|
||||
#include "../../text/juce_XmlDocument.h"
|
||||
#include "../../io/streams/juce_MemoryOutputStream.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -282,21 +284,11 @@ public:
|
|||
juce_closeInternetFile (handle);
|
||||
}
|
||||
|
||||
bool isError() const
|
||||
{
|
||||
return handle == 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
int64 getTotalLength()
|
||||
{
|
||||
return juce_getInternetFileContentLength (handle);
|
||||
}
|
||||
|
||||
bool isExhausted()
|
||||
{
|
||||
return finished;
|
||||
}
|
||||
bool isError() const { return handle == 0; }
|
||||
int64 getTotalLength() { return juce_getInternetFileContentLength (handle); }
|
||||
bool isExhausted() { return finished; }
|
||||
int64 getPosition() { return position; }
|
||||
|
||||
int read (void* dest, int bytes)
|
||||
{
|
||||
|
|
@ -316,11 +308,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
int64 getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
bool setPosition (int64 wantedPos)
|
||||
{
|
||||
if (wantedPos != position)
|
||||
|
|
@ -370,64 +357,52 @@ private:
|
|||
|
||||
void createHeadersAndPostData (const URL& url)
|
||||
{
|
||||
MemoryOutputStream data (256, 256, &postData);
|
||||
|
||||
if (url.getFilesToUpload().size() > 0)
|
||||
{
|
||||
// need to upload some files, so do it as multi-part...
|
||||
String boundary (String::toHexString (Random::getSystemRandom().nextInt64()));
|
||||
const String boundary (String::toHexString (Random::getSystemRandom().nextInt64()));
|
||||
|
||||
headers << "Content-Type: multipart/form-data; boundary=" << boundary << "\r\n";
|
||||
|
||||
appendUTF8ToPostData ("--" + boundary);
|
||||
data << "--" << boundary;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < url.getParameters().size(); ++i)
|
||||
{
|
||||
String s;
|
||||
s << "\r\nContent-Disposition: form-data; name=\""
|
||||
<< url.getParameters().getAllKeys() [i]
|
||||
<< "\"\r\n\r\n"
|
||||
<< url.getParameters().getAllValues() [i]
|
||||
<< "\r\n--"
|
||||
<< boundary;
|
||||
|
||||
appendUTF8ToPostData (s);
|
||||
data << "\r\nContent-Disposition: form-data; name=\""
|
||||
<< url.getParameters().getAllKeys() [i]
|
||||
<< "\"\r\n\r\n"
|
||||
<< url.getParameters().getAllValues() [i]
|
||||
<< "\r\n--"
|
||||
<< boundary;
|
||||
}
|
||||
|
||||
for (i = 0; i < url.getFilesToUpload().size(); ++i)
|
||||
{
|
||||
const File f (url.getFilesToUpload().getAllValues() [i]);
|
||||
const File file (url.getFilesToUpload().getAllValues() [i]);
|
||||
const String paramName (url.getFilesToUpload().getAllKeys() [i]);
|
||||
|
||||
String s;
|
||||
s << "\r\nContent-Disposition: form-data; name=\""
|
||||
<< paramName
|
||||
<< "\"; filename=\""
|
||||
<< f.getFileName()
|
||||
<< "\"\r\n";
|
||||
data << "\r\nContent-Disposition: form-data; name=\"" << paramName
|
||||
<< "\"; filename=\"" << file.getFileName() << "\"\r\n";
|
||||
|
||||
const String mimeType (url.getMimeTypesOfUploadFiles()
|
||||
.getValue (paramName, String::empty));
|
||||
|
||||
if (mimeType.isNotEmpty())
|
||||
s << "Content-Type: " << mimeType << "\r\n";
|
||||
data << "Content-Type: " << mimeType << "\r\n";
|
||||
|
||||
s << "Content-Transfer-Encoding: binary\r\n\r\n";
|
||||
|
||||
appendUTF8ToPostData (s);
|
||||
|
||||
f.loadFileAsData (postData);
|
||||
|
||||
s = "\r\n--" + boundary;
|
||||
|
||||
appendUTF8ToPostData (s);
|
||||
data << "Content-Transfer-Encoding: binary\r\n\r\n"
|
||||
<< file << "\r\n--" << boundary;
|
||||
}
|
||||
|
||||
appendUTF8ToPostData ("--\r\n");
|
||||
data << "--\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
appendUTF8ToPostData (getMangledParameters (url.getParameters()));
|
||||
appendUTF8ToPostData (url.getPostData());
|
||||
data << getMangledParameters (url.getParameters())
|
||||
<< url.getPostData();
|
||||
|
||||
// just a short text attachment, so use simple url encoding..
|
||||
headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: "
|
||||
|
|
@ -436,12 +411,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void appendUTF8ToPostData (const String& text)
|
||||
{
|
||||
postData.append (text.toUTF8(),
|
||||
(int) strlen (text.toUTF8()));
|
||||
}
|
||||
|
||||
WebInputStream (const WebInputStream&);
|
||||
WebInputStream& operator= (const WebInputStream&);
|
||||
};
|
||||
|
|
@ -583,8 +552,6 @@ const String URL::addEscapeChars (const String& s, const bool isParameter)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
extern bool juce_launchFile (const String& fileName, const String& parameters);
|
||||
|
||||
bool URL::launchInDefaultBrowser() const
|
||||
{
|
||||
String u (toString (true));
|
||||
|
|
@ -592,7 +559,7 @@ bool URL::launchInDefaultBrowser() const
|
|||
if (u.containsChar ('@') && ! u.containsChar (':'))
|
||||
u = "mailto:" + u;
|
||||
|
||||
return juce_launchFile (u, String::empty);
|
||||
return PlatformUtilities::openDocument (u, String::empty);
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_OutputStream.h"
|
||||
#include "../../threads/juce_ScopedLock.h"
|
||||
#include "../../containers/juce_VoidArray.h"
|
||||
#include "../../containers/juce_ScopedPointer.h"
|
||||
#include "../files/juce_FileInputStream.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -228,20 +230,19 @@ void OutputStream::writeText (const String& text, const bool asUnicode,
|
|||
}
|
||||
}
|
||||
|
||||
int OutputStream::writeFromInputStream (InputStream& source, int numBytesToWrite)
|
||||
int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite)
|
||||
{
|
||||
if (numBytesToWrite < 0)
|
||||
numBytesToWrite = 0x7fffffff;
|
||||
numBytesToWrite = std::numeric_limits<int64>::max();
|
||||
|
||||
int numWritten = 0;
|
||||
|
||||
while (numBytesToWrite > 0 && ! source.isExhausted())
|
||||
{
|
||||
char buffer [8192];
|
||||
const int num = source.read (buffer, (int) jmin (numBytesToWrite, (int64) sizeof (buffer)));
|
||||
|
||||
const int num = (int) source.read (buffer, (int) jmin ((size_t) numBytesToWrite, sizeof (buffer)));
|
||||
|
||||
if (num == 0)
|
||||
if (num <= 0)
|
||||
break;
|
||||
|
||||
write (buffer, num);
|
||||
|
|
@ -276,5 +277,21 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const
|
|||
return stream;
|
||||
}
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
|
||||
{
|
||||
stream.write (data.getData(), (int) data.getSize());
|
||||
return stream;
|
||||
}
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const File& fileToRead)
|
||||
{
|
||||
const ScopedPointer<FileInputStream> in (fileToRead.createInputStream());
|
||||
|
||||
if (in != 0)
|
||||
stream.writeFromInputStream (*in, -1);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "../../text/juce_String.h"
|
||||
#include "juce_InputStream.h"
|
||||
|
||||
class File;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
|
@ -199,7 +199,7 @@ public:
|
|||
less than zero, it will keep reading until the input
|
||||
is exhausted)
|
||||
*/
|
||||
virtual int writeFromInputStream (InputStream& source, int maxNumBytesToWrite);
|
||||
virtual int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite);
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
|
@ -218,6 +218,11 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, char character);
|
|||
/** Writes a null-terminated text string to a stream. */
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* text);
|
||||
|
||||
/** Writes a block of data from a MemoryBlock to a stream. */
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data);
|
||||
|
||||
/** Writes the contents of a file to a stream. */
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const File& fileToRead);
|
||||
|
||||
|
||||
#endif // __JUCE_OUTPUTSTREAM_JUCEHEADER__
|
||||
|
|
|
|||
|
|
@ -247,27 +247,58 @@ int64 File::getSize() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool juce_canWriteToFile (const String& fileName)
|
||||
bool File::hasWriteAccess() const
|
||||
{
|
||||
return access (fileName.toUTF8(), W_OK) == 0;
|
||||
if (exists())
|
||||
return access (fullPath.toUTF8(), W_OK) == 0;
|
||||
|
||||
if ((! isDirectory()) && fullPath.containsChar (separator))
|
||||
return getParentDirectory().hasWriteAccess();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool juce_setFileReadOnly (const String& fileName, bool isReadOnly)
|
||||
bool File::setFileReadOnlyInternal (const bool shouldBeReadOnly) const
|
||||
{
|
||||
struct stat info;
|
||||
const int res = stat (fileName.toUTF8(), &info);
|
||||
const int res = stat (fullPath.toUTF8(), &info);
|
||||
if (res != 0)
|
||||
return false;
|
||||
|
||||
info.st_mode &= 0777; // Just permissions
|
||||
|
||||
if (isReadOnly)
|
||||
if (shouldBeReadOnly)
|
||||
info.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||
else
|
||||
// Give everybody write permission?
|
||||
info.st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
|
||||
|
||||
return chmod (fileName.toUTF8(), info.st_mode) == 0;
|
||||
return chmod (fullPath.toUTF8(), info.st_mode) == 0;
|
||||
}
|
||||
|
||||
void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const
|
||||
{
|
||||
modificationTime = 0;
|
||||
accessTime = 0;
|
||||
creationTime = 0;
|
||||
|
||||
struct stat info;
|
||||
const int res = stat (fullPath.toUTF8(), &info);
|
||||
if (res == 0)
|
||||
{
|
||||
modificationTime = (int64) info.st_mtime * 1000;
|
||||
accessTime = (int64) info.st_atime * 1000;
|
||||
creationTime = (int64) info.st_ctime * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 creationTime) const
|
||||
{
|
||||
struct utimbuf times;
|
||||
times.actime = (time_t) (accessTime / 1000);
|
||||
times.modtime = (time_t) (modificationTime / 1000);
|
||||
|
||||
return utime (fullPath.toUTF8(), ×) == 0;
|
||||
}
|
||||
|
||||
bool File::deleteFile() const
|
||||
|
|
@ -280,20 +311,17 @@ bool File::deleteFile() const
|
|||
return remove (fullPath.toUTF8()) == 0;
|
||||
}
|
||||
|
||||
bool juce_copyFile (const String& s, const String& d);
|
||||
|
||||
bool juce_moveFile (const String& source, const String& dest)
|
||||
bool File::moveInternal (const File& dest) const
|
||||
{
|
||||
if (rename (source.toUTF8(), dest.toUTF8()) == 0)
|
||||
if (rename (fullPath.toUTF8(), dest.getFullPathName().toUTF8()) == 0)
|
||||
return true;
|
||||
|
||||
if (juce_canWriteToFile (source)
|
||||
&& juce_copyFile (source, dest))
|
||||
if (hasWriteAccess() && copyInternal (dest))
|
||||
{
|
||||
if (File (source).deleteFile())
|
||||
if (deleteFile())
|
||||
return true;
|
||||
|
||||
File (dest).deleteFile();
|
||||
dest.deleteFile();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -652,14 +652,12 @@ public:
|
|||
outputId (outputId_),
|
||||
isOpen_ (false),
|
||||
isStarted (false),
|
||||
internal (0)
|
||||
internal (new ALSAThread (inputId_, outputId_))
|
||||
{
|
||||
internal = new ALSAThread (inputId, outputId);
|
||||
}
|
||||
|
||||
~ALSAAudioIODevice()
|
||||
{
|
||||
delete internal;
|
||||
}
|
||||
|
||||
const StringArray getOutputChannelNames()
|
||||
|
|
@ -817,7 +815,7 @@ public:
|
|||
|
||||
private:
|
||||
bool isOpen_, isStarted;
|
||||
ALSAThread* internal;
|
||||
ScopedPointer<ALSAThread> internal;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,66 +33,26 @@ static const short U_NFS_SUPER_MAGIC = 0x6969; // linux/nfs_fs.h
|
|||
static const short U_SMB_SUPER_MAGIC = 0x517B; // linux/smb_fs.h
|
||||
|
||||
//==============================================================================
|
||||
void juce_getFileTimes (const String& fileName,
|
||||
int64& modificationTime,
|
||||
int64& accessTime,
|
||||
int64& creationTime)
|
||||
bool File::copyInternal (const File& dest) const
|
||||
{
|
||||
modificationTime = 0;
|
||||
accessTime = 0;
|
||||
creationTime = 0;
|
||||
FileInputStream in (*this);
|
||||
|
||||
struct stat info;
|
||||
const int res = stat (fileName.toUTF8(), &info);
|
||||
if (res == 0)
|
||||
if (dest.deleteFile())
|
||||
{
|
||||
modificationTime = (int64) info.st_mtime * 1000;
|
||||
accessTime = (int64) info.st_atime * 1000;
|
||||
creationTime = (int64) info.st_ctime * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
bool juce_setFileTimes (const String& fileName,
|
||||
int64 modificationTime,
|
||||
int64 accessTime,
|
||||
int64 creationTime)
|
||||
{
|
||||
struct utimbuf times;
|
||||
times.actime = (time_t) (accessTime / 1000);
|
||||
times.modtime = (time_t) (modificationTime / 1000);
|
||||
|
||||
return utime (fileName.toUTF8(), ×) == 0;
|
||||
}
|
||||
|
||||
bool juce_copyFile (const String& s, const String& d)
|
||||
{
|
||||
const File source (s), dest (d);
|
||||
|
||||
FileInputStream* in = source.createInputStream();
|
||||
bool ok = false;
|
||||
|
||||
if (in != 0)
|
||||
{
|
||||
if (dest.deleteFile())
|
||||
{
|
||||
FileOutputStream* const out = dest.createOutputStream();
|
||||
FileOutputStream out (dest);
|
||||
|
||||
if (out != 0)
|
||||
{
|
||||
const int bytesCopied = out->writeFromInputStream (*in, -1);
|
||||
delete out;
|
||||
if (out.failedToOpen())
|
||||
return false;
|
||||
|
||||
ok = (bytesCopied == source.getSize());
|
||||
|
||||
if (! ok)
|
||||
dest.deleteFile();
|
||||
}
|
||||
if (out.writeFromInputStream (in, -1) == getSize())
|
||||
return true;
|
||||
}
|
||||
|
||||
delete in;
|
||||
dest.deleteFile();
|
||||
}
|
||||
|
||||
return ok;
|
||||
return false;
|
||||
}
|
||||
|
||||
void File::findFileSystemRoots (Array<File>& destArray)
|
||||
|
|
@ -105,11 +65,8 @@ bool File::isOnCDRomDrive() const
|
|||
{
|
||||
struct statfs buf;
|
||||
|
||||
if (statfs (getFullPathName().toUTF8(), &buf) == 0)
|
||||
return (buf.f_type == U_ISOFS_SUPER_MAGIC);
|
||||
|
||||
// Assume not if this fails for some reason
|
||||
return false;
|
||||
return statfs (getFullPathName().toUTF8(), &buf) == 0
|
||||
&& buf.f_type == U_ISOFS_SUPER_MAGIC;
|
||||
}
|
||||
|
||||
bool File::isOnHardDisk() const
|
||||
|
|
@ -292,30 +249,24 @@ public:
|
|||
if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0)
|
||||
{
|
||||
filenameFound = String::fromUTF8 (de->d_name);
|
||||
|
||||
const String path (parentDir + filenameFound);
|
||||
|
||||
if (isDir != 0 || fileSize != 0)
|
||||
if (isDir != 0 || fileSize != 0 || modTime != 0 || creationTime != 0)
|
||||
{
|
||||
struct stat info;
|
||||
const bool statOk = (stat (path.toUTF8(), &info) == 0);
|
||||
const bool statOk = juce_stat (path, info);
|
||||
|
||||
if (isDir != 0) *isDir = path.isEmpty() || (statOk && ((info.st_mode & S_IFDIR) != 0));
|
||||
if (isHidden != 0) *isHidden = (de->d_name[0] == '.');
|
||||
if (fileSize != 0) *fileSize = statOk ? info.st_size : 0;
|
||||
if (isDir != 0) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
|
||||
if (fileSize != 0) *fileSize = statOk ? info.st_size : 0;
|
||||
if (modTime != 0) *modTime = statOk ? (int64) info.st_mtime * 1000 : 0;
|
||||
if (creationTime != 0) *creationTime = statOk ? (int64) info.st_ctime * 1000 : 0;
|
||||
}
|
||||
|
||||
if (modTime != 0 || creationTime != 0)
|
||||
{
|
||||
int64 m, a, c;
|
||||
juce_getFileTimes (path, m, a, c);
|
||||
|
||||
if (modTime != 0) *modTime = m;
|
||||
if (creationTime != 0) *creationTime = c;
|
||||
}
|
||||
if (isHidden != 0)
|
||||
*isHidden = filenameFound.startsWithChar ('.');
|
||||
|
||||
if (isReadOnly != 0)
|
||||
*isReadOnly = ! juce_canWriteToFile (path);
|
||||
*isReadOnly = access (path.toUTF8(), W_OK) != 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -349,8 +300,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound,
|
|||
|
||||
|
||||
//==============================================================================
|
||||
bool juce_launchFile (const String& fileName,
|
||||
const String& parameters)
|
||||
bool PlatformUtilities::openDocument (const String& fileName, const String& parameters)
|
||||
{
|
||||
String cmdString (fileName.replace (" ", "\\ ",false));
|
||||
cmdString << " " << parameters;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public:
|
|||
if (fontDirs.size() == 0)
|
||||
{
|
||||
XmlDocument fontsConfig (File ("/etc/fonts/fonts.conf"));
|
||||
XmlElement* const fontsInfo = fontsConfig.getDocumentElement();
|
||||
const ScopedPointer<XmlElement> fontsInfo (fontsConfig.getDocumentElement());
|
||||
|
||||
if (fontsInfo != 0)
|
||||
{
|
||||
|
|
@ -116,8 +116,6 @@ public:
|
|||
{
|
||||
fontDirs.add (e->getAllSubText().trim());
|
||||
}
|
||||
|
||||
delete fontsInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -412,11 +412,6 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
bool juce_isOnLine()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void* juce_openInternetFile (const String& url,
|
||||
const String& headers,
|
||||
const MemoryBlock& postData,
|
||||
|
|
@ -437,10 +432,7 @@ void* juce_openInternetFile (const String& url,
|
|||
|
||||
void juce_closeInternetFile (void* handle)
|
||||
{
|
||||
JUCE_HTTPSocketStream* const s = (JUCE_HTTPSocketStream*) handle;
|
||||
|
||||
if (s != 0)
|
||||
delete s;
|
||||
delete static_cast <JUCE_HTTPSocketStream*> (handle);
|
||||
}
|
||||
|
||||
int juce_readFromInternetFile (void* handle, void* buffer, int bytesToRead)
|
||||
|
|
|
|||
|
|
@ -210,7 +210,15 @@ public:
|
|||
{
|
||||
if (! transform.isSingularity())
|
||||
{
|
||||
Image* singleChannelImage = createAlphaChannelImage (sourceImage);
|
||||
ScopedPointer<Image> imageToDelete;
|
||||
const Image* singleChannelImage = &sourceImage;
|
||||
|
||||
if (sourceImage.getFormat() != Image::SingleChannel)
|
||||
{
|
||||
imageToDelete = sourceImage.createCopyOfAlphaChannel();
|
||||
singleChannelImage = imageToDelete;
|
||||
}
|
||||
|
||||
CGImageRef image = CoreGraphicsImage::createImage (*singleChannelImage, true, greyColourSpace);
|
||||
|
||||
flip();
|
||||
|
|
@ -224,7 +232,6 @@ public:
|
|||
flip();
|
||||
|
||||
CGImageRelease (image);
|
||||
deleteAlphaChannelImage (sourceImage, singleChannelImage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -697,20 +704,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
static Image* createAlphaChannelImage (const Image& im)
|
||||
{
|
||||
if (im.getFormat() == Image::SingleChannel)
|
||||
return const_cast <Image*> (&im);
|
||||
|
||||
return im.createCopyOfAlphaChannel();
|
||||
}
|
||||
|
||||
static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm)
|
||||
{
|
||||
if (im.getFormat() != Image::SingleChannel)
|
||||
delete alphaIm;
|
||||
}
|
||||
|
||||
void flip() const
|
||||
{
|
||||
CGContextConcatCTM (context, CGAffineTransformMake (1, 0, 0, -1, 0, flipHeight));
|
||||
|
|
|
|||
|
|
@ -33,50 +33,19 @@
|
|||
*/
|
||||
|
||||
//==============================================================================
|
||||
void juce_getFileTimes (const String& fileName,
|
||||
int64& modificationTime,
|
||||
int64& accessTime,
|
||||
int64& creationTime)
|
||||
{
|
||||
modificationTime = 0;
|
||||
accessTime = 0;
|
||||
creationTime = 0;
|
||||
|
||||
struct stat info;
|
||||
const int res = stat (fileName.toUTF8(), &info);
|
||||
if (res == 0)
|
||||
{
|
||||
modificationTime = (int64) info.st_mtime * 1000;
|
||||
accessTime = (int64) info.st_atime * 1000;
|
||||
creationTime = (int64) info.st_ctime * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
bool juce_setFileTimes (const String& fileName,
|
||||
int64 modificationTime,
|
||||
int64 accessTime,
|
||||
int64 creationTime)
|
||||
{
|
||||
struct utimbuf times;
|
||||
times.actime = (time_t) (accessTime / 1000);
|
||||
times.modtime = (time_t) (modificationTime / 1000);
|
||||
|
||||
return utime (fileName.toUTF8(), ×) == 0;
|
||||
}
|
||||
|
||||
bool juce_copyFile (const String& src, const String& dst)
|
||||
bool File::copyInternal (const File& dest) const
|
||||
{
|
||||
const ScopedAutoReleasePool pool;
|
||||
NSFileManager* fm = [NSFileManager defaultManager];
|
||||
|
||||
return [fm fileExistsAtPath: juceStringToNS (src)]
|
||||
return [fm fileExistsAtPath: juceStringToNS (fullPath)]
|
||||
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
&& [fm copyItemAtPath: juceStringToNS (src)
|
||||
toPath: juceStringToNS (dst)
|
||||
&& [fm copyItemAtPath: juceStringToNS (fullPath)
|
||||
toPath: juceStringToNS (dest.getFullPathName())
|
||||
error: nil];
|
||||
#else
|
||||
&& [fm copyPath: juceStringToNS (src)
|
||||
toPath: juceStringToNS (dst)
|
||||
&& [fm copyPath: juceStringToNS (fullPath)
|
||||
toPath: juceStringToNS (dest.getFullPathName())
|
||||
handler: nil];
|
||||
#endif
|
||||
}
|
||||
|
|
@ -345,27 +314,22 @@ public:
|
|||
|
||||
const String path (parentDir + filenameFound);
|
||||
|
||||
if (isDir != 0 || fileSize != 0)
|
||||
if (isDir != 0 || fileSize != 0 || modTime != 0 || creationTime != 0)
|
||||
{
|
||||
struct stat info;
|
||||
const bool statOk = juce_stat (path, info);
|
||||
|
||||
if (isDir != 0) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
|
||||
if (isHidden != 0) *isHidden = juce_isHiddenFile (path);
|
||||
if (fileSize != 0) *fileSize = statOk ? info.st_size : 0;
|
||||
if (isDir != 0) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
|
||||
if (fileSize != 0) *fileSize = statOk ? info.st_size : 0;
|
||||
if (modTime != 0) *modTime = statOk ? (int64) info.st_mtime * 1000 : 0;
|
||||
if (creationTime != 0) *creationTime = statOk ? (int64) info.st_ctime * 1000 : 0;
|
||||
}
|
||||
|
||||
if (modTime != 0 || creationTime != 0)
|
||||
{
|
||||
int64 m, a, c;
|
||||
juce_getFileTimes (path, m, a, c);
|
||||
|
||||
if (modTime != 0) *modTime = m;
|
||||
if (creationTime != 0) *creationTime = c;
|
||||
}
|
||||
if (isHidden != 0)
|
||||
*isHidden = juce_isHiddenFile (path);
|
||||
|
||||
if (isReadOnly != 0)
|
||||
*isReadOnly = ! juce_canWriteToFile (path);
|
||||
*isReadOnly = access (path.toUTF8(), W_OK) != 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -419,7 +383,7 @@ bool juce_launchExecutable (const String& pathAndArguments)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool juce_launchFile (const String& fileName, const String& parameters)
|
||||
bool PlatformUtilities::openDocument (const String& fileName, const String& parameters)
|
||||
{
|
||||
#if JUCE_IPHONE
|
||||
return [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: juceStringToNS (fileName)]];
|
||||
|
|
|
|||
|
|
@ -326,11 +326,6 @@ public:
|
|||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
bool juce_isOnLine()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void* juce_openInternetFile (const String& url,
|
||||
const String& headers,
|
||||
const MemoryBlock& postData,
|
||||
|
|
|
|||
|
|
@ -29,33 +29,12 @@
|
|||
|
||||
namespace ActiveXHelpers
|
||||
{
|
||||
class JuceIStorage : public IStorage
|
||||
//==============================================================================
|
||||
class JuceIStorage : public ComBaseClassHelper <IStorage>
|
||||
{
|
||||
int refCount;
|
||||
|
||||
public:
|
||||
JuceIStorage() : refCount (1) {}
|
||||
|
||||
virtual ~JuceIStorage()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IStorage)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
JuceIStorage() {}
|
||||
~JuceIStorage() {}
|
||||
|
||||
HRESULT __stdcall CreateStream (const WCHAR*, DWORD, DWORD, DWORD, IStream**) { return E_NOTIMPL; }
|
||||
HRESULT __stdcall OpenStream (const WCHAR*, void*, DWORD, DWORD, IStream**) { return E_NOTIMPL; }
|
||||
|
|
@ -76,39 +55,14 @@ namespace ActiveXHelpers
|
|||
juce_UseDebuggingNewOperator
|
||||
};
|
||||
|
||||
|
||||
class JuceOleInPlaceFrame : public IOleInPlaceFrame
|
||||
//==============================================================================
|
||||
class JuceOleInPlaceFrame : public ComBaseClassHelper <IOleInPlaceFrame>
|
||||
{
|
||||
int refCount;
|
||||
HWND window;
|
||||
|
||||
public:
|
||||
JuceOleInPlaceFrame (HWND window_)
|
||||
: refCount (1),
|
||||
window (window_)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JuceOleInPlaceFrame()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IOleInPlaceFrame)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
JuceOleInPlaceFrame (HWND window_) : window (window_) {}
|
||||
~JuceOleInPlaceFrame() {}
|
||||
|
||||
HRESULT __stdcall GetWindow (HWND* lphwnd) { *lphwnd = window; return S_OK; }
|
||||
HRESULT __stdcall ContextSensitiveHelp (BOOL) { return E_NOTIMPL; }
|
||||
|
|
@ -126,43 +80,23 @@ namespace ActiveXHelpers
|
|||
juce_UseDebuggingNewOperator
|
||||
};
|
||||
|
||||
|
||||
class JuceIOleInPlaceSite : public IOleInPlaceSite
|
||||
//==============================================================================
|
||||
class JuceIOleInPlaceSite : public ComBaseClassHelper <IOleInPlaceSite>
|
||||
{
|
||||
int refCount;
|
||||
HWND window;
|
||||
JuceOleInPlaceFrame* frame;
|
||||
|
||||
public:
|
||||
JuceIOleInPlaceSite (HWND window_)
|
||||
: refCount (1),
|
||||
window (window_)
|
||||
{
|
||||
frame = new JuceOleInPlaceFrame (window);
|
||||
}
|
||||
: window (window_),
|
||||
frame (new JuceOleInPlaceFrame (window))
|
||||
{}
|
||||
|
||||
virtual ~JuceIOleInPlaceSite()
|
||||
~JuceIOleInPlaceSite()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
frame->Release();
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IOleInPlaceSite)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
HRESULT __stdcall GetWindow (HWND* lphwnd) { *lphwnd = window; return S_OK; }
|
||||
HRESULT __stdcall ContextSensitiveHelp (BOOL) { return E_NOTIMPL; }
|
||||
HRESULT __stdcall CanInPlaceActivate() { return S_OK; }
|
||||
|
|
@ -190,47 +124,33 @@ namespace ActiveXHelpers
|
|||
juce_UseDebuggingNewOperator
|
||||
};
|
||||
|
||||
|
||||
class JuceIOleClientSite : public IOleClientSite
|
||||
//==============================================================================
|
||||
class JuceIOleClientSite : public ComBaseClassHelper <IOleClientSite>
|
||||
{
|
||||
int refCount;
|
||||
JuceIOleInPlaceSite* inplaceSite;
|
||||
|
||||
public:
|
||||
JuceIOleClientSite (HWND window)
|
||||
: refCount (1)
|
||||
{
|
||||
inplaceSite = new JuceIOleInPlaceSite (window);
|
||||
}
|
||||
: inplaceSite (new JuceIOleInPlaceSite (window))
|
||||
{}
|
||||
|
||||
virtual ~JuceIOleClientSite()
|
||||
~JuceIOleClientSite()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
inplaceSite->Release();
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
HRESULT __stdcall QueryInterface (REFIID type, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IOleClientSite)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
else if (id == IID_IOleInPlaceSite)
|
||||
if (type == IID_IOleInPlaceSite)
|
||||
{
|
||||
inplaceSite->AddRef();
|
||||
*result = inplaceSite;
|
||||
*result = static_cast <IOleInPlaceSite*> (inplaceSite);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
return ComBaseClassHelper <IOleClientSite>::QueryInterface (type, result);
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
HRESULT __stdcall SaveObject() { return E_NOTIMPL; }
|
||||
HRESULT __stdcall GetMoniker (DWORD, DWORD, IMoniker**) { return E_NOTIMPL; }
|
||||
HRESULT __stdcall GetContainer (LPOLECONTAINER* ppContainer) { *ppContainer = 0; return E_NOINTERFACE; }
|
||||
|
|
|
|||
|
|
@ -2137,13 +2137,13 @@ static IDiscRecorder* enumCDBurners (StringArray* list, int indexToOpen, IDiscMa
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
class AudioCDBurner::Pimpl : public IDiscMasterProgressEvents,
|
||||
class AudioCDBurner::Pimpl : public ComBaseClassHelper <IDiscMasterProgressEvents>,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
Pimpl (AudioCDBurner& owner_, IDiscMaster* discMaster_, IDiscRecorder* discRecorder_)
|
||||
: owner (owner_), discMaster (discMaster_), discRecorder (discRecorder_), redbook (0),
|
||||
listener (0), progress (0), shouldCancel (false), refCount (1)
|
||||
listener (0), progress (0), shouldCancel (false)
|
||||
{
|
||||
HRESULT hr = discMaster->SetActiveDiscMasterFormat (IID_IRedbookDiscMaster, (void**) &redbook);
|
||||
jassert (SUCCEEDED (hr));
|
||||
|
|
@ -2166,25 +2166,6 @@ public:
|
|||
Release();
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (result == 0)
|
||||
return E_POINTER;
|
||||
|
||||
if (id == IID_IUnknown || id == IID_IDiscMasterProgressEvents)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
HRESULT __stdcall QueryCancel (boolean* pbCancel)
|
||||
{
|
||||
if (listener != 0 && ! shouldCancel)
|
||||
|
|
@ -2296,9 +2277,6 @@ public:
|
|||
AudioCDBurner::BurnProgressListener* listener;
|
||||
float progress;
|
||||
bool shouldCancel;
|
||||
|
||||
private:
|
||||
int refCount;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ private:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
class GrabberCallback : public ISampleGrabberCB
|
||||
class GrabberCallback : public ComBaseClassHelper <ISampleGrabberCB>
|
||||
{
|
||||
public:
|
||||
GrabberCallback (DShowCameraDeviceInteral& owner_)
|
||||
|
|
@ -632,25 +632,6 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void** result)
|
||||
{
|
||||
if (id == IID_IUnknown)
|
||||
*result = dynamic_cast <IUnknown*> (this);
|
||||
else if (id == IID_ISampleGrabberCB)
|
||||
*result = dynamic_cast <ISampleGrabberCB*> (this);
|
||||
else
|
||||
{
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
//==============================================================================
|
||||
STDMETHODIMP SampleCB (double /*SampleTime*/, IMediaSample* /*pSample*/)
|
||||
{
|
||||
|
|
@ -664,7 +645,6 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
int refCount;
|
||||
DShowCameraDeviceInteral& owner;
|
||||
|
||||
GrabberCallback (const GrabberCallback&);
|
||||
|
|
@ -691,13 +671,13 @@ CameraDevice::CameraDevice (const String& name_, int /*index*/)
|
|||
CameraDevice::~CameraDevice()
|
||||
{
|
||||
stopRecording();
|
||||
delete (DShowCameraDeviceInteral*) internal;
|
||||
delete static_cast <DShowCameraDeviceInteral*> (internal);
|
||||
internal = 0;
|
||||
}
|
||||
|
||||
Component* CameraDevice::createViewerComponent()
|
||||
{
|
||||
return new DShowCameraDeviceInteral::DShowCaptureViewerComp ((DShowCameraDeviceInteral*) internal);
|
||||
return new DShowCameraDeviceInteral::DShowCaptureViewerComp (static_cast <DShowCameraDeviceInteral*> (internal));
|
||||
}
|
||||
|
||||
const String CameraDevice::getFileExtension()
|
||||
|
|
@ -837,16 +817,15 @@ CameraDevice* CameraDevice::openDevice (int index,
|
|||
|
||||
if (filter != 0)
|
||||
{
|
||||
CameraDevice* const cam = new CameraDevice (name, index);
|
||||
ScopedPointer <CameraDevice> cam (new CameraDevice (name, index));
|
||||
|
||||
DShowCameraDeviceInteral* const intern
|
||||
= new DShowCameraDeviceInteral (cam, captureGraphBuilder, filter,
|
||||
minWidth, minHeight, maxWidth, maxHeight);
|
||||
cam->internal = intern;
|
||||
|
||||
if (intern->ok)
|
||||
return cam;
|
||||
else
|
||||
delete cam;
|
||||
return cam.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,28 +65,32 @@ bool File::isDirectory() const
|
|||
return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) && (attr != INVALID_FILE_ATTRIBUTES);
|
||||
}
|
||||
|
||||
bool juce_canWriteToFile (const String& fileName)
|
||||
bool File::hasWriteAccess() const
|
||||
{
|
||||
const DWORD attr = GetFileAttributes (fileName);
|
||||
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
if (exists())
|
||||
return (GetFileAttributes (fullPath) & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
|
||||
// on windows, it seems that even read-only directories can still be written into,
|
||||
// so checking the parent directory's permissions would return the wrong result..
|
||||
return true;
|
||||
}
|
||||
|
||||
bool juce_setFileReadOnly (const String& fileName, bool isReadOnly)
|
||||
bool File::setFileReadOnlyInternal (const bool shouldBeReadOnly) const
|
||||
{
|
||||
DWORD attr = GetFileAttributes (fileName);
|
||||
DWORD attr = GetFileAttributes (fullPath);
|
||||
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
|
||||
if (isReadOnly != juce_canWriteToFile (fileName))
|
||||
if (shouldBeReadOnly == ((attr & FILE_ATTRIBUTE_READONLY) != 0))
|
||||
return true;
|
||||
|
||||
if (isReadOnly)
|
||||
if (shouldBeReadOnly)
|
||||
attr |= FILE_ATTRIBUTE_READONLY;
|
||||
else
|
||||
attr &= ~FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
return SetFileAttributes (fileName, attr) != FALSE;
|
||||
return SetFileAttributes (fullPath, attr) != FALSE;
|
||||
}
|
||||
|
||||
bool File::isHidden() const
|
||||
|
|
@ -126,14 +130,14 @@ bool File::moveToTrash() const
|
|||
return SHFileOperation (&fos) == 0;
|
||||
}
|
||||
|
||||
bool juce_moveFile (const String& source, const String& dest)
|
||||
bool File::copyInternal (const File& dest) const
|
||||
{
|
||||
return MoveFile (source, dest) != 0;
|
||||
return CopyFile (fullPath, dest.getFullPathName(), false) != 0;
|
||||
}
|
||||
|
||||
bool juce_copyFile (const String& source, const String& dest)
|
||||
bool File::moveInternal (const File& dest) const
|
||||
{
|
||||
return CopyFile (source, dest, false) != 0;
|
||||
return MoveFile (fullPath, dest.getFullPathName()) != 0;
|
||||
}
|
||||
|
||||
void File::createDirectoryInternal (const String& fileName) const
|
||||
|
|
@ -237,14 +241,11 @@ static void timeToFileTime (const int64 time, FILETIME* const ft)
|
|||
reinterpret_cast<ULARGE_INTEGER*> (ft)->QuadPart = time * 10000 + literal64bit (116444736000000000);
|
||||
}
|
||||
|
||||
void juce_getFileTimes (const String& fileName,
|
||||
int64& modificationTime,
|
||||
int64& accessTime,
|
||||
int64& creationTime)
|
||||
void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
|
||||
if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes))
|
||||
if (GetFileAttributesEx (fullPath, GetFileExInfoStandard, &attributes))
|
||||
{
|
||||
modificationTime = fileTimeToTime (&attributes.ftLastWriteTime);
|
||||
creationTime = fileTimeToTime (&attributes.ftCreationTime);
|
||||
|
|
@ -256,12 +257,9 @@ void juce_getFileTimes (const String& fileName,
|
|||
}
|
||||
}
|
||||
|
||||
bool juce_setFileTimes (const String& fileName,
|
||||
int64 modificationTime,
|
||||
int64 accessTime,
|
||||
int64 creationTime)
|
||||
bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 creationTime) const
|
||||
{
|
||||
void* const h = juce_fileOpen (fileName, true);
|
||||
void* const h = juce_fileOpen (fullPath, true);
|
||||
bool ok = false;
|
||||
|
||||
if (h != 0)
|
||||
|
|
@ -600,7 +598,7 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound,
|
|||
|
||||
|
||||
//==============================================================================
|
||||
bool juce_launchFile (const String& fileName, const String& parameters)
|
||||
bool PlatformUtilities::openDocument (const String& fileName, const String& parameters)
|
||||
{
|
||||
HINSTANCE hInstance = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -228,5 +228,28 @@ public:
|
|||
T* p;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
template <class ComClass>
|
||||
class ComBaseClassHelper : public ComClass
|
||||
{
|
||||
public:
|
||||
ComBaseClassHelper() : refCount (1) {}
|
||||
virtual ~ComBaseClassHelper() {}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID refId, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (refId == __uuidof (ComClass)) { AddRef(); *result = dynamic_cast <ComClass*> (this); return S_OK; }
|
||||
if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast <IUnknown*> (this); return S_OK; }
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
protected:
|
||||
int refCount;
|
||||
};
|
||||
|
||||
#endif // __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__
|
||||
|
|
|
|||
|
|
@ -37,14 +37,6 @@
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
bool juce_isOnLine()
|
||||
{
|
||||
DWORD connectionType;
|
||||
|
||||
return InternetGetConnectedState (&connectionType, 0) != 0
|
||||
|| (connectionType & (INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_PROXY)) != 0;
|
||||
}
|
||||
|
||||
struct ConnectionAndRequestStruct
|
||||
{
|
||||
HINTERNET connection, request;
|
||||
|
|
@ -293,10 +285,9 @@ void juce_closeInternetFile (void* handle)
|
|||
{
|
||||
if (handle != 0)
|
||||
{
|
||||
ConnectionAndRequestStruct* const crs = static_cast <ConnectionAndRequestStruct*> (handle);
|
||||
ScopedPointer <ConnectionAndRequestStruct> crs (static_cast <ConnectionAndRequestStruct*> (handle));
|
||||
InternetCloseHandle (crs->request);
|
||||
InternetCloseHandle (crs->connection);
|
||||
delete crs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public:
|
|||
|
||||
EventHandler* handler = new EventHandler (owner);
|
||||
connectionPoint->Advise (handler, &adviseCookie);
|
||||
handler->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -142,14 +143,13 @@ private:
|
|||
DWORD adviseCookie;
|
||||
|
||||
//==============================================================================
|
||||
class EventHandler : public IDispatch,
|
||||
class EventHandler : public ComBaseClassHelper <IDispatch>,
|
||||
public ComponentMovementWatcher
|
||||
{
|
||||
public:
|
||||
EventHandler (WebBrowserComponent* owner_)
|
||||
: ComponentMovementWatcher (owner_),
|
||||
owner (owner_),
|
||||
refCount (0)
|
||||
owner (owner_)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -158,22 +158,6 @@ private:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IDispatch || id == DIID_DWebBrowserEvents2)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
HRESULT __stdcall GetTypeInfoCount (UINT __RPC_FAR*) { return E_NOTIMPL; }
|
||||
HRESULT __stdcall GetTypeInfo (UINT, LCID, ITypeInfo __RPC_FAR *__RPC_FAR*) { return E_NOTIMPL; }
|
||||
HRESULT __stdcall GetIDsOfNames (REFIID, LPOLESTR __RPC_FAR*, UINT, LCID, DISPID __RPC_FAR*) { return E_NOTIMPL; }
|
||||
|
|
@ -223,7 +207,6 @@ private:
|
|||
|
||||
private:
|
||||
WebBrowserComponent* const owner;
|
||||
int refCount;
|
||||
|
||||
EventHandler (const EventHandler&);
|
||||
EventHandler& operator= (const EventHandler&);
|
||||
|
|
|
|||
|
|
@ -844,15 +844,8 @@ private:
|
|||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
TemporaryImage()
|
||||
: image (0)
|
||||
{
|
||||
}
|
||||
|
||||
~TemporaryImage()
|
||||
{
|
||||
delete image;
|
||||
}
|
||||
TemporaryImage() {}
|
||||
~TemporaryImage() {}
|
||||
|
||||
//==============================================================================
|
||||
WindowsBitmapImage* getImage (const bool transparent, const int w, const int h) throw()
|
||||
|
|
@ -860,10 +853,7 @@ private:
|
|||
const Image::PixelFormat format = transparent ? Image::ARGB : Image::RGB;
|
||||
|
||||
if (image == 0 || image->getWidth() < w || image->getHeight() < h || image->getFormat() != format)
|
||||
{
|
||||
delete image;
|
||||
image = new WindowsBitmapImage (format, (w + 31) & ~31, (h + 31) & ~31, false);
|
||||
}
|
||||
|
||||
startTimer (3000);
|
||||
return image;
|
||||
|
|
@ -873,11 +863,11 @@ private:
|
|||
void timerCallback()
|
||||
{
|
||||
stopTimer();
|
||||
deleteAndZero (image);
|
||||
image = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
WindowsBitmapImage* image;
|
||||
ScopedPointer <WindowsBitmapImage> image;
|
||||
|
||||
TemporaryImage (const TemporaryImage&);
|
||||
TemporaryImage& operator= (const TemporaryImage&);
|
||||
|
|
@ -1526,35 +1516,15 @@ private:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
class JuceDropTarget : public IDropTarget
|
||||
class JuceDropTarget : public ComBaseClassHelper <IDropTarget>
|
||||
{
|
||||
public:
|
||||
JuceDropTarget (Win32ComponentPeer* const owner_)
|
||||
: owner (owner_),
|
||||
refCount (1)
|
||||
: owner (owner_)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JuceDropTarget()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IDropTarget)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
~JuceDropTarget() {}
|
||||
|
||||
HRESULT __stdcall DragEnter (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect)
|
||||
{
|
||||
|
|
@ -1587,7 +1557,6 @@ private:
|
|||
|
||||
private:
|
||||
Win32ComponentPeer* const owner;
|
||||
int refCount;
|
||||
StringArray files;
|
||||
|
||||
void updateFileList (IDataObject* const pDataObject)
|
||||
|
|
@ -2411,15 +2380,13 @@ static Image* createImageFromHICON (HICON icon) throw()
|
|||
|
||||
if (GetIconInfo (icon, &info))
|
||||
{
|
||||
Image* const mask = createImageFromHBITMAP (info.hbmMask);
|
||||
|
||||
ScopedPointer<Image> mask (createImageFromHBITMAP (info.hbmMask));
|
||||
if (mask == 0)
|
||||
return 0;
|
||||
|
||||
Image* const image = createImageFromHBITMAP (info.hbmColor);
|
||||
|
||||
ScopedPointer<Image> image (createImageFromHBITMAP (info.hbmColor));
|
||||
if (image == 0)
|
||||
return mask;
|
||||
return mask.release();
|
||||
|
||||
for (int y = image->getHeight(); --y >= 0;)
|
||||
{
|
||||
|
|
@ -2432,8 +2399,7 @@ static Image* createImageFromHICON (HICON icon) throw()
|
|||
}
|
||||
}
|
||||
|
||||
delete mask;
|
||||
return image;
|
||||
return image.release();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -2673,36 +2639,11 @@ void MouseCursor::showInAllWindows() const
|
|||
|
||||
//==============================================================================
|
||||
//==============================================================================
|
||||
class JuceDropSource : public IDropSource
|
||||
class JuceDropSource : public ComBaseClassHelper <IDropSource>
|
||||
{
|
||||
int refCount;
|
||||
|
||||
public:
|
||||
JuceDropSource()
|
||||
: refCount (1)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JuceDropSource()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IDropSource)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
JuceDropSource() {}
|
||||
~JuceDropSource() {}
|
||||
|
||||
HRESULT __stdcall QueryContinueDrag (BOOL escapePressed, DWORD keys)
|
||||
{
|
||||
|
|
@ -2722,36 +2663,16 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class JuceEnumFormatEtc : public IEnumFORMATETC
|
||||
class JuceEnumFormatEtc : public ComBaseClassHelper <IEnumFORMATETC>
|
||||
{
|
||||
public:
|
||||
JuceEnumFormatEtc (const FORMATETC* const format_)
|
||||
: refCount (1),
|
||||
format (format_),
|
||||
: format (format_),
|
||||
index (0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~JuceEnumFormatEtc()
|
||||
{
|
||||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IEnumFORMATETC)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
~JuceEnumFormatEtc() {}
|
||||
|
||||
HRESULT __stdcall Clone (IEnumFORMATETC** result)
|
||||
{
|
||||
|
|
@ -2802,7 +2723,6 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
int refCount;
|
||||
const FORMATETC* const format;
|
||||
int index;
|
||||
|
||||
|
|
@ -2821,12 +2741,11 @@ private:
|
|||
JuceEnumFormatEtc& operator= (const JuceEnumFormatEtc&);
|
||||
};
|
||||
|
||||
class JuceDataObject : public IDataObject
|
||||
class JuceDataObject : public ComBaseClassHelper <IDataObject>
|
||||
{
|
||||
JuceDropSource* const dropSource;
|
||||
const FORMATETC* const format;
|
||||
const STGMEDIUM* const medium;
|
||||
int refCount;
|
||||
|
||||
JuceDataObject (const JuceDataObject&);
|
||||
JuceDataObject& operator= (const JuceDataObject&);
|
||||
|
|
@ -2837,8 +2756,7 @@ public:
|
|||
const STGMEDIUM* const medium_)
|
||||
: dropSource (dropSource_),
|
||||
format (format_),
|
||||
medium (medium_),
|
||||
refCount (1)
|
||||
medium (medium_)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -2847,22 +2765,6 @@ public:
|
|||
jassert (refCount == 0);
|
||||
}
|
||||
|
||||
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
|
||||
{
|
||||
if (id == IID_IUnknown || id == IID_IDataObject)
|
||||
{
|
||||
AddRef();
|
||||
*result = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*result = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG __stdcall AddRef() { return ++refCount; }
|
||||
ULONG __stdcall Release() { jassert (refCount > 0); const int r = --refCount; if (r == 0) delete this; return r; }
|
||||
|
||||
HRESULT __stdcall GetData (FORMATETC __RPC_FAR* pFormatEtc, STGMEDIUM __RPC_FAR* pMedium)
|
||||
{
|
||||
if ((pFormatEtc->tymed & format->tymed) != 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue