public IEnumerable <IFile> Files()
 {
     lock (ChildFiles)
     {
         return(ChildFiles.Where(x => x.Exists).Cast <IFile>().ToList());
     }
 }
Exemplo n.º 2
0
        private void GetDirInfo()
        {
            var di = new DirectoryInfo(FullPath);

            Name      = di.Name;
            Created   = di.CreationTime;
            LastWrite = di.LastWriteTime;
            var dirs  = Directory.EnumerateDirectories(FullPath).AsParallel();
            var files = Directory.EnumerateFiles(FullPath);

            if (dirs.Count() == 0 && files.Count() == 0)
            {
                TerminalLeaf = true;
            }
            if (dirs.Count() > 0)
            {
                foreach (var d in dirs)
                {
                    ChildDirectories.Add(Path.GetFileName(d));
                }
            }

            if (files.Count() > 0)
            {
                foreach (var f in files)
                {
                    ChildFiles.Add(Path.GetFileName(f));
                }
            }
        }
 public IEnumerable <IFile> Files(string filter, SearchScope searchScope)
 {
     lock (ChildFiles)
         lock (ChildDirectories)
         {
             var filterRegex       = filter.Wildcard();
             var immediateChildren = ChildFiles.Where(x => x.Exists && filterRegex.IsMatch(x.Name)).Cast <IFile>();
             return(searchScope == SearchScope.CurrentOnly
                                         ? immediateChildren.ToList()
                                         : immediateChildren.Concat(ChildDirectories.SelectMany(x => x.Files(filter, searchScope))).ToList());
         }
 }
        public IFile GetFile(string fileName)
        {
            InMemoryFile file;

            lock (ChildFiles)
            {
                file = ChildFiles.FirstOrDefault(x => x.Name.Equals(fileName, _stringComparison));
                if (file == null)
                {
                    file = new InMemoryFile(Path.Combine(fileName).FullPath)
                    {
                        Parent = this
                    };
                    ChildFiles.Add(file);
                }
                file.FileSystem = FileSystem;
            }
            return(file);
        }
Exemplo n.º 5
0
 private decimal GetEnabledSize()
 {
     return(ChildFiles.Where(x => x.IsEnabled == true).Sum(x => x.SizeInMb));
 }
Exemplo n.º 6
0
 private int GetEnabledMediaFiles(MediaType mediaType)
 {
     return(ChildFiles.Count(x => x.IsEnabled == true && x.MediaType == mediaType));
 }