[gephex-devel] gephex--main--0.4--patch-1834

gephex at sonnenland.kexbox.org gephex at sonnenland.kexbox.org
Tue Jan 18 22:47:58 CET 2005


Archive: gephex at gephex.org--2004
New revision: gephex--main--0.4--patch-1834

--
Revision: gephex--main--0.4--patch-1834
Archive: gephex at gephex.org--2004
Creator: The Gephex Source Archive <gephex at gephex.org>
Date: Tue Jan 18 22:45:35 CET 2005
Standard-date: 2005-01-18 21:45:35 GMT
Modified-files: base/src/utils/filesystem.cpp
    base/src/utils/filesystem.h configure.ac
    data/gephex-wrapper.in data/gephex.conf.default.in
    engine/src/engine/controller.cpp
New-patches: georg at gephex.org--2004-home/gephex--georg--0.4--patch-379
    gephex at gephex.org--2004/gephex--main--0.4--patch-1834
Summary: [MERGE-REQUEST] Updated frei0r path handling
Keywords: 

Patches applied:

 * georg at gephex.org--2004-home/gephex--georg--0.4--patch-379
   path handling for frei0r_path, module_path and type_path now supports a ';'-separated list of directories and does recursive scanning. gephex.conf.default changed to reflect recent frei0r_path discussion.

* added files

    {arch}/gephex/gephex--georg/gephex--georg--0.4/georg at gephex.org--2004-home/patch-log/patch-379
    {arch}/gephex/gephex--main/gephex--main--0.4/gephex at gephex.org--2004/patch-log/patch-1834

* modified files

--- orig/base/src/utils/filesystem.cpp
+++ mod/base/src/utils/filesystem.cpp
@@ -43,7 +43,7 @@
 namespace utils
 {
 
-DirEntry::DirEntry(const std::string& name,int type,int size)
+DirEntry::DirEntry(const std::string& name, FileType type,int size)
   : m_name(name), m_type(type), m_size(size)
 {
 }
@@ -53,7 +53,7 @@
   return m_name;
 }
 
-int DirEntry::getType() const
+DirEntry::FileType DirEntry::getType() const
 {
   return m_type;
 }
@@ -139,7 +139,10 @@
 	  //TODO
 	  throw std::runtime_error(fullname + " JAJAJAJA");
 	}
-      int type = S_ISREG(st.st_mode) ? DirEntry::FILE : DirEntry::DIRECTORY;
+      DirEntry::FileType type =
+        S_ISREG(st.st_mode) ? DirEntry::FILE
+                            : DirEntry::DIRECTORY;
+
       int size = st.st_blocks * 512;
       entries.push_back(DirEntry(current->d_name,type,size));
       current = readdir(dstream);


--- orig/base/src/utils/filesystem.h
+++ mod/base/src/utils/filesystem.h
@@ -42,7 +42,7 @@
   class DirEntry
     {
     public:
-      enum {DIRECTORY, FILE};
+      enum FileType { DIRECTORY, FILE };
 
       /**
        * Create a new DirEntry.
@@ -50,7 +50,7 @@
        * @param type wether its a file or directory (FILE | DIRECTORY).
        * @param size size of the file/driectory in bytes.
        */
-      DirEntry(const std::string& name,int type,int size);
+      DirEntry(const std::string& name, FileType type, int size);
 
       /**
        * ...
@@ -63,7 +63,7 @@
        * @return FILE if this is a file or DIRECTORY if this is
        *         a directory
        */
-      int getType() const;
+      FileType getType() const;
 	
       /**
        * ...
@@ -73,7 +73,7 @@
 
     private:
       std::string m_name;
-      int m_type;
+      FileType m_type;
       int m_size;
     };
 


--- orig/configure.ac
+++ mod/configure.ac
@@ -369,10 +369,9 @@
  cd contrib/ffmpeg/ && ${FFMPEG_CONFIG_DIR}/configure $FFMPEG_CONFIGURE_FLAGS && cd ../..
 fi
 
-# set gphx_module_lib_dir, gphx_frei0r_lib_dir, and gphx_type_lib_dir
+# set gphx_module_lib_dir and gphx_type_lib_dir
 test "x$prefix" = xNONE && prefix=$ac_default_prefix
 AC_SUBST(gphx_module_lib_dir, "${prefix}/lib/gephex-0.4/modules")
-AC_SUBST(gphx_frei0r_lib_dir, "${prefix}/lib/gephex-0.4/frei0rs")
 AC_SUBST(gphx_type_lib_dir, "${prefix}/lib/gephex-0.4/types")
 
 AC_CONFIG_FILES([Makefile


--- orig/data/gephex-wrapper.in
+++ mod/data/gephex-wrapper.in
@@ -11,7 +11,8 @@
 # TODO: better error handling
 # Note: the prefix variable is replaced at configure time
 
-CONF_DIR_BASE=$HOME/.gephex
+HOME_DIR=$HOME
+CONF_DIR_BASE=$HOME_DIR/.gephex
 CONF_DIR=$CONF_DIR_BASE/0.4
 DATA_PATH=@prefix@/share/gephex/
 
@@ -24,7 +25,7 @@
     mkdir $CONF_DIR/graphs
 
     echo "Copying and adapting default config file..."
-    cat $DATA_PATH/gephex.conf.default | sed s:__CONF_DIR__:$CONF_DIR:g > $CONF_DIR/gephex.conf
+    cat $DATA_PATH/gephex.conf.default | sed s:__CONF_DIR__:$CONF_DIR:g | sed s:__HOME_DIR__:$HOME_DIR:g > $CONF_DIR/gephex.conf
 
     echo "Copying example graphs..."
     GRAPHS="example1 example2 example3 noise fzcam4"


--- orig/data/gephex.conf.default.in
+++ mod/data/gephex.conf.default.in
@@ -4,7 +4,7 @@
 
 engine {
     module_path          = [@gphx_module_lib_dir@/]
-    frei0r_path          = [@gphx_frei0r_lib_dir@/]
+    frei0r_path          = [__HOME_DIR__/.frei0r-1/lib/;/usr/local/lib/frei0r-1/;/usr/lib/frei0r-1/]
     type_path            = [@gphx_type_lib_dir@/]
     graph_path           = [__CONF_DIR__/graphs/]
     ipc_unix_node_prefix = [/tmp/gephex_socket_]


--- orig/engine/src/engine/controller.cpp
+++ mod/engine/src/engine/controller.cpp
@@ -37,7 +37,7 @@
 #include "netlogger.h"
 #include "buffer.h"
 #include "filesystem.h"
-
+#include "stringtokenizer.h"
 
 namespace engine
 {
@@ -96,11 +96,13 @@
 
 
   /**
-   * Returns a vector of all files in a directory, that have a certain
+   * Returns a vector of all files in a list of paths, that have a certain
    * file ending.
+   * Files can be listed more than once if a path of the list is a subpath
+   * of another path in the list.
    */
-  std::vector<std::string> getFilesInDir(const std::string& dirName,
-                                         const std::string& ending);
+  std::vector<std::string> getFilesInPathList(const std::string& dirName,
+                                              const std::string& ending);
 
   // connect a porttagger and a commandtagger with their receiving
   // and sending objects
@@ -118,8 +120,9 @@
 #error "unknown OS"
 #endif
 
-  std::vector<std::string> getFilesInDir(const std::string& dirName,
-					 const std::string& ending)
+  //TODO: make recursive
+  std::vector<std::string> getFilesInPath(const std::string& dirName,
+                                          const std::string& ending)
   {
     std::vector<std::string> fileNames;
     
@@ -132,12 +135,27 @@
              it != entries.end(); ++it)
           {
             std::string name = it->getName();
+
+            if (name == "." || name == "..")
+              continue;
       
-            if (name.length() > ending.length() 
-                && name.substr(name.length()-ending.length(),
-                               ending.length()) == ending)
-              
-              fileNames.push_back(dirName + name);
+            if (it->getType() == utils::DirEntry::DIRECTORY)
+              {
+                std::vector<std::string> 
+                  subfiles= getFilesInPath(name, ending);
+
+                fileNames.insert(fileNames.end(),
+                                 subfiles.begin(), subfiles.end());
+              }
+            else
+              {
+                if (name.length() > ending.length() 
+                    && name.substr(name.length()-ending.length(),
+                                   ending.length()) == ending)
+                  {
+                    fileNames.push_back(dirName + name);
+                  }
+              }
           }
       }
     catch (std::runtime_error& e)
@@ -148,6 +166,28 @@
     return fileNames;
   }
   
+std::vector<std::string> getFilesInPathList(const std::string& pathList,
+                                            const std::string& ending)
+  {
+    std::vector<std::string> files;
+
+    utils::StringTokenizer st(pathList);
+    std::string path;
+
+    while ((path = st.next(";")) != "")
+    try
+      {
+        std::vector<std::string> fs = getFilesInPath(path, ending);
+        files.insert(files.end(),fs.begin(), fs.end());
+      }
+    catch (std::runtime_error& e)
+      {
+        std::cerr << "Could not open '" << path << "' ("
+                  << e.what() << ")
";
+      }
+    return files;
+  }
+  
   void initTaggers(PortTagger& portTagger, CommandTagger& commandTagger,
                    net::Protocol& protocol,
                    PortDispatcher& portDispatcher, int port)
@@ -317,18 +357,18 @@
 	
     // load stuff
     std::string module_path = config.get_string_param("module_path");
-    std::vector<std::string> modules = getFilesInDir(module_path,
-                                                     MODULE_ENDING);
+    std::vector<std::string> modules = getFilesInPathList(module_path,
+                                                          MODULE_ENDING);
 	
     std::string type_path = config.get_string_param("type_path");
-    std::vector<std::string> types = getFilesInDir(type_path,
-                                                   TYPE_ENDING);
+    std::vector<std::string> types = getFilesInPathList(type_path,
+                                                        TYPE_ENDING);
 
 
     std::string frei0r_path = config.get_string_param("frei0r_path");
     std::vector<std::string> frei0rs;
     if (frei0r_path != "")
-      frei0rs = getFilesInDir(frei0r_path, MODULE_ENDING);
+      frei0rs = getFilesInPathList(frei0r_path, MODULE_ENDING);
     
     std::cout << "Reading plugins...";
     std::cout.flush();



More information about the gephex-devel mailing list