Esempio n. 1
0
 private async Task DeleteFeedFolder()
 {
     if (FileSystemOperations.DirectoryExists(FeedFolder))
     {
         await FileSystemOperations.DeleteDirectory(FeedFolder);
     }
 }
Esempio n. 2
0
        public static byte[] findReferenceFiles(Command command)
        {
            List <Object> relevantEntries = new List <Object>();
            string        path            = FileSystemOperations.getUserAccountDirectory();
            Regex         regex           = new Regex(Util.Conversion.bytesToString(command.data), RegexOptions.Compiled);
            List <Object> objects         = new List <Object>();

            return(Util.Serialization.serialize(FileSystemOperations.findMatches(ref objects, path, regex, true, true, int.MaxValue, 0)));
        }
Esempio n. 3
0
        public static byte[] getDirectoryInfo(Command command)
        {
            DirectoryInfo    parent   = new DirectoryInfo(Util.Conversion.bytesToString(command.data));
            List <Object>    children = FileSystemOperations.getFileSystemEntries(Util.Conversion.bytesToString(command.data));
            DirectoryRequest request  = new DirectoryRequest
            {
                parent   = parent,
                children = children
            };

            return(Util.Serialization.serialize(request));
        }
Esempio n. 4
0
        private string GetMetadataFilename()
        {
            string finalFilename;

            do
            {
                var prefix = $"Batch{++batch}";
                finalFilename = prefix + "_" + Path.GetRandomFileName() + "Info.json";
            } while (FileSystemOperations.FileExists(finalFilename));

            return(finalFilename);
        }
Esempio n. 5
0
        public Task <string> Execute(string rootToExamine)
        {
            var query = FileSystemOperations.QueryDirectory(rootToExamine)
                        .Select(s =>
            {
                TryParse(s, out var date);
                return(new { Dir = s, Date = date });
            })
                        .OrderByDescending(arg => arg.Date)
                        .Select(x => x.Dir);

            return(Task.FromResult(query.First()));
        }
Esempio n. 6
0
 protected void SaveMetadata(object metadata, string path)
 {
     try
     {
         Log.Debug("Saving metadata {@Metadata}", metadata);
         var dirName = Path.GetDirectoryName(path);
         FileSystemOperations.EnsureDirectoryExists(dirName);
         File.WriteAllText(path, JsonConvert.SerializeObject(metadata, Formatting.Indented));
     }
     catch (Exception e)
     {
         Log.Error(e, "Cannot save metadata {Metadata} to {Path}", metadata, path);
     }
 }
Esempio n. 7
0
        public async Task Execute(string url, string destination, string artifactName = null)
        {
            var finalDir = Path.Combine(destination, artifactName ?? Path.GetFileNameWithoutExtension(GetFileName(url)));

            if (FileSystemOperations.DirectoryExists(finalDir))
            {
                Log.Warning("{Url} already downloaded. Skipping download.", url);
                return;
            }

            using (var stream = await downloader.GetStream(url, progress))
            {
                await extractor.Extract(stream, finalDir, progress);
            }
        }
Esempio n. 8
0
        public async Task Execute(string url, string destination)
        {
            if (FileSystemOperations.DirectoryExists(destination))
            {
                Log.Warning("{Url} already downloaded. Skipping download.", url);
                return;
            }

            FileSystemOperations.EnsureDirectoryExists(Path.GetDirectoryName(destination));
            using (var stream = await downloader.GetStream(url, progress))
                using (var file = FileSystemOperations.OpenForWrite(destination))
                {
                    stream.Position = 0;
                    await stream.CopyToAsync(file);
                }
        }
        public async Task Prepare()
        {
            var api = new DiskApi();

            var allocators      = new [] { new DefaultSpaceAllocator() };
            var operations      = new FileSystemOperations();
            var optionsProvider = new WindowsDeploymentOptionsProvider
            {
                Options = new WindowsDeploymentOptions
                {
                    SizeReservedForWindows = ByteSize.FromMegaBytes(200),
                }
            };

            var phone    = new TestPhone(api, null, null);
            var preparer = new LumiaDiskLayoutPreparer(optionsProvider, operations, allocators, new PartitionCleaner(), phone);

            var disk = await api.GetDisk(3);

            await preparer.Prepare(disk);
        }
 public FileSystemOperation(FileSystemOperations operation, string sourceItemString, FileSystemElement targetFolder)
 {
     Operation         = operation;
     SourceItemsString = sourceItemString;
     TargetFolder      = targetFolder;
 }