mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-13 00:04:19 +00:00
String tokenisation clean-up.
This commit is contained in:
parent
ed0ed361f0
commit
eabc372ea9
6 changed files with 174 additions and 240 deletions
|
|
@ -7629,25 +7629,25 @@ const String File::addTrailingSeparator (const String& path)
|
|||
}
|
||||
|
||||
#if JUCE_LINUX
|
||||
#define NAMES_ARE_CASE_SENSITIVE 1
|
||||
#define NAMES_ARE_CASE_SENSITIVE 1
|
||||
#endif
|
||||
|
||||
bool File::areFileNamesCaseSensitive()
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator== (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath == other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.equalsIgnoreCase (other.fullPath);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator!= (const File& other) const
|
||||
|
|
@ -7657,20 +7657,20 @@ bool File::operator!= (const File& other) const
|
|||
|
||||
bool File::operator< (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath < other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.compareIgnoreCase (other.fullPath) < 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator> (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath > other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.compareIgnoreCase (other.fullPath) > 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::setReadOnly (const bool shouldBeReadOnly,
|
||||
|
|
@ -7711,9 +7711,9 @@ bool File::moveFileTo (const File& newFile) const
|
|||
if (newFile.fullPath == fullPath)
|
||||
return true;
|
||||
|
||||
#if ! NAMES_ARE_CASE_SENSITIVE
|
||||
#if ! NAMES_ARE_CASE_SENSITIVE
|
||||
if (*this != newFile)
|
||||
#endif
|
||||
#endif
|
||||
if (! newFile.deleteFile())
|
||||
return false;
|
||||
|
||||
|
|
@ -7801,11 +7801,11 @@ bool File::isAChildOf (const File& potentialParent) const
|
|||
|
||||
const String ourPath (getPathUpToLastSlash());
|
||||
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
if (potentialParent.fullPath == ourPath)
|
||||
#else
|
||||
#else
|
||||
if (potentialParent.fullPath.equalsIgnoreCase (ourPath))
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -7888,26 +7888,11 @@ const File File::getSiblingFile (const String& fileName) const
|
|||
|
||||
const String File::descriptionOfSizeInBytes (const int64 bytes)
|
||||
{
|
||||
if (bytes == 1)
|
||||
{
|
||||
return "1 byte";
|
||||
}
|
||||
else if (bytes < 1024)
|
||||
{
|
||||
return String ((int) bytes) + " bytes";
|
||||
}
|
||||
else if (bytes < 1024 * 1024)
|
||||
{
|
||||
return String (bytes / 1024.0, 1) + " KB";
|
||||
}
|
||||
else if (bytes < 1024 * 1024 * 1024)
|
||||
{
|
||||
return String (bytes / (1024.0 * 1024.0), 1) + " MB";
|
||||
}
|
||||
else
|
||||
{
|
||||
return String (bytes / (1024.0 * 1024.0 * 1024.0), 1) + " GB";
|
||||
}
|
||||
if (bytes == 1) return "1 byte";
|
||||
else if (bytes < 1024) return String (bytes) + " bytes";
|
||||
else if (bytes < 1024 * 1024) return String (bytes / 1024.0, 1) + " KB";
|
||||
else if (bytes < 1024 * 1024 * 1024) return String (bytes / (1024.0 * 1024.0), 1) + " MB";
|
||||
else return String (bytes / (1024.0 * 1024.0 * 1024.0), 1) + " GB";
|
||||
}
|
||||
|
||||
bool File::create() const
|
||||
|
|
@ -7943,26 +7928,9 @@ bool File::createDirectory() const
|
|||
return true;
|
||||
}
|
||||
|
||||
const Time File::getCreationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (c);
|
||||
}
|
||||
|
||||
const Time File::getLastModificationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (m);
|
||||
}
|
||||
|
||||
const Time File::getLastAccessTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (a);
|
||||
}
|
||||
const Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (m); }
|
||||
const Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (a); }
|
||||
const Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (c); }
|
||||
|
||||
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); }
|
||||
|
|
@ -8041,7 +8009,7 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
{
|
||||
putNumbersInBrackets = true;
|
||||
|
||||
const int openBracks = prefix.lastIndexOfChar ('(');
|
||||
const int openBracks = prefix.lastIndexOfChar ('(');
|
||||
const int closeBracks = prefix.lastIndexOfChar (')');
|
||||
|
||||
if (openBracks > 0
|
||||
|
|
@ -8059,10 +8027,14 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
|
||||
do
|
||||
{
|
||||
String newName (prefix);
|
||||
|
||||
if (putNumbersInBrackets)
|
||||
f = getChildFile (prefix + '(' + String (num++) + ')' + suffix);
|
||||
newName << '(' << num++ << ')';
|
||||
else
|
||||
f = getChildFile (prefix + String (num++) + suffix);
|
||||
newName << num++;
|
||||
|
||||
f = getChildFile (newName + suffix);
|
||||
|
||||
} while (f.exists());
|
||||
}
|
||||
|
|
@ -8073,16 +8045,11 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
const File File::getNonexistentSibling (const bool putNumbersInBrackets) const
|
||||
{
|
||||
if (exists())
|
||||
{
|
||||
return getParentDirectory()
|
||||
.getNonexistentChildFile (getFileNameWithoutExtension(),
|
||||
getFileExtension(),
|
||||
putNumbersInBrackets);
|
||||
}
|
||||
else
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const String File::getFileExtension() const
|
||||
|
|
@ -8232,9 +8199,7 @@ bool File::hasIdenticalContentTo (const File& other) const
|
|||
FileInputStream in1 (*this), in2 (other);
|
||||
|
||||
const int bufferSize = 4096;
|
||||
HeapBlock <char> buffer1, buffer2;
|
||||
buffer1.malloc (bufferSize);
|
||||
buffer2.malloc (bufferSize);
|
||||
HeapBlock <char> buffer1 (bufferSize), buffer2 (bufferSize);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -8341,11 +8306,11 @@ const String File::getRelativePathFrom (const File& dir) const
|
|||
|
||||
while (dirPath.isNotEmpty())
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
#if JUCE_WINDOWS
|
||||
thisPath = "..\\" + thisPath;
|
||||
#else
|
||||
#else
|
||||
thisPath = "../" + thisPath;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const int sep = dirPath.indexOfChar (separator);
|
||||
|
||||
|
|
@ -8366,8 +8331,8 @@ const File File::createTempFile (const String& fileNameEnding)
|
|||
|
||||
if (tempFile.exists())
|
||||
return createTempFile (fileNameEnding);
|
||||
else
|
||||
return tempFile;
|
||||
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
#if JUCE_UNIT_TESTS
|
||||
|
|
@ -14307,48 +14272,25 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c
|
|||
|
||||
if (text.isNotEmpty())
|
||||
{
|
||||
bool insideQuotes = false;
|
||||
juce_wchar currentQuoteChar = 0;
|
||||
|
||||
String::CharPointerType t (text.getCharPointer());
|
||||
String::CharPointerType tokenStart (t);
|
||||
int numChars = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = t.getAndAdvance();
|
||||
++numChars;
|
||||
String::CharPointerType tokenEnd (CharacterFunctions::findEndOfToken (t,
|
||||
breakCharacters.getCharPointer(),
|
||||
quoteCharacters.getCharPointer()));
|
||||
|
||||
const bool isBreak = (c == 0) || ((! insideQuotes) && breakCharacters.containsChar (c));
|
||||
|
||||
if (! isBreak)
|
||||
{
|
||||
if (quoteCharacters.containsChar (c))
|
||||
{
|
||||
if (insideQuotes)
|
||||
{
|
||||
// only break out of quotes-mode if we find a matching quote to the
|
||||
// one that we opened with..
|
||||
if (currentQuoteChar == c)
|
||||
insideQuotes = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
insideQuotes = true;
|
||||
currentQuoteChar = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add (String (tokenStart, numChars - 1));
|
||||
++num;
|
||||
tokenStart = t;
|
||||
numChars = 0;
|
||||
}
|
||||
|
||||
if (c == 0)
|
||||
if (tokenEnd == t)
|
||||
break;
|
||||
|
||||
add (String (t, tokenEnd));
|
||||
++num;
|
||||
t = tokenEnd;
|
||||
|
||||
if (t.isEmpty())
|
||||
break;
|
||||
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244430,9 +244372,7 @@ void PlatformUtilities::registerFileAssociation (const String& fileExtension,
|
|||
targetExecutable.getFullPathName() + "," + String (-iconResourceNumber));
|
||||
|
||||
setRegistryValue (key + "\\", fullDescription);
|
||||
|
||||
setRegistryValue (key + "\\shell\\open\\command\\",
|
||||
targetExecutable.getFullPathName() + " %1");
|
||||
setRegistryValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1");
|
||||
}
|
||||
|
||||
bool juce_IsRunningInWine()
|
||||
|
|
@ -244449,12 +244389,10 @@ bool juce_IsRunningInWine()
|
|||
|
||||
const String JUCE_CALLTYPE PlatformUtilities::getCurrentCommandLineParams()
|
||||
{
|
||||
String s (::GetCommandLineW());
|
||||
|
||||
StringArray tokens;
|
||||
tokens.addTokens (s, true); // tokenise so that we can remove the initial filename argument
|
||||
|
||||
return tokens.joinIntoString (" ", 1);
|
||||
const String commandLine (GetCommandLineW());
|
||||
return String (CharacterFunctions::findEndOfToken (commandLine.getCharPointer(),
|
||||
String (" ").getCharPointer(),
|
||||
String ("\"").getCharPointer())).trimStart();
|
||||
}
|
||||
|
||||
static void* currentModuleHandle = 0;
|
||||
|
|
|
|||
|
|
@ -2079,6 +2079,34 @@ public:
|
|||
return p;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
static Type findEndOfToken (const Type& text, const Type& breakCharacters, const Type& quoteCharacters)
|
||||
{
|
||||
Type t (text);
|
||||
juce_wchar currentQuoteChar = 0;
|
||||
|
||||
while (! t.isEmpty())
|
||||
{
|
||||
const juce_wchar c = t.getAndAdvance();
|
||||
|
||||
if (currentQuoteChar == 0 && breakCharacters.indexOf (c) >= 0)
|
||||
{
|
||||
--t;
|
||||
break;
|
||||
}
|
||||
|
||||
if (quoteCharacters.indexOf (c) >= 0)
|
||||
{
|
||||
if (currentQuoteChar == 0)
|
||||
currentQuoteChar = c;
|
||||
else if (currentQuoteChar == c)
|
||||
currentQuoteChar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
private:
|
||||
static double mulexp10 (const double value, int exponent) throw();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -173,25 +173,25 @@ const String File::addTrailingSeparator (const String& path)
|
|||
|
||||
//==============================================================================
|
||||
#if JUCE_LINUX
|
||||
#define NAMES_ARE_CASE_SENSITIVE 1
|
||||
#define NAMES_ARE_CASE_SENSITIVE 1
|
||||
#endif
|
||||
|
||||
bool File::areFileNamesCaseSensitive()
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator== (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath == other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.equalsIgnoreCase (other.fullPath);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator!= (const File& other) const
|
||||
|
|
@ -201,20 +201,20 @@ bool File::operator!= (const File& other) const
|
|||
|
||||
bool File::operator< (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath < other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.compareIgnoreCase (other.fullPath) < 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool File::operator> (const File& other) const
|
||||
{
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
return fullPath > other.fullPath;
|
||||
#else
|
||||
#else
|
||||
return fullPath.compareIgnoreCase (other.fullPath) > 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -256,9 +256,9 @@ bool File::moveFileTo (const File& newFile) const
|
|||
if (newFile.fullPath == fullPath)
|
||||
return true;
|
||||
|
||||
#if ! NAMES_ARE_CASE_SENSITIVE
|
||||
#if ! NAMES_ARE_CASE_SENSITIVE
|
||||
if (*this != newFile)
|
||||
#endif
|
||||
#endif
|
||||
if (! newFile.deleteFile())
|
||||
return false;
|
||||
|
||||
|
|
@ -348,11 +348,11 @@ bool File::isAChildOf (const File& potentialParent) const
|
|||
|
||||
const String ourPath (getPathUpToLastSlash());
|
||||
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
#if NAMES_ARE_CASE_SENSITIVE
|
||||
if (potentialParent.fullPath == ourPath)
|
||||
#else
|
||||
#else
|
||||
if (potentialParent.fullPath.equalsIgnoreCase (ourPath))
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -437,26 +437,11 @@ const File File::getSiblingFile (const String& fileName) const
|
|||
//==============================================================================
|
||||
const String File::descriptionOfSizeInBytes (const int64 bytes)
|
||||
{
|
||||
if (bytes == 1)
|
||||
{
|
||||
return "1 byte";
|
||||
}
|
||||
else if (bytes < 1024)
|
||||
{
|
||||
return String ((int) bytes) + " bytes";
|
||||
}
|
||||
else if (bytes < 1024 * 1024)
|
||||
{
|
||||
return String (bytes / 1024.0, 1) + " KB";
|
||||
}
|
||||
else if (bytes < 1024 * 1024 * 1024)
|
||||
{
|
||||
return String (bytes / (1024.0 * 1024.0), 1) + " MB";
|
||||
}
|
||||
else
|
||||
{
|
||||
return String (bytes / (1024.0 * 1024.0 * 1024.0), 1) + " GB";
|
||||
}
|
||||
if (bytes == 1) return "1 byte";
|
||||
else if (bytes < 1024) return String (bytes) + " bytes";
|
||||
else if (bytes < 1024 * 1024) return String (bytes / 1024.0, 1) + " KB";
|
||||
else if (bytes < 1024 * 1024 * 1024) return String (bytes / (1024.0 * 1024.0), 1) + " MB";
|
||||
else return String (bytes / (1024.0 * 1024.0 * 1024.0), 1) + " GB";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -494,26 +479,9 @@ bool File::createDirectory() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
const Time File::getCreationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (c);
|
||||
}
|
||||
|
||||
const Time File::getLastModificationTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (m);
|
||||
}
|
||||
|
||||
const Time File::getLastAccessTime() const
|
||||
{
|
||||
int64 m, a, c;
|
||||
getFileTimesInternal (m, a, c);
|
||||
return Time (a);
|
||||
}
|
||||
const Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (m); }
|
||||
const Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (a); }
|
||||
const Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (c); }
|
||||
|
||||
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); }
|
||||
|
|
@ -595,7 +563,7 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
{
|
||||
putNumbersInBrackets = true;
|
||||
|
||||
const int openBracks = prefix.lastIndexOfChar ('(');
|
||||
const int openBracks = prefix.lastIndexOfChar ('(');
|
||||
const int closeBracks = prefix.lastIndexOfChar (')');
|
||||
|
||||
if (openBracks > 0
|
||||
|
|
@ -613,10 +581,14 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
|
||||
do
|
||||
{
|
||||
String newName (prefix);
|
||||
|
||||
if (putNumbersInBrackets)
|
||||
f = getChildFile (prefix + '(' + String (num++) + ')' + suffix);
|
||||
newName << '(' << num++ << ')';
|
||||
else
|
||||
f = getChildFile (prefix + String (num++) + suffix);
|
||||
newName << num++;
|
||||
|
||||
f = getChildFile (newName + suffix);
|
||||
|
||||
} while (f.exists());
|
||||
}
|
||||
|
|
@ -627,16 +599,11 @@ const File File::getNonexistentChildFile (const String& prefix_,
|
|||
const File File::getNonexistentSibling (const bool putNumbersInBrackets) const
|
||||
{
|
||||
if (exists())
|
||||
{
|
||||
return getParentDirectory()
|
||||
.getNonexistentChildFile (getFileNameWithoutExtension(),
|
||||
getFileExtension(),
|
||||
putNumbersInBrackets);
|
||||
}
|
||||
else
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -790,9 +757,7 @@ bool File::hasIdenticalContentTo (const File& other) const
|
|||
FileInputStream in1 (*this), in2 (other);
|
||||
|
||||
const int bufferSize = 4096;
|
||||
HeapBlock <char> buffer1, buffer2;
|
||||
buffer1.malloc (bufferSize);
|
||||
buffer2.malloc (bufferSize);
|
||||
HeapBlock <char> buffer1 (bufferSize), buffer2 (bufferSize);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -901,11 +866,11 @@ const String File::getRelativePathFrom (const File& dir) const
|
|||
|
||||
while (dirPath.isNotEmpty())
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
#if JUCE_WINDOWS
|
||||
thisPath = "..\\" + thisPath;
|
||||
#else
|
||||
#else
|
||||
thisPath = "../" + thisPath;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const int sep = dirPath.indexOfChar (separator);
|
||||
|
||||
|
|
@ -927,10 +892,12 @@ const File File::createTempFile (const String& fileNameEnding)
|
|||
|
||||
if (tempFile.exists())
|
||||
return createTempFile (fileNameEnding);
|
||||
else
|
||||
return tempFile;
|
||||
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_UNIT_TESTS
|
||||
|
||||
#include "../../utilities/juce_UnitTest.h"
|
||||
|
|
|
|||
|
|
@ -172,9 +172,7 @@ void PlatformUtilities::registerFileAssociation (const String& fileExtension,
|
|||
targetExecutable.getFullPathName() + "," + String (-iconResourceNumber));
|
||||
|
||||
setRegistryValue (key + "\\", fullDescription);
|
||||
|
||||
setRegistryValue (key + "\\shell\\open\\command\\",
|
||||
targetExecutable.getFullPathName() + " %1");
|
||||
setRegistryValue (key + "\\shell\\open\\command\\", targetExecutable.getFullPathName() + " %1");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -194,12 +192,10 @@ bool juce_IsRunningInWine()
|
|||
//==============================================================================
|
||||
const String JUCE_CALLTYPE PlatformUtilities::getCurrentCommandLineParams()
|
||||
{
|
||||
String s (::GetCommandLineW());
|
||||
|
||||
StringArray tokens;
|
||||
tokens.addTokens (s, true); // tokenise so that we can remove the initial filename argument
|
||||
|
||||
return tokens.joinIntoString (" ", 1);
|
||||
const String commandLine (GetCommandLineW());
|
||||
return String (CharacterFunctions::findEndOfToken (commandLine.getCharPointer(),
|
||||
String (" ").getCharPointer(),
|
||||
String ("\"").getCharPointer())).trimStart();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -500,6 +500,34 @@ public:
|
|||
return p;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
static Type findEndOfToken (const Type& text, const Type& breakCharacters, const Type& quoteCharacters)
|
||||
{
|
||||
Type t (text);
|
||||
juce_wchar currentQuoteChar = 0;
|
||||
|
||||
while (! t.isEmpty())
|
||||
{
|
||||
const juce_wchar c = t.getAndAdvance();
|
||||
|
||||
if (currentQuoteChar == 0 && breakCharacters.indexOf (c) >= 0)
|
||||
{
|
||||
--t;
|
||||
break;
|
||||
}
|
||||
|
||||
if (quoteCharacters.indexOf (c) >= 0)
|
||||
{
|
||||
if (currentQuoteChar == 0)
|
||||
currentQuoteChar = c;
|
||||
else if (currentQuoteChar == c)
|
||||
currentQuoteChar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
private:
|
||||
static double mulexp10 (const double value, int exponent) throw();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -354,48 +354,25 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c
|
|||
|
||||
if (text.isNotEmpty())
|
||||
{
|
||||
bool insideQuotes = false;
|
||||
juce_wchar currentQuoteChar = 0;
|
||||
|
||||
String::CharPointerType t (text.getCharPointer());
|
||||
String::CharPointerType tokenStart (t);
|
||||
int numChars = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = t.getAndAdvance();
|
||||
++numChars;
|
||||
String::CharPointerType tokenEnd (CharacterFunctions::findEndOfToken (t,
|
||||
breakCharacters.getCharPointer(),
|
||||
quoteCharacters.getCharPointer()));
|
||||
|
||||
const bool isBreak = (c == 0) || ((! insideQuotes) && breakCharacters.containsChar (c));
|
||||
|
||||
if (! isBreak)
|
||||
{
|
||||
if (quoteCharacters.containsChar (c))
|
||||
{
|
||||
if (insideQuotes)
|
||||
{
|
||||
// only break out of quotes-mode if we find a matching quote to the
|
||||
// one that we opened with..
|
||||
if (currentQuoteChar == c)
|
||||
insideQuotes = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
insideQuotes = true;
|
||||
currentQuoteChar = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add (String (tokenStart, numChars - 1));
|
||||
++num;
|
||||
tokenStart = t;
|
||||
numChars = 0;
|
||||
}
|
||||
|
||||
if (c == 0)
|
||||
if (tokenEnd == t)
|
||||
break;
|
||||
|
||||
add (String (t, tokenEnd));
|
||||
++num;
|
||||
t = tokenEnd;
|
||||
|
||||
if (t.isEmpty())
|
||||
break;
|
||||
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue