public PackageStream(string packageFile, string path) { #if !MOBILE log.InfoFormat("open package file {0} from {1}", path, packageFile); #endif var zipFile = PackageStream.GetZipFile(PackageStream.NormalizePath(packageFile)); if (zipFile == null) { throw PackageStream.FileNotFoundException(path, packageFile); } var entryIndex = zipFile.FindEntry(path, true); if (entryIndex == -1) { throw PackageStream.FileNotFoundException(path, packageFile); } try { _zipStream = zipFile.GetInputStream(entryIndex); } catch (Exception ex) { throw new IOException(string.Format("failed to open {0} in {1}", path, packageFile), ex); } }
public static string[] GetFileEntries(string packageFile) { if (!File.Exists(packageFile)) { return(null); } var zipFile = PackageStream.GetZipFile(packageFile); return(zipFile.Cast <ZipEntry>().Select(e => e.Name).ToArray()); }
public static bool IsFileExisted(string packageFile, string path) { if (!File.Exists(packageFile)) { return(false); } var zipFile = PackageStream.GetZipFile(packageFile); return(zipFile.FindEntry(path, true) != -1); }
public static long?GetCrc(string packageFile, string path) { #if !MOBILE log.InfoFormat("open package file {0} from {1}", path, packageFile); #endif var zipFile = PackageStream.GetZipFile(PackageStream.NormalizePath(packageFile)); try { var entryIndex = zipFile.FindEntry(path, true); var entry = zipFile[entryIndex]; return(entry.HasCrc ? entry.Crc : (long?)null); } catch (Exception) { throw PackageStream.FileNotFoundException(path, packageFile); } }