Exemple #1
0
    protected override Errno OnReadDirectory(string directory, Mono.Fuse.OpenedPathInfo info, out System.Collections.Generic.IEnumerable<Mono.Fuse.DirectoryEntry> paths)
    {
        //Console.WriteLine("OnReadDirectory:" + directory);
        //Console.WriteLine("Handle: " + info.Handle);
        //Console.WriteLine("OpenFlags: " + info.OpenFlags);
        //Console.WriteLine("OpenAccess: " + info.OpenAccess);

        Ext2fsLib.Ext2FS.Inode inode1 = new Ext2fsLib.Ext2FS.Inode();
        Ext2fsLib.Ext2FS.Errors err = Ext2fs.GetPathInode(directory, ref inode1);
        if (err == Ext2fsLib.Ext2FS.Errors.NotFound)
        {
            paths = null;
            return Errno.ENOENT;
        }
        Ext2fsLib.Ext2FS.DirectoryEntry[] dir = Ext2fs.ListDirectory(inode1);
        //Dim d As Mono.Fuse.DirectoryEntry
        //Ext2fsLib.Ext2FS.DirectoryEntry dir1;
        List<Mono.Fuse.DirectoryEntry> d = new List<Mono.Fuse.DirectoryEntry>();
        foreach (Ext2fsLib.Ext2FS.DirectoryEntry dir1 in dir)
        {
            Mono.Fuse.DirectoryEntry d1 = new Mono.Fuse.DirectoryEntry(dir1.name);
            //Mono.Unix.Native.Stat stat1 = new Mono.Unix.Native.Stat();
            d.Add(d1);
            //Console.WriteLine(d1.Name);
        }
        paths = d;
        return 0;
    }
Exemple #2
0
        private IEnumerable<DirectoryEntry> GetEntries(int nodeid)
        {
            yield return new DirectoryEntry (".");
            yield return new DirectoryEntry ("..");

            //Logging.Write("Getting Entries...");
            if(Engine.FSNodes[nodeid] != null)
            {

                if(Engine.FSNodes[nodeid].NodeType == SoundCloudFS.FileTree.Node.NodeTypeTree)
                {
                    //Logging.Write("Nodetype is a tree for node " + nodeid.ToString());
                    for(int esubn = 0; esubn < Engine.FSNodes[nodeid].SubNodes.Length; esubn++)
                    {
                        //Logging.Write("esubn: " + esubn.ToString());
                        if(Engine.FSNodes[nodeid].SubNodes[esubn] > -1)
                        {
                            int snid = Engine.FSNodes[nodeid].SubNodes[esubn];
                            //Logging.Write("Yielding DirectoryEntry: " + Engine.FSNodes[snid].Name);
                            yield return new DirectoryEntry(Engine.FSNodes[snid].Name);
                        }
                    }
                }
                else
                {
                    //	Need to yield return each track here.
                    if(!Engine.FSNodes[nodeid].HasSearched)
                    {
                        if(!Engine.FSNodes[nodeid].RunSearch())
                        {
                            Logging.Write("Running search on node " + nodeid.ToString() + " failed.");
                        }
                    }

                    if(Engine.FSNodes[nodeid].Tracks != null)
                    {
                        for(int etrack = 0; etrack < Engine.FSNodes[nodeid].Tracks.Length; etrack++)
                        {
                            if(Engine.FSNodes[nodeid].Tracks[etrack] != null)
                            {
                                //Logging.Write("Getting entry for track " + etrack.ToString());
                                DirectoryEntry de = new DirectoryEntry(Engine.FSNodes[nodeid].Tracks[etrack].Filename);

                                yield return de;

                            }
                        }
                    }
                }
            }

            /*for(int etrack = 0; etrack < Engine.Tracks.Length; etrack++)
            {
                if(Engine.Tracks[etrack] != null)
                {
                    //Logging.Write("Getting entry for track " + etrack.ToString());
                    DirectoryEntry de = new DirectoryEntry(Engine.Tracks[etrack].Filename);
                    //de.Stat.st_atime = Engine.Tracks[etrack].UnixTimeAccessed();
                    //de.Stat.st_ctime = Engine.Tracks[etrack].UnixTimeCreated();
                    //de.Stat.st_mtime = Engine.Tracks[etrack].UnixTimeCreated();
                    //de.Stat.st_gid = (uint)Engine.Config.GroupID;
                    //de.Stat.st_uid = (uint)Engine.Config.UserID;
                    //de.Stat.st_uid = (uint)1000;
                    //de.Stat.st_mode = FilePermissions.S_IFREG |
                    //		NativeConvert.FromOctalPermissionString("0644");
                    //de.Stat.st_nlink = 1;
                    //de.Stat.st_size = Engine.Tracks[etrack].Filesize;

                    yield return de;
                }
            }*/
        }
Exemple #3
0
 private IEnumerable<DirectoryEntry> ReadDirectory(IntPtr dp)
 {
     Dirent de;
     while ((de = Syscall.readdir (dp)) != null) {
         DirectoryEntry e = new DirectoryEntry (de.d_name);
         e.Stat.st_ino  = de.d_ino;
         e.Stat.st_mode = (FilePermissions) (de.d_type << 12);
         yield return e;
     }
 }
Exemple #4
0
        protected override Errno OnReadDirectory(string path, OpenedPathInfo fi,
		                                          out IEnumerable<DirectoryEntry> paths)
        {
            IntPtr dp = Syscall.opendir (basedir + path);
            if (dp == IntPtr.Zero)
            {
                paths = null;
                return Stdlib.GetLastError ();
            }

            Dirent de;
            List<DirectoryEntry> entries = new List<DirectoryEntry> ();
            while ((de = Syscall.readdir (dp)) != null)
            {
                DirectoryEntry e = new DirectoryEntry (de.d_name);
                e.Stat.st_ino = de.d_ino;
                e.Stat.st_mode = (FilePermissions)(de.d_type << 12);
                entries.Add (e);
            }
            Syscall.closedir (dp);

            paths = entries;
            return 0;
        }