Beispiel #1
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();
        }
Beispiel #2
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);
        }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #5
0
 private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo d)
 {
     try {
         return(new PlainFolder(server, types, this, d));
     }
     catch (Exception ex) {
         server.Warn("Failed to access folder", ex);
         return(null);
     }
 }
Beispiel #6
0
 private PlainFolder TryGetFolder(FileServer server, DirectoryInfo d)
 {
     try {
     return new PlainFolder(server, this, d);
       }
       catch (Exception ex) {
     if (!d.Name.Equals("System Volume Information")) {
       server.Warn("Failed to access folder", ex);
     }
     return null;
       }
 }
Beispiel #7
0
 private PlainFolder TryGetFolder(FileServer server, DirectoryInfo d)
 {
     try {
         return(new PlainFolder(server, this, d));
     }
     catch (Exception ex) {
         if (!d.Name.Equals("System Volume Information"))
         {
             server.Warn("Failed to access folder", ex);
         }
         return(null);
     }
 }
Beispiel #8
0
        private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types,
                                         DirectoryInfo d)
        {
            // HAWKYNT: exclude recycle bin and system volume information
            if (d.Parent.IsRoot())
            {
                if (_EXCLUDED_ROOT_DIRECTORY_NAMES.Any(i => i == d.Name))
                {
                    Trace.WriteLine($"[Info]Skipping {d.FullName} because it is blacklisted");
                    return(null);
                }
            }

            try {
                return(new PlainFolder(server, types, this, d));
            }
            catch (Exception ex) {
                server.Warn("Failed to access folder", ex);
                return(null);
            }
        }
Beispiel #9
0
 private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo d)
 {
     try {
     return new PlainFolder(server, types, this, d);
       }
       catch (Exception ex) {
     server.Warn("Failed to access folder", ex);
     return null;
       }
 }