Index: branches/testa-single-bookmark/php/NorthernCross/ns/PathInfo.php
===================================================================
--- branches/testa-single-bookmark/php/NorthernCross/ns/PathInfo.php	(revision 34)
+++ branches/testa-single-bookmark/php/NorthernCross/ns/PathInfo.php	(revision 39)
@@ -8,20 +8,91 @@
     protected $root_path;
 
-    function __construct( $root_path ){
+    function __construct( $part, $root_path , $restrict = null){
+        $this->part = $part;
         $this->root_path = $root_path;
         $this->root = new PathItem( "/" , "/");
         $this->hier_hash = array();
         $this->hier_hash["/"] = $this->root;
+        $this->restrict = null;
+        $this->restrict_dir = array();
+        if( $restrict !== null ){
+            $this->restrict = array();
+            foreach($restrict as $k => $v){
+                 $pathinfo = pathinfo($v);
+                 array_push( $this->restrict,  $pathinfo['filename'] );
+            }
+        }
+    }
+
+    public function match_in_list0( $path2, $list ){
+        $hit = false;
+
+        foreach( $list as $k => $r ){
+            if( preg_match($r , $path2) ){
+                $hit = true;
+                break;
+            }
+        }
+        return $hit;
+    }
+
+    public function match_in_list( $path, $list ){
+        $hit = false;
+
+        $pathinfo = pathinfo($path);
+        $index = array_search( $pathinfo['dirname'] , $list );
+        if( $index !== FALSE ){
+            $hit = true;
+        }
+        return $hit;
+    }
+
+    public function scan( $path ){
+        $pathinfo = pathinfo( $path );
+
+        $filename = $pathinfo['filename'];
+#        echo "filename=" . $filename . "\n";
+#        $basename = $pathinfo['basename'];
+#        echo "basename=" . $basename . "\n";
+
+        if( $this->restrict !== null ){
+            $index = array_search( $filename , $this->restrict );
+            if( $index !== FALSE ){
+                $dirname  = $pathinfo['dirname'];
+                $this->restrict_dir[ $dirname ] = "";
+            }
+        }
+    }
+
+    public function show_restrict() {
+        var_dump( $this->restrict );
+    }
+
+    public function show_restrict_dir() {
+        var_dump( $this->restrict_dir );
     }
 
     public function register( $path ){
         $path2 = trim($path);
+
         if( strlen($path2) == 0 ){
             echo "size is 0 - A\n";
             exit(0);
         }
+
         if( array_key_exists($path2,  $this->hier_hash)){
+            echo "register" . "\n";
             return;
         }
+
+        if( $this->restrict !== null ){
+#   echo "match_in_list\n";
+            if( ! $this->match_in_list( $path2, array_keys( $this->restrict_dir ) ) ){
+#                echo "!match path2=" . $path2 . "\n";
+                return;
+            }
+        }
+#        echo "path2=" . $path2 . "\n";
+        
         $array = explode("/", $path2);
         $name = array_pop($array);
@@ -61,13 +132,16 @@
     public function pathinfo_list_in_json(){
         $array = array();
-        foreach( $this->hier_hash as $a => $b ){
+        $keys = array_keys( $this->hier_hash );
+        sort( $keys , SORT_STRING );
+        foreach( $keys as $key ){
+            $b = $this->hier_hash[ $key ];
             $names = array_map(array($this, 'get_pathitem_name'), $b->get_children());
-            $array[$a]=$names;
-        }
+            sort($names, SORT_STRING);
+            $array[$key]=$names;
+        } 
         return json_encode($array);
     }
 
     public function dump() {
-        #       var_dump($this->hier_hash);
         foreach( $this->hier_hash as $a => $b ){
             echo "###########\n";
