mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-10 10:13:35 +00:00
Change get_readable/writable_extensions() API from char* to std::string
This commit is contained in:
parent
79c30a9ef3
commit
5ef4cb1460
@ -265,8 +265,7 @@ protected:
|
||||
}
|
||||
|
||||
void onImageFilename() {
|
||||
char exts[4096];
|
||||
get_writable_extensions(exts, sizeof(exts));
|
||||
std::string exts = get_writable_extensions();
|
||||
|
||||
std::string newFilename = app::show_file_selector(
|
||||
"Save Sprite Sheet", m_filename, exts, FileSelectorType::Save);
|
||||
|
@ -41,9 +41,7 @@ LoadPaletteCommand::LoadPaletteCommand()
|
||||
|
||||
void LoadPaletteCommand::onExecute(Context* context)
|
||||
{
|
||||
char exts[4096];
|
||||
get_readable_palette_extensions(exts, sizeof(exts));
|
||||
|
||||
std::string exts = get_readable_palette_extensions();
|
||||
std::string filename =
|
||||
app::show_file_selector("Load Palette", "", exts,
|
||||
FileSelectorType::Open);
|
||||
|
@ -109,8 +109,7 @@ void OpenFileCommand::onExecute(Context* context)
|
||||
|
||||
// interactive
|
||||
if (context->isUiAvailable() && m_filename.empty()) {
|
||||
char exts[4096];
|
||||
get_readable_extensions(exts, sizeof(exts));
|
||||
std::string exts = get_readable_extensions();
|
||||
|
||||
// Add backslash as show_file_selector() expected a filename as
|
||||
// initial path (and the file part is removed from the path).
|
||||
|
@ -135,8 +135,7 @@ void SaveFileBaseCommand::saveAsDialog(const ContextReader& reader, const char*
|
||||
else {
|
||||
filename = document->filename();
|
||||
|
||||
char exts[4096];
|
||||
get_writable_extensions(exts, sizeof(exts));
|
||||
std::string exts = get_writable_extensions();
|
||||
|
||||
for (;;) {
|
||||
std::string newfilename = app::show_file_selector(
|
||||
|
@ -40,9 +40,7 @@ SavePaletteCommand::SavePaletteCommand()
|
||||
|
||||
void SavePaletteCommand::onExecute(Context* context)
|
||||
{
|
||||
char exts[4096];
|
||||
get_writable_palette_extensions(exts, sizeof(exts));
|
||||
|
||||
std::string exts = get_writable_palette_extensions();
|
||||
std::string filename;
|
||||
int ret;
|
||||
|
||||
|
@ -43,38 +43,34 @@ using namespace base;
|
||||
static FileOp* fop_new(FileOpType type, Context* context);
|
||||
static void fop_prepare_for_sequence(FileOp* fop);
|
||||
|
||||
void get_readable_extensions(char* buf, int size)
|
||||
std::string get_readable_extensions()
|
||||
{
|
||||
FileFormatsList::iterator it = FileFormatsManager::instance()->begin();
|
||||
FileFormatsList::iterator end = FileFormatsManager::instance()->end();
|
||||
std::string buf;
|
||||
|
||||
// Clear the string
|
||||
strncpy(buf, "", size);
|
||||
|
||||
// Insert file format
|
||||
for (; it != end; ++it) {
|
||||
if ((*it)->support(FILE_SUPPORT_LOAD)) {
|
||||
if (*buf) strncat(buf, ",", size);
|
||||
strncat(buf, (*it)->extensions(), size);
|
||||
for (const FileFormat* format : *FileFormatsManager::instance()) {
|
||||
if (format->support(FILE_SUPPORT_LOAD)) {
|
||||
if (!buf.empty())
|
||||
buf.push_back(',');
|
||||
buf += format->extensions();
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void get_writable_extensions(char* buf, int size)
|
||||
std::string get_writable_extensions()
|
||||
{
|
||||
FileFormatsList::iterator it = FileFormatsManager::instance()->begin();
|
||||
FileFormatsList::iterator end = FileFormatsManager::instance()->end();
|
||||
std::string buf;
|
||||
|
||||
// Clear the string
|
||||
strncpy(buf, "", size);
|
||||
|
||||
// Insert file format
|
||||
for (; it != end; ++it) {
|
||||
if ((*it)->support(FILE_SUPPORT_SAVE)) {
|
||||
if (*buf) strncat(buf, ",", size);
|
||||
strncat(buf, (*it)->extensions(), size);
|
||||
for (const FileFormat* format : *FileFormatsManager::instance()) {
|
||||
if (format->support(FILE_SUPPORT_SAVE)) {
|
||||
if (!buf.empty())
|
||||
buf.push_back(',');
|
||||
buf += format->extensions();
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Document* load_document(Context* context, const char* filename)
|
||||
|
@ -112,8 +112,8 @@ namespace app {
|
||||
|
||||
// Available extensions for each load/save operation.
|
||||
|
||||
void get_readable_extensions(char* buf, int size);
|
||||
void get_writable_extensions(char* buf, int size);
|
||||
std::string get_readable_extensions();
|
||||
std::string get_writable_extensions();
|
||||
|
||||
// High-level routines to load/save documents.
|
||||
|
||||
|
@ -30,16 +30,18 @@ namespace app {
|
||||
|
||||
using namespace doc;
|
||||
|
||||
void get_readable_palette_extensions(char* buf, int size)
|
||||
std::string get_readable_palette_extensions()
|
||||
{
|
||||
get_readable_extensions(buf, size);
|
||||
std::strcat(buf, ",col,gpl");
|
||||
std::string buf = get_readable_extensions();
|
||||
buf += ",col,gpl";
|
||||
return buf;
|
||||
}
|
||||
|
||||
void get_writable_palette_extensions(char* buf, int size)
|
||||
std::string get_writable_palette_extensions()
|
||||
{
|
||||
get_writable_extensions(buf, size);
|
||||
std::strcat(buf, ",col,gpl");
|
||||
std::string buf = get_writable_extensions();
|
||||
buf += ",col,gpl";
|
||||
return buf;
|
||||
}
|
||||
|
||||
Palette* load_palette(const char *filename)
|
||||
|
@ -15,8 +15,8 @@ namespace doc {
|
||||
|
||||
namespace app {
|
||||
|
||||
void get_readable_palette_extensions(char* buf, int size);
|
||||
void get_writable_palette_extensions(char* buf, int size);
|
||||
std::string get_readable_palette_extensions();
|
||||
std::string get_writable_palette_extensions();
|
||||
|
||||
doc::Palette* load_palette(const char *filename);
|
||||
bool save_palette(const char *filename, doc::Palette* pal);
|
||||
|
Loading…
x
Reference in New Issue
Block a user