[aseprite] 180/196: Add base::normalize_path()

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:50:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 221e9bf4fcebd9cf01a8ae7d54e6552633139a95
Author: David Capello <davidcapello at gmail.com>
Date:   Mon Apr 11 19:17:39 2016 -0300

    Add base::normalize_path()
---
 src/app/app.cpp             |  2 +-
 src/app/file/file.cpp       |  6 ++++--
 src/app/recent_files.cpp    |  6 ++----
 src/base/path.cpp           | 10 +++++++++-
 src/base/path.h             |  6 +++++-
 src/doc/document.cpp        |  4 ++--
 src/doc/documents.cpp       |  6 +++---
 src/she/osx/app_delegate.mm |  3 ++-
 8 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/app/app.cpp b/src/app/app.cpp
index 425d7c5..97a5fce 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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();
 
diff --git a/src/app/file/file.cpp b/src/app/file/file.cpp
index acfca1d..0ffc70d 100644
--- a/src/app/file/file.cpp
+++ b/src/app/file/file.cpp
@@ -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) {
diff --git a/src/app/recent_files.cpp b/src/app/recent_files.cpp
index c456263..46f7604 100644
--- a/src/app/recent_files.cpp
+++ b/src/app/recent_files.cpp
@@ -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
diff --git a/src/base/path.cpp b/src/base/path.cpp
index 0876cd5..9744fc4 100644
--- a/src/base/path.cpp
+++ b/src/base/path.cpp
@@ -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()) {
diff --git a/src/base/path.h b/src/base/path.h
index d954cf7..e58baa5 100644
--- a/src/base/path.h
+++ b/src/base/path.h
@@ -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.
diff --git a/src/doc/document.cpp b/src/doc/document.cpp
index 946ed03..e41ed29 100644
--- a/src/doc/document.cpp
+++ b/src/doc/document.cpp
@@ -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);
 }
 
diff --git a/src/doc/documents.cpp b/src/doc/documents.cpp
index c245c95..05eff2f 100644
--- a/src/doc/documents.cpp
+++ b/src/doc/documents.cpp
@@ -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;
diff --git a/src/she/osx/app_delegate.mm b/src/she/osx/app_delegate.mm
index 76460d3..0c54771 100644
--- a/src/she/osx/app_delegate.mm
+++ b/src/she/osx/app_delegate.mm
@@ -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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list