fix some issues when writing binary data into an XML file
This commit is contained in:
parent
e2813c845f
commit
435d4f82d7
|
@ -296,7 +296,7 @@ void PropertyFileIncluded::Restore(Base::XMLReader &reader)
|
|||
|
||||
void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const
|
||||
{
|
||||
std::ifstream from(_cValue.c_str());
|
||||
Base::ifstream from(Base::FileInfo(_cValue.c_str()));
|
||||
if (!from)
|
||||
throw Base::Exception("PropertyFileIncluded::SaveDocFile() "
|
||||
"File in document transient dir deleted");
|
||||
|
@ -311,7 +311,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const
|
|||
|
||||
void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader)
|
||||
{
|
||||
std::ofstream to(_cValue.c_str());
|
||||
Base::ofstream to(Base::FileInfo(_cValue.c_str()));
|
||||
if (!to)
|
||||
throw Base::Exception("PropertyFileIncluded::RestoreDocFile() "
|
||||
"File in document transient dir deleted");
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "Exception.h"
|
||||
#include "Base64.h"
|
||||
#include "FileInfo.h"
|
||||
#include "Stream.h"
|
||||
#include "Tools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -59,19 +60,24 @@ Writer::~Writer()
|
|||
|
||||
void Writer::insertAsciiFile(const char* FileName)
|
||||
{
|
||||
std::ifstream from(FileName);
|
||||
if (!from) throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
Base::FileInfo fi(FileName);
|
||||
Base::ifstream from(fi);
|
||||
if (!from)
|
||||
throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
|
||||
Stream() << "<![CDATA[" << endl;
|
||||
char ch;
|
||||
while (from.get(ch)) Stream().put(ch);
|
||||
while (from.get(ch))
|
||||
Stream().put(ch);
|
||||
Stream() << endl << "]]>" << endl;
|
||||
}
|
||||
|
||||
void Writer::insertBinFile(const char* FileName)
|
||||
{
|
||||
std::ifstream from(FileName);
|
||||
if (!from) throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
Base::FileInfo fi(FileName);
|
||||
Base::ifstream from(fi, std::ios::in | std::ios::binary);
|
||||
if (!from)
|
||||
throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
|
||||
Stream() << "<![CDATA[" << endl;
|
||||
|
||||
|
@ -79,8 +85,8 @@ void Writer::insertBinFile(const char* FileName)
|
|||
std::string encoded;
|
||||
unsigned int i;
|
||||
|
||||
while (from){
|
||||
for(i=0 ; i<60 && from;i++)
|
||||
while (from) {
|
||||
for (i=0 ; i<60 && from;i++)
|
||||
buf[i] = from.get();
|
||||
Stream() << Base::base64_encode(buf,i) << endl;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user