mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +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
|
||||
else {
|
||||
const std::string& filename = value.value();
|
||||
const std::string& filename = base::normalize_path(value.value());
|
||||
|
||||
app::Document* oldDoc = ctx->activeDocument();
|
||||
|
||||
|
@ -711,10 +711,12 @@ void FileOp::postLoad()
|
||||
return;
|
||||
|
||||
// Set the filename.
|
||||
std::string fn;
|
||||
if (isSequence())
|
||||
m_document->setFilename(m_seq.filename_list.begin()->c_str());
|
||||
fn = m_seq.filename_list.begin()->c_str();
|
||||
else
|
||||
m_document->setFilename(m_filename.c_str());
|
||||
fn = m_filename.c_str();
|
||||
m_document->setFilename(fn);
|
||||
|
||||
bool result = m_format->postLoad(this);
|
||||
if (!result) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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
|
||||
// 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)
|
||||
{
|
||||
fn = base::get_canonical_path(fn);
|
||||
fn = base::fix_path_separators(fn);
|
||||
return fn;
|
||||
return base::normalize_path(fn);
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/path.h"
|
||||
|
||||
#include "base/fs.h" // TODO we should merge base/path.h and base/fs.h
|
||||
#include "base/string.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -142,6 +143,13 @@ std::string fix_path_separators(const std::string& filename)
|
||||
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)
|
||||
{
|
||||
if (!filename.empty()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -40,6 +40,10 @@ namespace base {
|
||||
// Replaces all separators with the system separator.
|
||||
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
|
||||
// extensions. The cvs_extensions parameter must be a set of
|
||||
// possible extensions separated by comma.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -64,7 +64,7 @@ std::string Document::name() const
|
||||
|
||||
void Document::setFilename(const std::string& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
m_filename = base::normalize_path(filename);
|
||||
notifyObservers(&DocumentObserver::onFileNameChanged, this);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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.
|
||||
// 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
|
||||
{
|
||||
std::string fixfn = base::fix_path_separators(filename);
|
||||
std::string fn = base::normalize_path(filename);
|
||||
for (const auto& doc : *this) {
|
||||
if (base::fix_path_separators(doc->filename()) == fixfn)
|
||||
if (doc->filename() == fn)
|
||||
return doc;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "she/osx/app_delegate.h"
|
||||
|
||||
#include "base/path.h"
|
||||
#include "she/event.h"
|
||||
#include "she/event_queue.h"
|
||||
#include "she/osx/app.h"
|
||||
@ -41,7 +42,7 @@
|
||||
std::vector<std::string> files;
|
||||
for (int i=0; i<[filenames count]; ++i) {
|
||||
NSString* fn = [filenames objectAtIndex: i];
|
||||
files.push_back([fn UTF8String]);
|
||||
files.push_back(base::normalize_path([fn UTF8String]));
|
||||
}
|
||||
|
||||
she::Event ev;
|
||||
|
Loading…
x
Reference in New Issue
Block a user