* Inherit from SimpleFileSaver, which enables the logic in

the application to set the file panel save text to the previous
   ref name.
 * Wait for the export thread to finish writing the file before
   trying to set the icon attribute. Usually it never worked when
   saving a file for the first time, since the file did not yet
   exist.
 * Report errors to std::err.
 * Code style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2011-04-04 09:21:43 +00:00
parent 1c4001e299
commit e62d9c79e1
2 changed files with 33 additions and 20 deletions

View File

@ -1,34 +1,48 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
* Copyright 2007, 2011, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "NativeSaver.h"
#include <stdio.h>
#include <string.h>
#include "FlatIconFormat.h"
#include "MessageExporter.h"
// constructor
NativeSaver::NativeSaver(const entry_ref& ref)
: fAttrSaver(ref, kVectorAttrNodeName),
fFileSaver(new MessageExporter(), ref)
:
SimpleFileSaver(new MessageExporter(), ref),
fAttrSaver(ref, kVectorAttrNodeName)
{
}
// destructor
NativeSaver::~NativeSaver()
{
}
// Save
status_t
NativeSaver::Save(Document* document)
{
status_t ret = fFileSaver.Save(document);
if (ret < B_OK)
status_t ret = SimpleFileSaver::Save(document);
if (ret != B_OK) {
fprintf(stderr, "Error saving icon: %s\n", strerror(ret));
return ret;
return fAttrSaver.Save(document);
}
WaitForExportThread();
ret = fAttrSaver.Save(document);
if (ret != B_OK) {
fprintf(stderr, "Error saving icon attribute: %s\n", strerror(ret));
return ret;
}
return B_OK;
}

View File

@ -1,17 +1,16 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
* Copyright 2007, 2011, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef NATIVE_SAVER_H
#define NATIVE_SAVER_H
#include "AttributeSaver.h"
#include "SimpleFileSaver.h"
class NativeSaver : public DocumentSaver {
class NativeSaver : public SimpleFileSaver {
public:
NativeSaver(const entry_ref& ref);
virtual ~NativeSaver();
@ -20,7 +19,7 @@ class NativeSaver : public DocumentSaver {
protected:
AttributeSaver fAttrSaver;
SimpleFileSaver fFileSaver;
};
#endif // NATIVE_SAVER_H