Beispiel #1
0
 /// <summary>
 /// 注意:所有目录 必须以‘/’结尾
 /// </summary>
 /// <param name="zipfile">zip文件</param>
 /// <param name="tempDir">zip 释放或写入的临时目录</param>
 public ZipFileProvider(string zipfile, string tempDir)
     : this(ZipFileSystemConfiguration.CreateDefaultConfig(zipfile, tempDir))
 {
     if (!Directory.Exists(tempDir))
     {
         Directory.CreateDirectory(tempDir);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Creates the provider with the ZIP file to be processed.
        /// 注意:所有目录 必须以‘/’结尾
        /// </summary>
        public ZipFileProvider(ZipFileSystemConfiguration configuration)
        {
            Ensure.ArgumentNotNull(configuration, "configuration");
            Configuration = configuration;

            //init the repository
            NodeRepository = new ZipNodeRepository(configuration);

            InitTransferServices();
        }
Beispiel #3
0
        /// <summary>
        /// Creates a browser for a given zip file.
        /// </summary>
        /// <param name="configuration">Represents the processed ZIP file.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="configuration"/> is a
        /// null reference.</exception>
        public ZipNodeRepository(ZipFileSystemConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            Configuration = configuration;

            //create and immediately parse the ZIP file into a repository
            ZipFile = new ZipFile(configuration.ZipFileInfo.FullName);
            Refresh();
        }
Beispiel #4
0
        public static ZipFileSystemConfiguration CreateDefaultConfig(string zipfile, string tempDir)
        {
            //init transfer stores
            InMemoryTransferStore <ZipDownloadTransfer> downloadTransferStore = new InMemoryTransferStore <ZipDownloadTransfer>();
            InMemoryTransferStore <ZipUploadTransfer>   uploadTransferStore   = new InMemoryTransferStore <ZipUploadTransfer>();

            //init configuration
            var tempFactory   = new TempFileStreamFactory(tempDir);
            var configuration = new ZipFileSystemConfiguration(new FileInfo(zipfile), tempFactory);

            configuration.DownloadStore = downloadTransferStore;
            configuration.UploadStore   = uploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;
            configuration.MaxUploadFileSize           = (long)1024 * 1024 * 2048; //2GB limit
            //
            return(configuration);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            string ZipFilePath = Path.Combine("", "TestArchive.zip");

            if (File.Exists(ZipFilePath))
            {
                File.Delete(ZipFilePath);
            }
            var zip = new ZipFile(ZipFilePath);

            zip.AddDirectory("LocalVFS", "LocalVFS/");
            zip.Save();
            zip.Dispose();
            //
            ZipFileSystemConfiguration zc = ZipFileSystemConfiguration.CreateDefaultConfig(ZipFilePath, "_tmp_");
            ZipFileProvider            lp = new ZipFileProvider(zc);
            bool exfd = lp.ExistFolder("LocalVFS/", true);

            if (exfd)
            {
                lp.DeleteFolder("LocalVFS/");
            }
            byte[] dataTest = Encoding.UTF8.GetBytes("this is a test context!!!");
            File.WriteAllBytes("test.cs", dataTest);
            lp.CreateFolder("LocalVFS/");
            string filepath = lp.CreateFilePath("LocalVFS/", "test.txt");

            //lp.MoveFile("test.cs", filepath);
            byte[] dataTest2 = Encoding.UTF8.GetBytes("this is a test write data!!!");
            using (MemoryStream ms = new MemoryStream(dataTest2)) {
                lp.WriteFile("LocalVFS/test.txt", ms, true, dataTest2.Length, ContentUtil.UnknownContentType);
            }
            //lp.DeleteFile("LocalVFS/test.txt");
            lp.CopyFolder("LocalVFS/", "localvfs_test/");
            lp.Dispose();
            int jj = 0;
        }