[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [pingus] push by address@hidden - Made Pathname::opendir()
From: |
pingus |
Subject: |
[Pingus-CVS] [pingus] push by address@hidden - Made Pathname::opendir() to return Pathname's with the same type as th... on 2011-09-27 10:53 GMT |
Date: |
Tue, 27 Sep 2011 11:06:22 +0000 |
Revision: 1983039fa5f9
Author: Ingo Ruhnke <address@hidden>
Date: Tue Sep 27 03:52:59 2011
Log: Made Pathname::opendir() to return Pathname's with the same type
as the parent, instead of converting everything to SYSTEM_PATH
http://code.google.com/p/pingus/source/detail?r=1983039fa5f9
Modified:
/src/editor/object_selector.cpp
/src/util/pathname.cpp
/src/util/pathname.hpp
=======================================
--- /src/editor/object_selector.cpp Mon Sep 26 13:00:39 2011
+++ /src/editor/object_selector.cpp Tue Sep 27 03:52:59 2011
@@ -398,7 +398,7 @@
auto directory = Pathname("prefabs",
Pathname::DATA_PATH).opendir("*.prefab");
for(auto i = directory.begin(); i != directory.end(); ++i)
{
- set->add(new Prefab("prefabs/" +
System::cut_file_extension(i->get_raw_path())));
+ set->add(new Prefab(System::cut_file_extension(i->get_raw_path())));
}
return set;
=======================================
--- /src/util/pathname.cpp Mon Sep 26 13:00:13 2011
+++ /src/util/pathname.cpp Tue Sep 27 03:52:59 2011
@@ -18,8 +18,10 @@
#include <assert.h>
#include <ostream>
+#include <set>
#include "pingus/path_manager.hpp"
+#include "util/log.hpp"
#include "util/string_util.hpp"
#include "util/system.hpp"
@@ -153,17 +155,17 @@
paths.insert(paths.end(), lst.begin(), lst.end());
}
- std::vector<Pathname> result;
+ std::set<Pathname> result;
for(auto p = paths.begin(); p != paths.end(); ++p)
{
std::string path = Pathname::join(*p, pathname);
System::Directory lst = System::opendir(path, pattern);
for(auto it = lst.begin(); it != lst.end(); ++it)
{
- result.push_back(Pathname(Pathname::join(path, it->name),
Pathname::SYSTEM_PATH));
+ result.insert(Pathname(Pathname::join(pathname, it->name),
Pathname::DATA_PATH));
}
}
- return result;
+ return std::vector<Pathname>(result.begin(), result.end());
}
case Pathname::SYSTEM_PATH: {
@@ -260,5 +262,22 @@
{
return StringUtil::has_suffix(pathname, ext);
}
+
+bool
+Pathname::operator<(const Pathname& rhs) const
+{
+ if (type < rhs.type)
+ {
+ return true;
+ }
+ else if (type > rhs.type)
+ {
+ return false;
+ }
+ else
+ {
+ return pathname < rhs.pathname;
+ }
+}
/* EOF */
=======================================
--- /src/util/pathname.hpp Mon Sep 26 13:00:13 2011
+++ /src/util/pathname.hpp Tue Sep 27 03:52:59 2011
@@ -45,13 +45,14 @@
std::string pathname;
Type type;
+ void opendir_recursive(std::vector<Pathname>& result) const;
+
public:
Pathname();
explicit Pathname(const std::string& pathname, Type type = DATA_PATH);
std::vector<Pathname> opendir(const std::string& pattern = "*") const;
std::vector<Pathname> opendir_recursive() const;
- void opendir_recursive(std::vector<Pathname>& result) const;
bool has_extension(const std::string& ext) const;
@@ -75,6 +76,8 @@
bool exist() const;
uint64_t mtime() const;
+
+ bool operator<(const Pathname& rhs) const;
};
std::ostream& operator<< (std::ostream& os, const Pathname& p);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [pingus] push by address@hidden - Made Pathname::opendir() to return Pathname's with the same type as th... on 2011-09-27 10:53 GMT,
pingus <=