1using System.IO.Compression;
25 using ZipArchive zip =
new ZipArchive(str, ZipArchiveMode.Update,
true);
27 foreach (
string file
in fs.GetFiles(path,
"",
true))
30 ZipArchiveEntry e = zip.CreateEntry(file.Remove(0, path.Length));
31 using Stream estr = e.Open();
32 using Stream fstr = fs.OpenRead(file);
39 using FileStream str =
new FileStream(path, FileMode.Open, FileAccess.Read);
40 fs.ImportZip(str, root);
56 ZipArchive? arch =
new ZipArchive(str, ZipArchiveMode.Read,
false, encoding ?? Encoding.UTF8);
60 throw new Exception(
"Failed to open zip file");
63 foreach (ZipArchiveEntry entry
in arch.Entries)
65 BadLogger.
Log(
"Importing File: " + entry.FullName,
"BFS");
72 string? dir = Path.GetDirectoryName(entry.FullName);
74 if (dir !=
null && !
string.IsNullOrEmpty(dir))
76 fs.CreateDirectory(root + dir,
true);
79 using Stream s = entry.Open();
80 using Stream o = fs.OpenWrite(root + entry.FullName,
BadWriteMode.CreateNew);
Public facing interface for a logger.
static void Log(string message)
Writes a Log to the Message Handler.
File System Helper Extensions.
static void ImportZip(this IVirtualFileSystem fs, Stream str, string root="/", Encoding? encoding=null)
Imports a Zip File to a Virtual File System.
static void ExportZip(this IVirtualFileSystem fs, Stream str, string path="/")
Exports a Virtual File System to a Zip File.
static void ImportZip(this IVirtualFileSystem fs, string path, string root="/")
Implements Operations to read and manipulate File System Paths.
static bool IsDirectory(string path)
Contains Logging system for the BadScript Runtime.
Contains the Implementation of the BadScript Virtual File System.
Contains IO Implementation for the BadScript2 Runtime.
BadWriteMode
The Write Modes of the File System Abstraction.