FromArchive() static private method

static private FromArchive ( Stream archiveData, string fullOrigin ) : FileSource
archiveData Stream
fullOrigin string
return FileSource
Ejemplo n.º 1
0
 private FileSource LoadSource(string path)
 {
     if (path.StartsWith("ftp://") || path.StartsWith("http://") || path.StartsWith("https://"))
     {
         log?.WriteLine($"Downloading {path}");
         Uri uri = new Uri(path);
         using (HttpClient client = new HttpClient())
         {
             // I know using .Result is nasty, but we're in a console app, and nothing is
             // going to deadlock...
             var data = client.GetAsync(path).Result.EnsureSuccessStatusCode().Content.ReadAsByteArrayAsync().Result;
             log?.WriteLine($"Compiling from archive");
             return(FileSource.FromArchive(new MemoryStream(data), uri.AbsolutePath));
         }
     }
     if (Directory.Exists(path))
     {
         log?.WriteLine($"Compiling from directory {path}");
         return(FileSource.FromDirectory(path));
     }
     else
     {
         log?.WriteLine($"Compiling from archive file {path}");
         using (var file = File.OpenRead(path))
         {
             return(FileSource.FromArchive(file, path));
         }
     }
 }
Ejemplo n.º 2
0
 private FileSource LoadSource(string path)
 {
     if (path.StartsWith("ftp://") || path.StartsWith("http://") || path.StartsWith("https://"))
     {
         log?.WriteLine($"Downloading {path}");
         Uri uri = new Uri(path);
         using (WebClient client = new WebClient())
         {
             var data = client.DownloadData(path);
             log?.WriteLine($"Compiling from archive");
             return(FileSource.FromArchive(new MemoryStream(data), uri.AbsolutePath));
         }
     }
     if (Directory.Exists(path))
     {
         log?.WriteLine($"Compiling from directory {path}");
         return(FileSource.FromDirectory(path));
     }
     else
     {
         log?.WriteLine($"Compiling from archive file {path}");
         using (var file = File.OpenRead(path))
         {
             return(FileSource.FromArchive(file, path));
         }
     }
 }
Ejemplo n.º 3
0
        private async Task <FileSource> LoadSourceAsync(string path)
        {
            if (path.StartsWith("ftp://") || path.StartsWith("http://") || path.StartsWith("https://"))
            {
                log?.WriteLine($"Downloading {path}");
                var data = await FileUtility.LoadFileOrUrlAsync(path);

                return(FileSource.FromArchive(new MemoryStream(data), path));
            }
            if (Directory.Exists(path))
            {
                log?.WriteLine($"Compiling from directory {path}");
                return(FileSource.FromDirectory(path));
            }
            else
            {
                log?.WriteLine($"Compiling from archive file {path}");
                using (var file = File.OpenRead(path))
                {
                    return(FileSource.FromArchive(file, path));
                }
            }
        }