예제 #1
0
 protected ZipFileReference CreateZipFileReference(string path)
 {
     ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(System.IO.Path.Combine(Source, path.Substring(1)));
     lock (zipFiles)
     {
         ZipFileReference zipFileRef = new ZipFileReference();
         zipFiles.Add(path, zipFileRef);
         zipFileRef.Path = path;
         zipFileRef.RefCount++;
         zipFileRef.ZipFile = zipFile;
         return(zipFileRef);
     }
 }
예제 #2
0
        protected OpenedZipEntry CreateOpenedZipEntry(ZipFileReference zipFile, string fullPath, string path)
        {
            OpenedZipEntry entry = new OpenedZipEntry();

            entry.Path     = fullPath;
            entry.ZipFile  = zipFile;
            entry.ZipEntry = zipFile.ZipFile.GetEntry(path);
            entry.Stream   = zipFile.ZipFile.GetInputStream(entry.ZipEntry);
            entry.Data     = new byte[entry.ZipEntry.Size];
            entry.OpenCount++;
            entry.LastAccess = DateTime.Now;
            lock (zipEntries)
            {
                zipEntries.Add(fullPath, entry);
            }
            return(entry);
        }
예제 #3
0
 protected OpenedZipEntry CreateOpenedZipEntry(ZipFileReference zipFile, string fullPath, string path)
 {
     OpenedZipEntry entry = new OpenedZipEntry();
     entry.Path = fullPath;
     entry.ZipFile = zipFile;
     entry.ZipEntry = zipFile.ZipFile.GetEntry(path);
     entry.Stream = zipFile.ZipFile.GetInputStream(entry.ZipEntry);
     entry.Data = new byte[entry.ZipEntry.Size];
     entry.OpenCount++;
     entry.LastAccess = DateTime.Now;
     lock (zipEntries)
     {
         zipEntries.Add(fullPath, entry);
     }
     return entry;
 }
예제 #4
0
 protected ZipFileReference CreateZipFileReference(string path)
 {
     ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(System.IO.Path.Combine(Source, path.Substring(1)));
     lock (zipFiles)
     {
         ZipFileReference zipFileRef = new ZipFileReference();
         zipFiles.Add(path, zipFileRef);
         zipFileRef.Path = path;
         zipFileRef.RefCount++;
         zipFileRef.ZipFile = zipFile;
         return zipFileRef;
     }
 }
예제 #5
0
        protected override Errno OnOpenHandle(string file, OpenedPathInfo info)
        {
            if ((info.OpenFlags & (OpenFlags.O_CREAT | OpenFlags.O_APPEND | OpenFlags.O_WRONLY)) != 0)
            {
                return(Errno.EROFS);
            }
            try
            {
                Entry fsEntry = walker.SearchEntry(file.Substring(1));
                if (fsEntry == null)
                {
                    return(Errno.ENOENT);
                }
                if (fsEntry.Kind != EntryKind.ZipFileEntry)
                {
                    return(Errno.EIO);
                }
                if (!IsZipEntryOpened(file))
                {
                    if (!IsZipEntryCached(file))
                    {
                        Entry            zip           = walker.SearchEntry(file.Substring(1), EntryKind.ZipFile);
                        string           fileEntryPath = file.Substring(file.LastIndexOf(zip.Name + '/') + zip.Name.Length + 1);
                        string           zipPath       = file.Substring(0, file.LastIndexOf(zip.Name + '/') + zip.Name.Length);
                        ZipFileReference zipRef        = null;
                        if (!IsZipFileOpened(zipPath))
                        {
                            zipRef = CreateZipFileReference(zipPath);
                        }

                        else
                        {
                            zipRef = LockZipFileReference(zipPath);
                        }
                        CreateOpenedZipEntry(zipRef, file, fileEntryPath);
                    }

                    else
                    {
                        LockOpenedZipEntryFromCache(file);
                    }
                }

                else
                {
                    LockOpenedZipEntry(file);
                }
            }
            catch (DirectoryNotFoundException)
            {
                return(Errno.ENOTDIR);
            }
            catch (IOException)
            {
                return(Errno.EIO);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(0);
        }