mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Use new FSTREAM_PATH() macro to open fstreams
This commit is contained in:
parent
a4e7df6037
commit
cf8cd97cb6
@ -17,6 +17,7 @@
|
||||
#include "base/convert_to.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/path.h"
|
||||
#include "base/serialization.h"
|
||||
#include "base/string.h"
|
||||
@ -46,14 +47,6 @@ using namespace base::serialization;
|
||||
using namespace base::serialization::little_endian;
|
||||
using namespace doc;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define IFSTREAM(dir, name, fn) \
|
||||
std::ifstream name(base::from_utf8(base::join_path(dir, fn)), std::ifstream::binary);
|
||||
#else
|
||||
#define IFSTREAM(dir, name, fn) \
|
||||
std::ifstream name(base::join_path(dir, fn).c_str(), std::ifstream::binary);
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
class Reader : public SubObjectsIO {
|
||||
@ -154,7 +147,7 @@ private:
|
||||
fn.push_back('.');
|
||||
fn += base::convert_to<std::string>(ver);
|
||||
|
||||
IFSTREAM(m_dir, s, fn);
|
||||
std::ifstream s(FSTREAM_PATH(base::join_path(m_dir, fn)), std::ifstream::binary);
|
||||
T obj = nullptr;
|
||||
if (read32(s) == MAGIC_NUMBER)
|
||||
obj = (this->*readMember)(s);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/path.h"
|
||||
#include "base/process.h"
|
||||
#include "base/split_string.h"
|
||||
@ -103,13 +104,8 @@ void Session::create(base::pid pid)
|
||||
{
|
||||
m_pid = pid;
|
||||
|
||||
#ifdef _WIN32
|
||||
std::ofstream pidf(base::from_utf8(pidFilename()));
|
||||
std::ofstream verf(base::from_utf8(verFilename()));
|
||||
#else
|
||||
std::ofstream pidf(pidFilename().c_str());
|
||||
std::ofstream verf(verFilename().c_str());
|
||||
#endif
|
||||
std::ofstream pidf(FSTREAM_PATH(pidFilename()));
|
||||
std::ofstream verf(FSTREAM_PATH(verFilename()));
|
||||
|
||||
pidf << m_pid;
|
||||
verf << VERSION;
|
||||
@ -213,11 +209,7 @@ void Session::loadPid()
|
||||
|
||||
std::string pidfile = pidFilename();
|
||||
if (base::is_file(pidfile)) {
|
||||
#ifdef _WIN32
|
||||
std::ifstream pf(base::from_utf8(pidfile));
|
||||
#else
|
||||
std::ifstream pf(pidfile.c_str());
|
||||
#endif
|
||||
std::ifstream pf(FSTREAM_PATH(pidfile));
|
||||
if (pf)
|
||||
pf >> m_pid;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "app/document.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/path.h"
|
||||
#include "base/serialization.h"
|
||||
#include "base/string.h"
|
||||
@ -43,14 +44,6 @@ using namespace base::serialization;
|
||||
using namespace base::serialization::little_endian;
|
||||
using namespace doc;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define OFSTREAM(name, fullfn) \
|
||||
std::ofstream name(base::from_utf8(fullfn), std::ofstream::binary);
|
||||
#else
|
||||
#define OFSTREAM(name, fullfn) \
|
||||
std::ofstream name(fullfn.c_str(), std::ofstream::binary);
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
static std::map<ObjectId, ObjVersionsMap> g_docVersions;
|
||||
@ -178,7 +171,7 @@ private:
|
||||
std::string oldfn = fullfn + "." + base::convert_to<std::string>(versions.older());
|
||||
fullfn += "." + base::convert_to<std::string>(obj->version());
|
||||
|
||||
OFSTREAM(s, fullfn);
|
||||
std::ofstream s(FSTREAM_PATH(fullfn), std::ofstream::binary);
|
||||
write32(s, 0); // Leave a room for the magic number
|
||||
(this->*writeMember)(s, obj); // Write the object
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "app/filename_formatter.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/path.h"
|
||||
#include "base/shared_ptr.h"
|
||||
#include "base/string.h"
|
||||
@ -266,11 +267,7 @@ Document* DocumentExporter::exportSheet()
|
||||
if (m_dataFilename.empty())
|
||||
osbuf = std::cout.rdbuf();
|
||||
else {
|
||||
#ifdef _WIN32
|
||||
fos.open(base::from_utf8(m_dataFilename).c_str(), std::ios::out);
|
||||
#else
|
||||
fos.open(m_dataFilename.c_str(), std::ios::out);
|
||||
#endif
|
||||
fos.open(FSTREAM_PATH(m_dataFilename), std::ios::out);
|
||||
osbuf = fos.rdbuf();
|
||||
}
|
||||
std::ostream os(osbuf);
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/path.h"
|
||||
#include "base/replace_string.h"
|
||||
#include "base/scoped_value.h"
|
||||
@ -59,11 +60,7 @@ void HttpLoader::threadHttpRequest()
|
||||
base::replace_string(fn, "&", "-");
|
||||
fn = base::join_path(dir, fn);
|
||||
|
||||
#ifdef _WIN32
|
||||
std::ofstream output(base::from_utf8(fn).c_str());
|
||||
#else
|
||||
std::ofstream output(fn.c_str());
|
||||
#endif
|
||||
std::ofstream output(FSTREAM_PATH(fn));
|
||||
net::HttpRequest http(m_url);
|
||||
net::HttpResponse response(&output);
|
||||
http.send(response);
|
||||
|
@ -8,11 +8,12 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/sha1.h"
|
||||
#include "base/sha1_rfc3174.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -32,7 +33,7 @@ Sha1 Sha1::calculateFromFile(const std::string& fileName)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
ifstream file(fileName.c_str(), ios::in | ios::binary);
|
||||
ifstream file(FSTREAM_PATH(fileName), ios::in | ios::binary);
|
||||
if (!file.good())
|
||||
return Sha1();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user