Esempio n. 1
0
        public VFSItem Create(string path)
        {
            bool asDir = path.EndsWith("/");

            if (asDir)
            {
                path = path.Substring(0, path.Length - 1);
            }
            int    sep   = path.LastIndexOf('/');
            string inner = path.Substring(sep + 1);

            path = path.Substring(0, sep);
            VFSItem dir = GetItem(path);

            while (dir == null)
            {
                sep = path.LastIndexOf('/');
                if (sep < 0)
                {
                    return(null);
                }
                inner = path.Substring(sep + 1) + '/' + inner;
                path  = path.Substring(0, sep);
                dir   = GetItem(path);
            }
            if (!dir.Directory)
            {
                return(null);
            }
            return(dir.Create(inner, asDir));
        }
Esempio n. 2
0
        public void AddFile(VFSItem fil, string name)
        {
            ZipArchiveEntry zfil = z.CreateEntry(name);

            using (Stream zs = zfil.Open())
                using (Stream src = fil.OpenRead())
                {
                    zs.TransferFrom(src);
                }
        }
Esempio n. 3
0
 public void AddDirectory(VFSItem fil, string name)
 {
     foreach (VFSItem i in fil.ListFiles())
     {
         AddFile(i, name == null ? i.Name : name + '/' + i.Name);
     }
     foreach (VFSItem i in fil.ListDirectories())
     {
         AddDirectory(i, name == null ? i.Name : name + '/' + i.Name);
     }
 }