From c4f8bf4cb6630b7e13267fb8472a3e3129db3e51 Mon Sep 17 00:00:00 2001 From: Torello Querci Date: Sat, 06 Feb 2010 07:30:01 +0000 Subject: Upgrade software version from 0.1.0 to 0.1.1 because there is some fix in the DirAsTags filesystem module. --- diff --git a/ChangeLog b/ChangeLog index c0272f8..ecebde3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-06 Torello Querci + + fsgateway/DirAsTag.cs: Fixed come bug when there are files with the same name in different location. + 2009-12-27 Torello Querci fsgateway/FsSqlServer.cs: Added the support of SqlServer @@ -8,4 +12,4 @@ * configure.in: File added to be able to compile fsgateway - + diff --git a/configure.ac b/configure.ac index a439a42..9f238b8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_INIT(src/FsGateway.cs) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(fsgateway, 0.1.0) +AM_INIT_AUTOMAKE(fsgateway, 0.1.1) AM_MAINTAINER_MODE AC_PROG_INSTALL diff --git a/src/DirAsTag.cs b/src/DirAsTag.cs index b6f5a06..51e92e4 100644 --- a/src/DirAsTag.cs +++ b/src/DirAsTag.cs @@ -105,8 +105,6 @@ namespace FsGateway return false; } - System.Console.Out.WriteLine("ROOT="+root+" len="+root.Length+" DIR="+dir+" len="+dir.Length); - string suffix=null; string[] keys=null; if (dir.Length!=root.Length) { @@ -128,7 +126,6 @@ namespace FsGateway name=dir+"/"+dirent.d_name; - System.Console.Out.WriteLine("Name: "+name); Syscall.lstat(name,out buf); if ((buf.st_mode & Mono.Unix.Native.FilePermissions.S_IFDIR)!=0) { // This file is a directory @@ -137,7 +134,6 @@ namespace FsGateway if (!listTags.ContainsKey(dirent.d_name)) { // Directory not present in the list listTags.Add(dirent.d_name,new SortedList>()); - System.Console.Out.WriteLine("Directory name "+dirent.d_name+" added"); } // Analyze the files contained in the directory @@ -161,8 +157,7 @@ namespace FsGateway } } } -// System.Console.Out.WriteLine("\t"+NativeConvert.ToFilePermissions(buf.st_mode)); - System.Console.Out.WriteLine("\t"+buf.st_mode.ToString()); +// System.Console.Out.WriteLine("\t"+buf.st_mode.ToString()); } } Syscall.closedir(dirHandle); @@ -179,10 +174,142 @@ namespace FsGateway return Errno.ENODATA; } + /********************************************************************* + * + * Method to get the list of tags that are embedded in the directory path. + * This method setup also the out variable contents where will stored all + * the SortedList where the key is the filename and the value is the list + * of all the file with full path that have the same name + * + *********************************************************************/ + private List getTagListAndContents(string directory, out SortedList> contents) { + + // Expand path as list of tags + string[] tags=directory.Substring(1).Split('/'); + SortedList> contentsPurged=null; + List tagsList=new List(); + string key=""; + contents=null; + foreach (string tag in tags) { + + // Check if is the first look + if (contents==null) { + contents=new SortedList>(); + foreach (string keyListTags in listTags[tag].Keys) { + contents.Add(keyListTags,listTags[tag][keyListTags]); + } + + } else { + contentsPurged=new SortedList>(); + foreach (string keyContents in contents.Keys) { + if (listTags[tag].ContainsKey(keyContents)) { + List listFiles=new List(); + foreach (string fullPathName in listTags[tag][keyContents]) { + if (contents[keyContents].Contains(fullPathName)) { + listFiles.Add(fullPathName); + } + } + contentsPurged.Add(keyContents,listFiles); + + } + } + + contents=contentsPurged; + + if (contents.Count<1) { + break; + } + } + tagsList.Add(tag); + } + + return tagsList; + } + + public Errno OnReadDirectory (string directory, OpenedPathInfo info, out IEnumerable names) { names=null; + + // Check for root directory + if (directory.Equals("/")) { + + // Read all the directory tag + IEnumerator en=listTags.Keys.GetEnumerator(); + names=ListNames(en); + + } else { + // Expand path as list of tags + SortedList> contents=null; + List tagsList=this.getTagListAndContents(directory,out contents); + + IEnumerator en; + + // Add other tags + if (contents==null) { + contents=new SortedList>(); + } + + foreach (string listTagsKey in listTags.Keys) { + + // Check in this tags is already in the tag list + if (!tagsList.Contains(listTagsKey)) { + + // Check if this tag is already specify in the contents (file list) + // We need modify this behaviour later + if (!contents.ContainsKey(listTagsKey)) { + + // Check if this tag have some files with actual path + bool checkDir=false; + foreach (string filename in contents.Keys) { + if (listTags[listTagsKey].ContainsKey(filename)) { + foreach (string realFileName in listTags[listTagsKey][filename]) { + if (contents[filename].Contains(realFileName)) { + checkDir=true; + break; + } + } + } + } + + if (checkDir) { + contents.Add(listTagsKey,null); + } + } + } + } + + en=contents.Keys.GetEnumerator(); + List simbolicName=new List(); + IEnumerator en_link=null; + while (en.MoveNext()) { + int count=1; + if (contents[en.Current]!=null) { + en_link=contents[en.Current].GetEnumerator(); + while (en_link.MoveNext()) { + while (simbolicName.Contains(en.Current + (count>1 ? " ("+count+")" : ""))) { + ++count; + } + simbolicName.Add(en.Current + (count>1 ? " ("+count+")" : "")); + + } + } else { + // Suppose to be a directory (TAG) + simbolicName.Add(en.Current + (count>1 ? " ("+count+")" : "")); + } + + } + en_link=simbolicName.GetEnumerator(); + names=ListNames(en_link); + } + return 0; + } + +/* public Errno OnReadDirectory (string directory, OpenedPathInfo info, + out IEnumerable names) + { + names=null; // Check for root directory if (directory.Equals("/")) { @@ -286,7 +413,7 @@ namespace FsGateway } return 0; } - +*/ public Errno OnGetPathStatus (string path, out Stat stbuf) { // System.Console.Out.Write("DEBUG: OnGetPathStatus for "+path+" UID="+Mono.Unix.Native.Syscall.getuid()+" GID="+Mono.Unix.Native.Syscall.getgid()); @@ -347,7 +474,7 @@ namespace FsGateway } public Errno OnReadSymbolicLink (string link, out string target) { - System.Console.Out.WriteLine("DEBUG: OnReadSymbolicLynk for path="+link); +// System.Console.Out.WriteLine("DEBUG: OnReadSymbolicLynk for path="+link); Regex fileMultipleRegex = null; -- cgit v0.9.1