コード例 #1
0
		private bool SetupFilters(ArrayList folders)
		{
			bool filterAdded = false;
			matchers = new ArrayList();			
			ArrayList suffixes = new ArrayList(); 
			
			//Populate reserved suffixes
			suffixes.AddRange(reserved_suffixes);
			
			//Check if 'public' folder exists and setup default mapping for it:
			if (Directory.Exists(PathFinder.HomeDir + "/public"))
			{				
				SimpleMatcher defaultMatcher = new SimpleMatcher();
				
				//file:///home/userid/public/
				defaultMatcher.Match = PathFinder.HomeDir + "/public"; 			
				//http://hostname:8888/beagle/public/
				defaultMatcher.Rewrite = "public";	
				
				matchers.Add(defaultMatcher);				
				suffixes.Add("public");
			}
            
            //string[] folders = entry.Split (',');
            foreach (string d in folders) {
                	    
                //Each entry must start with ~/            	            	
            	if ((d.Trim().Length > 1) && 
				(d.StartsWith("~/") || (d.StartsWith(PathFinder.HomeDir + "/"))) ) {
                	string d2;
			if (d.StartsWith("~/"))			
            		 	d2 = d.Replace("~/", PathFinder.HomeDir + "/");
			else
				d2 = d;							
                 			
            		if (!Directory.Exists(d2))
						continue;
                 			         			
            		string[] comp = d2.Split('/');
            		string leaf;
            		if (comp.Length > 1)
            			for (int li = comp.Length; li > 0; --li) {
            				if ((leaf = comp[li - 1].Trim()).Length > 0) {
            					//Check the leaf component is unique
            					if (suffixes.Contains(leaf))
            					{
            						Logger.Log.Warn("ExternalAccessFilter: Ignoring entry {0}. Reason: Entry suffix not unique", d);
            						break;
            					}
            					else
            						suffixes.Add(leaf);
            							
								filterAdded = true;
								SimpleMatcher matcher = new SimpleMatcher ();
										
								matcher.Match = d2;  
								matcher.Rewrite = leaf; 
								matchers.Add (matcher);
								break;										                															                															
            				} 
	      				}                 				
                } //end if
            } //end foreach
			return filterAdded;
		}
コード例 #2
0
        private bool SetupFilters(ArrayList folders)
        {
            bool filterAdded = false;

            matchers = new ArrayList();
            ArrayList suffixes = new ArrayList();

            //Populate reserved suffixes
            suffixes.AddRange(reserved_suffixes);

            //Check if 'public' folder exists and setup default mapping for it:
            if (Directory.Exists(PathFinder.HomeDir + "/public"))
            {
                SimpleMatcher defaultMatcher = new SimpleMatcher();

                //file:///home/userid/public/
                defaultMatcher.Match = PathFinder.HomeDir + "/public";
                //http://hostname:8888/beagle/public/
                defaultMatcher.Rewrite = "public";

                matchers.Add(defaultMatcher);
                suffixes.Add("public");
            }

            //string[] folders = entry.Split (',');
            foreach (string d in folders)
            {
                //Each entry must start with ~/
                if ((d.Trim().Length > 1) &&
                    (d.StartsWith("~/") || (d.StartsWith(PathFinder.HomeDir + "/"))))
                {
                    string d2;
                    if (d.StartsWith("~/"))
                    {
                        d2 = d.Replace("~/", PathFinder.HomeDir + "/");
                    }
                    else
                    {
                        d2 = d;
                    }

                    if (!Directory.Exists(d2))
                    {
                        continue;
                    }

                    string[] comp = d2.Split('/');
                    string   leaf;
                    if (comp.Length > 1)
                    {
                        for (int li = comp.Length; li > 0; --li)
                        {
                            if ((leaf = comp[li - 1].Trim()).Length > 0)
                            {
                                //Check the leaf component is unique
                                if (suffixes.Contains(leaf))
                                {
                                    Logger.Log.Warn("ExternalAccessFilter: Ignoring entry {0}. Reason: Entry suffix not unique", d);
                                    break;
                                }
                                else
                                {
                                    suffixes.Add(leaf);
                                }

                                filterAdded = true;
                                SimpleMatcher matcher = new SimpleMatcher();

                                matcher.Match   = d2;
                                matcher.Rewrite = leaf;
                                matchers.Add(matcher);
                                break;
                            }
                        }
                    }
                } //end if
            }     //end foreach
            return(filterAdded);
        }