mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Add base::normalize_path()
This commit is contained in:
parent
e4c46a761a
commit
221e9bf4fc
@ -547,7 +547,7 @@ void App::initialize(const AppOptions& options)
|
|||||||
}
|
}
|
||||||
// File names aren't associated to any option
|
// File names aren't associated to any option
|
||||||
else {
|
else {
|
||||||
const std::string& filename = value.value();
|
const std::string& filename = base::normalize_path(value.value());
|
||||||
|
|
||||||
app::Document* oldDoc = ctx->activeDocument();
|
app::Document* oldDoc = ctx->activeDocument();
|
||||||
|
|
||||||
|
@ -711,10 +711,12 @@ void FileOp::postLoad()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Set the filename.
|
// Set the filename.
|
||||||
|
std::string fn;
|
||||||
if (isSequence())
|
if (isSequence())
|
||||||
m_document->setFilename(m_seq.filename_list.begin()->c_str());
|
fn = m_seq.filename_list.begin()->c_str();
|
||||||
else
|
else
|
||||||
m_document->setFilename(m_filename.c_str());
|
fn = m_filename.c_str();
|
||||||
|
m_document->setFilename(fn);
|
||||||
|
|
||||||
bool result = m_format->postLoad(this);
|
bool result = m_format->postLoad(this);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -103,9 +103,7 @@ void RecentFiles::removeRecentFile(const char* filename)
|
|||||||
|
|
||||||
std::string RecentFiles::normalizePath(std::string fn)
|
std::string RecentFiles::normalizePath(std::string fn)
|
||||||
{
|
{
|
||||||
fn = base::get_canonical_path(fn);
|
return base::normalize_path(fn);
|
||||||
fn = base::fix_path_separators(fn);
|
|
||||||
return fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Base Library
|
// Aseprite Base Library
|
||||||
// Copyright (c) 2001-2013, 2015 David Capello
|
// Copyright (c) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
|
||||||
|
#include "base/fs.h" // TODO we should merge base/path.h and base/fs.h
|
||||||
#include "base/string.h"
|
#include "base/string.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -142,6 +143,13 @@ std::string fix_path_separators(const std::string& filename)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string normalize_path(const std::string& filename)
|
||||||
|
{
|
||||||
|
std::string fn = base::get_canonical_path(filename);
|
||||||
|
fn = base::fix_path_separators(fn);
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
bool has_file_extension(const std::string& filename, const std::string& csv_extensions)
|
bool has_file_extension(const std::string& filename, const std::string& csv_extensions)
|
||||||
{
|
{
|
||||||
if (!filename.empty()) {
|
if (!filename.empty()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Base Library
|
// Aseprite Base Library
|
||||||
// Copyright (c) 2001-2013 David Capello
|
// Copyright (c) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -40,6 +40,10 @@ namespace base {
|
|||||||
// Replaces all separators with the system separator.
|
// Replaces all separators with the system separator.
|
||||||
std::string fix_path_separators(const std::string& filename);
|
std::string fix_path_separators(const std::string& filename);
|
||||||
|
|
||||||
|
// Calls get_canonical_path() and fix_path_separators() for the
|
||||||
|
// given filename.
|
||||||
|
std::string normalize_path(const std::string& filename);
|
||||||
|
|
||||||
// Returns true if the filename contains one of the specified
|
// Returns true if the filename contains one of the specified
|
||||||
// extensions. The cvs_extensions parameter must be a set of
|
// extensions. The cvs_extensions parameter must be a set of
|
||||||
// possible extensions separated by comma.
|
// possible extensions separated by comma.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2015 David Capello
|
// Copyright (c) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -64,7 +64,7 @@ std::string Document::name() const
|
|||||||
|
|
||||||
void Document::setFilename(const std::string& filename)
|
void Document::setFilename(const std::string& filename)
|
||||||
{
|
{
|
||||||
m_filename = filename;
|
m_filename = base::normalize_path(filename);
|
||||||
notifyObservers(&DocumentObserver::onFileNameChanged, this);
|
notifyObservers(&DocumentObserver::onFileNameChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2014 David Capello
|
// Copyright (c) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -106,9 +106,9 @@ Document* Documents::getByName(const std::string& name) const
|
|||||||
|
|
||||||
Document* Documents::getByFileName(const std::string& filename) const
|
Document* Documents::getByFileName(const std::string& filename) const
|
||||||
{
|
{
|
||||||
std::string fixfn = base::fix_path_separators(filename);
|
std::string fn = base::normalize_path(filename);
|
||||||
for (const auto& doc : *this) {
|
for (const auto& doc : *this) {
|
||||||
if (base::fix_path_separators(doc->filename()) == fixfn)
|
if (doc->filename() == fn)
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "she/osx/app_delegate.h"
|
#include "she/osx/app_delegate.h"
|
||||||
|
|
||||||
|
#include "base/path.h"
|
||||||
#include "she/event.h"
|
#include "she/event.h"
|
||||||
#include "she/event_queue.h"
|
#include "she/event_queue.h"
|
||||||
#include "she/osx/app.h"
|
#include "she/osx/app.h"
|
||||||
@ -41,7 +42,7 @@
|
|||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
for (int i=0; i<[filenames count]; ++i) {
|
for (int i=0; i<[filenames count]; ++i) {
|
||||||
NSString* fn = [filenames objectAtIndex: i];
|
NSString* fn = [filenames objectAtIndex: i];
|
||||||
files.push_back([fn UTF8String]);
|
files.push_back(base::normalize_path([fn UTF8String]));
|
||||||
}
|
}
|
||||||
|
|
||||||
she::Event ev;
|
she::Event ev;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user