[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3088 - trunk/pingus/src
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3088 - trunk/pingus/src |
Date: |
Wed, 5 Sep 2007 18:12:08 +0200 |
Author: grumbel
Date: 2007-09-05 18:12:07 +0200 (Wed, 05 Sep 2007)
New Revision: 3088
Added:
trunk/pingus/src/pathname.cpp
trunk/pingus/src/pathname.hpp
Log:
- added simple help screen to editor
- added right-click scrolling to the editor
- added new class Pathname for cleaner handling of pathnames
- fixed loading of levels from command line
Added: trunk/pingus/src/pathname.cpp
===================================================================
--- trunk/pingus/src/pathname.cpp 2007-09-05 16:10:33 UTC (rev 3087)
+++ trunk/pingus/src/pathname.cpp 2007-09-05 16:12:07 UTC (rev 3088)
@@ -0,0 +1,126 @@
+/* $Id$
+**
+** Pingus - A free Lemmings clone
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include <assert.h>
+#include <iostream>
+#include "system.hpp"
+#include "path_manager.hpp"
+#include "pathname.hpp"
+
+Pathname Pathname::tmpfile(const std::string& prefix)
+{
+ assert(!"Unimplemented");
+}
+
+Pathname::Pathname()
+ : type(INVALID)
+{
+}
+
+Pathname::Pathname(const std::string& pathname_, Type type_)
+ : pathname(pathname_), type(type_)
+{
+}
+
+std::string
+Pathname::get_sys_path() const
+{
+ switch(type)
+ {
+ case SYSTEM_PATH:
+ return pathname;
+
+ case DATA_PATH:
+ return path_manager.complete(pathname);
+
+ default:
+ assert(!"Never reached");
+ }
+}
+
+std::string
+Pathname::get_raw_path() const
+{
+ return pathname;
+}
+
+Pathname::Type
+Pathname::get_type() const
+{
+ return type;
+}
+
+bool
+Pathname::empty() const
+{
+ return (type == INVALID);
+}
+
+bool
+Pathname::exist() const
+{
+ return System::exist(get_sys_path());
+}
+
+uint64_t
+Pathname::mtime() const
+{
+ return System::get_mtime(get_sys_path());
+}
+
+std::string
+Pathname::str() const
+{
+ switch(type)
+ {
+ case Pathname::INVALID:
+ return "invalid://" + pathname;
+
+ case Pathname::DATA_PATH:
+ return "datadir://" + pathname;
+
+ case Pathname::SYSTEM_PATH:
+ return "system://" + pathname;
+
+ default:
+ assert(!"never reached");
+ }
+}
+
+std::ostream& operator<< (std::ostream& os, const Pathname& p)
+{
+ switch(p.get_type())
+ {
+ case Pathname::INVALID:
+ return os << "invalid://" << p.get_raw_path();
+
+ case Pathname::DATA_PATH:
+ return os << "datadir://" << p.get_raw_path();
+
+ case Pathname::SYSTEM_PATH:
+ return os << "system://" << p.get_raw_path();
+
+ default:
+ assert(!"never reached");
+ }
+}
+
+/* EOF */
Property changes on: trunk/pingus/src/pathname.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pingus/src/pathname.hpp
===================================================================
--- trunk/pingus/src/pathname.hpp 2007-09-05 16:10:33 UTC (rev 3087)
+++ trunk/pingus/src/pathname.hpp 2007-09-05 16:12:07 UTC (rev 3088)
@@ -0,0 +1,79 @@
+/* $Id$
+**
+** Pingus - A free Lemmings clone
+** Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_PATHNAME_HPP
+#define HEADER_PATHNAME_HPP
+
+#include <iosfwd>
+#include <string>
+
+/** Simple class to allow a distinction of paths that rever to the
+ * filesystem and paths that refer to the datadir, it also hides
+ * path_manager from the rest of the code. */
+class Pathname
+{
+public:
+ /** Generate a temporary filename suitable for temporary files */
+ static Pathname tmpfile(const std::string& prefix = "");
+
+ enum Type {
+ // The given pathname refers to the native file system
+ SYSTEM_PATH,
+
+ // The given pathname refers to a file in the datadir
+ DATA_PATH,
+
+ INVALID
+ };
+
+private:
+ std::string pathname;
+ Type type;
+
+public:
+ Pathname();
+ explicit Pathname(const std::string& pathname, Type type = DATA_PATH);
+
+ /** Return the pathname in a form suitable for the native file
+ system (i.e. can be passed to ifstream and friends */
+ std::string get_sys_path() const;
+
+ /** Return the pathname as is */
+ std::string get_raw_path() const;
+
+ Type get_type() const;
+
+ /** Converts the Pathname into human readable form, usefull for
+ debugging output and nothing else */
+ std::string str() const;
+
+ bool empty() const;
+
+ bool exist() const;
+
+ uint64_t mtime() const;
+};
+
+std::ostream& operator<< (std::ostream& os, const Pathname& p);
+
+#endif
+
+/* EOF */
Property changes on: trunk/pingus/src/pathname.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3088 - trunk/pingus/src,
grumbel at BerliOS <=