mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-02 03:20:06 +00:00
Introjucer: reporting of errors when resource files are missing when creating the binary data.
This commit is contained in:
parent
013b1ce000
commit
d130a8e338
3 changed files with 32 additions and 16 deletions
|
|
@ -109,7 +109,7 @@ static String getComment()
|
|||
return comment;
|
||||
}
|
||||
|
||||
bool ResourceFile::writeHeader (MemoryOutputStream& header)
|
||||
Result ResourceFile::writeHeader (MemoryOutputStream& header)
|
||||
{
|
||||
const String headerGuard ("BINARYDATA_H_" + String (project.getProjectUID().hashCode() & 0x7ffffff) + "_INCLUDED");
|
||||
|
||||
|
|
@ -126,6 +126,10 @@ bool ResourceFile::writeHeader (MemoryOutputStream& header)
|
|||
for (int i = 0; i < files.size(); ++i)
|
||||
{
|
||||
const File& file = files.getReference(i);
|
||||
|
||||
if (! file.existsAsFile())
|
||||
return Result::fail ("Can't open resource file: " + file.getFullPathName());
|
||||
|
||||
const int64 dataSize = file.getSize();
|
||||
|
||||
const String variableName (variableNames[i]);
|
||||
|
|
@ -155,10 +159,10 @@ bool ResourceFile::writeHeader (MemoryOutputStream& header)
|
|||
<< newLine
|
||||
<< "#endif" << newLine;
|
||||
|
||||
return true;
|
||||
return Result::ok();
|
||||
}
|
||||
|
||||
bool ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile, int& i, const int maxFileSize)
|
||||
Result ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile, int& i, const int maxFileSize)
|
||||
{
|
||||
const bool isFirstFile = (i == 0);
|
||||
|
||||
|
|
@ -247,17 +251,22 @@ bool ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile, in
|
|||
cpp << newLine
|
||||
<< "}" << newLine;
|
||||
|
||||
return true;
|
||||
return Result::ok();
|
||||
}
|
||||
|
||||
bool ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
|
||||
Result ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
|
||||
{
|
||||
const File headerFile (project.getBinaryDataHeaderFile());
|
||||
|
||||
{
|
||||
MemoryOutputStream mo;
|
||||
if (! (writeHeader (mo) && FileHelpers::overwriteFileWithNewDataIfDifferent (headerFile, mo)))
|
||||
return false;
|
||||
Result r (writeHeader (mo));
|
||||
|
||||
if (r.failed())
|
||||
return r;
|
||||
|
||||
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (headerFile, mo))
|
||||
return Result::fail ("Can't write to file: " + headerFile.getFullPathName());
|
||||
|
||||
filesCreated.add (headerFile);
|
||||
}
|
||||
|
|
@ -270,8 +279,14 @@ bool ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
|
|||
File cpp (project.getBinaryDataCppFile (fileIndex));
|
||||
|
||||
MemoryOutputStream mo;
|
||||
if (! (writeCpp (mo, headerFile, i, maxFileSize) && FileHelpers::overwriteFileWithNewDataIfDifferent (cpp, mo)))
|
||||
return false;
|
||||
|
||||
Result r (writeCpp (mo, headerFile, i, maxFileSize));
|
||||
|
||||
if (r.failed())
|
||||
return r;
|
||||
|
||||
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (cpp, mo))
|
||||
return Result::fail ("Can't write to file: " + cpp.getFullPathName());
|
||||
|
||||
filesCreated.add (cpp);
|
||||
++fileIndex;
|
||||
|
|
@ -280,5 +295,5 @@ bool ResourceFile::write (Array<File>& filesCreated, const int maxFileSize)
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return Result::ok();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue