1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-22 01:34:21 +00:00

Introjucer: added "save as"

This commit is contained in:
jules 2013-03-30 13:06:00 +00:00
parent 1bf9f441e6
commit 12c28fd882
9 changed files with 67 additions and 30 deletions

View file

@ -63,27 +63,44 @@ void SourceCodeDocument::reloadInternal()
{
jassert (codeDoc != nullptr);
modDetector.updateHash();
codeDoc->applyChanges (modDetector.getFile().loadFileAsString());
codeDoc->applyChanges (getFile().loadFileAsString());
codeDoc->setSavePoint();
}
bool SourceCodeDocument::save()
static bool writeCodeDocToFile (const File& file, CodeDocument& doc)
{
TemporaryFile temp (modDetector.getFile());
TemporaryFile temp (file);
{
FileOutputStream fo (temp.getFile());
if (! (fo.openedOk() && getCodeDocument().writeToStream (fo)))
if (! (fo.openedOk() && doc.writeToStream (fo)))
return false;
}
if (! temp.overwriteTargetFileWithTemporary())
return false;
return temp.overwriteTargetFileWithTemporary();
}
getCodeDocument().setSavePoint();
modDetector.updateHash();
return true;
bool SourceCodeDocument::save()
{
if (writeCodeDocToFile (getFile(), getCodeDocument()))
{
getCodeDocument().setSavePoint();
modDetector.updateHash();
return true;
}
return false;
}
bool SourceCodeDocument::saveAs()
{
FileChooser fc (TRANS("Save As..."), getFile(), "*");
if (! fc.browseForFileToSave (true))
return true;
return writeCodeDocToFile (fc.getResult(), getCodeDocument());
}
void SourceCodeDocument::updateLastState (CodeEditorComponent& editor)