#include <map>
#include <string.h>
-#include <fstream>
+#include <cstdint>
#include "resourcemgr.h"
#include "util.h"
#include "version.h"
#include "message.h"
#include "config.h"
+#include "portable.h"
class ResourceMgr::Private
{
bool ResourceMgr::writeCategory(const QCString &categoryName,const QCString &targetDir) const
{
- for (auto &kv : p->resources)
+ for (auto &[name,res] : p->resources)
{
- Resource &res = kv.second;
if (res.category==categoryName)
{
- std::string pathName = targetDir.str()+"/"+res.name;
- std::ofstream f(pathName,std::ofstream::out | std::ofstream::binary);
+ QCString pathName = targetDir+"/"+res.name;
+ std::ofstream f = Portable::openOutputStream(pathName);
bool ok=false;
if (f.is_open())
{
bool ResourceMgr::copyResourceAs(const QCString &name,const QCString &targetDir,const QCString &targetName,bool append) const
{
- std::string pathName = targetDir.str()+"/"+targetName.str();
- std::ios_base::openmode mode = std::ofstream::out | std::ofstream::binary;
- if (append) mode |= std::ofstream::app;
+ QCString pathName = targetDir+"/"+targetName;
const Resource *res = get(name);
if (res)
{
{
case Resource::Verbatim:
{
- std::ofstream f(pathName,mode);
+ std::ofstream f = Portable::openOutputStream(pathName,append);
bool ok=false;
if (f.is_open())
{
{
QCString n = name;
n = n.left(n.length()-4)+".png"; // replace .lum by .png
- const uchar *data = res->data;
- ushort width = (data[0]<<8)+data[1];
- ushort height = (data[2]<<8)+data[3];
+ const uint8_t *data = res->data;
+ uint16_t width = (data[0]<<8)+data[1];
+ uint16_t height = (data[2]<<8)+data[3];
ColoredImgDataItem images[2];
images[0].name = n.data();
images[0].width = width;
{
QCString n = name;
n = n.left(n.length()-5)+".png"; // replace .luma by .png
- const uchar *data = res->data;
- ushort width = (data[0]<<8)+data[1];
- ushort height = (data[2]<<8)+data[3];
+ const uint8_t *data = res->data;
+ uint16_t width = (data[0]<<8)+data[1];
+ uint16_t height = (data[2]<<8)+data[3];
ColoredImgDataItem images[2];
images[0].name = n.data();
images[0].width = width;
break;
case Resource::CSS:
{
- std::ofstream t(pathName,mode);
+ std::ofstream t = Portable::openOutputStream(pathName,append);
if (t.is_open())
{
QCString buf(res->size+1);
break;
case Resource::SVG:
{
- std::ofstream t(pathName,mode);
+ std::ofstream t = Portable::openOutputStream(pathName,append);
if (t.is_open())
{
QCString buf(res->size+1);