示例#1
0
        private PlainFolder(FileServer server, DlnaMediaTypes types,
                            VirtualFolder parent, DirectoryInfo dir,
                            IEnumerable <string> exts)
            : base(parent, dir.Name)
        {
            Server   = server;
            this.dir = dir;
            folders  = (from d in dir.GetDirectories()
                        let m = TryGetFolder(server, types, d)
                                where m != null && m.ChildCount > 0
                                select m as IMediaFolder).ToList();

            var rawfiles = from f in dir.GetFiles("*.*")
                           select f;
            var files = new List <BaseFile>();

            foreach (var f in rawfiles)
            {
                var ext = f.Extension;
                if (string.IsNullOrEmpty(ext) ||
                    !exts.Contains(ext.Substring(1), StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }
                try {
                    files.Add(server.GetFile(this, f));
                }
                catch (Exception ex) {
                    server.Warn(f, ex);
                }
            }
            resources.AddRange(files);
        }
示例#2
0
        internal PlainFolder(FileServer server, VirtualFolder parent, DirectoryInfo dir)
            : base(parent, dir.Name)
        {
            Server = server;
              this.dir = dir;
              var rawfiles = from f in dir.GetFiles("*.*")
                     select f;
              var files = new List<BaseFile>();
              foreach (var f in rawfiles) {
            var ext = f.Extension;
            if (string.IsNullOrEmpty(ext) ||
            !server.Filter.Filtered(ext.Substring(1))) {
              continue;
            }
            try {
              var file = server.GetFile(this, f);
              if (server.Allowed(file)) {
            files.Add(file);
              }
            }
            catch (Exception ex) {
              server.Warn(f, ex);
            }
              }
              Resources.AddRange(files);

              Folders = (from d in dir.GetDirectories()
                 let m = TryGetFolder(server, d)
                 where m != null && m.ChildCount > 0
                 select m as IMediaFolder).ToList();
        }
示例#3
0
        private PlainFolder(FileServer server, DlnaMediaTypes types, VirtualFolder parent, DirectoryInfo dir, IEnumerable<string> exts)
            : base(parent, dir.Name)
        {
            Server = server;
              this.dir = dir;
              folders = (from d in dir.GetDirectories()
                 let m = TryGetFolder(server, types, d)
                 where m != null && m.ChildCount > 0
                 select m as IMediaFolder).ToList();

              var rawfiles = from f in dir.GetFiles("*.*")
                     select f;
              var files = new List<BaseFile>();
              foreach (var f in rawfiles) {
            var ext = f.Extension;
            if (string.IsNullOrEmpty(ext) ||
              !exts.Contains(ext.Substring(1), StringComparer.InvariantCultureIgnoreCase)) {
              continue;
            }
            try {
              files.Add(server.GetFile(this, f));
            }
            catch (Exception ex) {
              server.Warn(f, ex);
            }
              }
              resources.AddRange(files);
        }
示例#4
0
        internal PlainFolder(FileServer server, VirtualFolder parent, DirectoryInfo dir)
            : base(parent, dir.Name)
        {
            Server   = server;
            this.dir = dir;
            var rawfiles = from f in dir.GetFiles("*.*")
                           select f;
            var files = new List <BaseFile>();

            foreach (var f in rawfiles)
            {
                var ext = f.Extension;
                if (string.IsNullOrEmpty(ext) ||
                    !server.Filter.Filtered(ext.Substring(1)))
                {
                    continue;
                }
                try {
                    var file = server.GetFile(this, f);
                    if (server.Allowed(file))
                    {
                        files.Add(file);
                    }
                }
                catch (Exception ex) {
                    server.Warn(f, ex);
                }
            }
            Resources.AddRange(files);

            Folders = (from d in dir.GetDirectories()
                       let m = TryGetFolder(server, d)
                               where m != null && m.ChildCount > 0
                               select m as IMediaFolder).ToList();
        }