mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 21:39:57 +00:00
Fix loading/saving .gpl files inside folders with Unicode chars on Windows
This commit is contained in:
parent
104e5e6479
commit
a4e7df6037
19
src/base/fstream_path.h
Normal file
19
src/base/fstream_path.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Aseprite Base Library
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef BASE_FSTREAM_PATH_H_INCLUDED
|
||||
#define BASE_FSTREAM_PATH_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/string.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FSTREAM_PATH(path) (base::from_utf8(path).c_str())
|
||||
#else
|
||||
#define FSTREAM_PATH(path) ((path).c_str())
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2014 David Capello
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -8,24 +8,25 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/fstream_path.h"
|
||||
#include "base/split_string.h"
|
||||
#include "base/trim_string.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <cctype>
|
||||
|
||||
namespace doc {
|
||||
namespace file {
|
||||
|
||||
Palette* load_gpl_file(const char *filename)
|
||||
{
|
||||
std::ifstream f(filename);
|
||||
std::ifstream f(FSTREAM_PATH(filename));
|
||||
if (f.bad()) return NULL;
|
||||
|
||||
// Read first line, it must be "GIMP Palette"
|
||||
@ -68,7 +69,7 @@ Palette* load_gpl_file(const char *filename)
|
||||
|
||||
bool save_gpl_file(const Palette *pal, const char *filename)
|
||||
{
|
||||
std::ofstream f(filename);
|
||||
std::ofstream f(FSTREAM_PATH(filename));
|
||||
if (f.bad()) return false;
|
||||
|
||||
f << "GIMP Palette\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user