Beispiel #1
0
        public DirectoryInMemory(DirectoryInfo directoryInfo, ILogger logger)
        {
            DirectoryInfo = directoryInfo;
            Logger        = logger;

            try
            {
                foreach (FileSystemInfo fileSystemInfo in DirectoryInfo.EnumerateFileSystemInfos())
                {
                    if (fileSystemInfo is DirectoryInfo subDirectoryInfo)
                    {
                        DirectoryInMemory directoryInMemory = new DirectoryInMemory(subDirectoryInfo, logger, this);
                        SubDirectories.Add(directoryInMemory);
                    }
                    else if (fileSystemInfo is FileInfo fileInfo)
                    {
                        FileInMemory fileInMemory = new FileInMemory(fileInfo, this);
                        Files.Add(fileInMemory);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogWarning($"Cannot read contents of \"{directoryInfo.FullName}\"", e);
            }
        }
Beispiel #2
0
        public void DeleteEmptySubDirectories(DateTime olderThanUtc)
        {
            for (int i = SubDirectories.Count - 1; i >= 0; --i)
            {
                DirectoryInMemory subDirectory = SubDirectories[i];
                subDirectory.DeleteEmptySubDirectories(olderThanUtc);

                if (subDirectory.DirectoryInfo.CreationTimeUtc < olderThanUtc)
                {
                    subDirectory.DeleteIfEmpty();
                }
            }
        }
Beispiel #3
0
 private void RemoveDirectory(DirectoryInMemory directoryInMemory)
 {
     SubDirectories.Remove(directoryInMemory);
 }
Beispiel #4
0
 private DirectoryInMemory(DirectoryInfo directoryInfo, ILogger logger, DirectoryInMemory parentDirectory) : this(directoryInfo, logger)
 {
     ParentDirectory = parentDirectory;
 }
 internal FileInMemory(FileInfo fileInfo, DirectoryInMemory parentDirectory)
 {
     FileInfo        = fileInfo;
     ParentDirectory = parentDirectory;
 }