public static void UpdateDownloadStatusSprite(PackageEntry packageEntry) { try { Assertion.NotNull(packageEntry, "packageEntry"); var ugc = m_WorkshopDetails(packageEntry); if (!packageEntry.publishedFileId.IsValid() || !ugc.publishedFileId.IsValid()) { //Log.Debug("[p0] entry name=" + packageEntry.entryName); RemoveDownloadStatusSprite(packageEntry); } else { var status = SteamUtilities.IsUGCUpToDate(ugc, out string reason); if (status == DownloadOK) { //Log.Debug("[p1] entry name=" + packageEntry.entryName); RemoveDownloadStatusSprite(packageEntry); } else { //Log.Debug("[p2] entry name=" + packageEntry.entryName); GetorCreateStatusPanel(packageEntry).StatusButton.SetStatus(status, reason); } } //Log.Succeeded(); } catch (Exception ex) { ex.Log(); } }
private Dictionary <string, string> GetPropertyDictionary(Metadata metadata, PackageEntry entry) { return(_mapper .GetPropertyPairs(metadata, entry) .GroupBy(x => x.Key) .ToDictionary(x => x.Key, x => x.First().Value)); }
/// <summary> /// Initializes a new entryfile from a packageentry and whether or not we should convert this entryfile /// </summary> /// <param name="entry">the packageentry that this entryfile represents</param> /// <param name="convert">whether or not to convert this packageentry</param> public EntryFile(PackageEntry entry, string newExtension, bool convert) { this.entry = entry; extension = newExtension ?? entry.TypeName; LoadData(convert); }
private static XmlDocument ReadXml(PackageEntry entry) { return((XmlDocument)AccountInstaller.ReadXmlMI.Invoke((object)null, new object[1] { (object)entry })); }
static void CheckPackage() { string filePath = Application.dataPath + "/../Library/PackageChecked"; if (!File.Exists(filePath)) { Debug.Log("[Auto Package] : Checking if required packages are included"); var packageListFile = Directory.GetFiles(Application.dataPath, "PackageImportList.txt", SearchOption.AllDirectories); if (packageListFile.Length == 0) { Debug.LogError("[Auto Package] : Couldn't find the packages list. Be sure there is a file called PackageImportList in your project"); } else { string packageListPath = packageListFile[0]; packageToAdd = new List <PackageEntry>(); string[] content = File.ReadAllLines(packageListPath); foreach (var line in content) { var split = line.Split('@'); PackageEntry entry = new PackageEntry(); entry.name = split[0]; entry.version = split.Length > 1 ? split[1] : null; packageToAdd.Add(entry); } File.WriteAllText(filePath, "Delete this to trigger a new auto package check"); listRequest = Client.List(); EditorApplication.update += Update; } } }
private void LoadPackage(int i, ClientHandler client, ContentManifestFile cmf) { PackageEntry entry = m_packageEntries[i]; using (Stream packageStream = cmf.OpenFile(client, entry.m_packageGUID)) using (BinaryReader packageReader = new BinaryReader(packageStream)) { var package = packageReader.Read <PackageHeader>(); m_packages[i] = package; if (package.m_recordCount == 0) { m_packageRecords[i] = new PackageRecord[0]; return; } if (package.m_bundleCount > 0) { packageStream.Position = package.m_offsetBundles; m_packageBundles[i] = packageReader.ReadArray <ulong>((int)package.m_bundleCount); } packageStream.Position = package.m_offsetRecords; using (GZipStream decompressedStream = new GZipStream(packageStream, CompressionMode.Decompress)) using (BinaryReader decompressedReader = new BinaryReader(decompressedStream)) { m_packageRecords[i] = decompressedReader.ReadArray <PackageRecord>((int)package.m_recordCount); } } }
//#endregion // new stuff public void CheckOnParentAndNode() { List <ContentReference> theList = new List <ContentReference>(); var shirt = _refConv.GetContentLink("Long Sleeve Shirt White Small_1"); var noProdParent = _refConv.GetContentLink("PriceTest_1"); var Pack = _refConv.GetContentLink("SomePackage_1"); var Prod = _refConv.GetContentLink("Shirt-Long-Sleeve_1"); var node = _refConv.GetContentLink("Shirts_1"); theList.Add(shirt); // parent = node, ...typeId "Variation" ... no children theList.Add(noProdParent); // parent = node ...typeId "Variation" ... no children theList.Add(Pack); // parent = node ...typeId "Package" ... no children theList.Add(Prod); //parent = node...typeId ""...no children theList.Add(node); // check ...TypeId - string/int var rel = new NodeEntryRelation { // IsPrimary // TargetCatalog }; var rel2 = new PackageEntry { //GroupName //Quantity //SortOrder }; var stuff = _contentLoader.GetItems(theList, new LoaderOptions()); foreach (var item in stuff) { var Parent = _contentLoader.Get <CatalogContentBase>(item.ParentLink); // new... var children = _contentLoader.GetChildren <CatalogContentBase>(item.ContentLink); var ii = item.GetOriginalType().Name; // "ShirtVariation" ... have FullName also if (item is EntryContentBase) // use this, checks "the tree" { var ParentPackages = // Smashing on the node... of course - "Wrong base class" _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentPackages(); var ParentProducts = _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentProducts(); var ParentEntries = _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentEntries(); var ParentCategories = _contentLoader.Get <EntryContentBase>(item.ContentLink).GetCategories(); } } // Can do like this now, not tested yet //var children2 = _relationRepository.GetChildren<NodeEntryRelation>(parentLink); }
internal AssemblyTreeNode(LoadedAssembly assembly, PackageEntry packageEntry) { this.LoadedAssembly = assembly ?? throw new ArgumentNullException(nameof(assembly)); this.LazyLoading = true; this.PackageEntry = packageEntry; Init(); }
private static void Extract(string[] args) { string output = args.FirstOrDefault(); ulong[] guids = args.Skip(1).Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); if (string.IsNullOrWhiteSpace(output)) { return; } Dictionary <ulong, PackageRecord[]> records = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, PackageRecord[]> totalRecords = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, PackageHeader> packages = new Dictionary <ulong, PackageHeader>(); ApplicationPackageManifest apm = TankHandler.m_packageManifest; for (int i = 0; i < apm.m_packageEntries.Length; ++i) { PackageEntry entry = apm.m_packageEntries[i]; if (guids.Contains(teResourceGUID.LongKey(entry.m_packageGUID)) || guids.Contains(teResourceGUID.Index(entry.m_packageGUID))) { packages[entry.m_packageGUID] = apm.m_packages[i]; records[entry.m_packageGUID] = apm.m_packageRecords[i]; } totalRecords[entry.m_packageGUID] = apm.m_packageRecords[i]; } foreach (ulong key in records.Keys) { Save(output, key, records[key]); } }
public static void RemoveDownloadStatusSprite(PackageEntry packageEntry) { try { Assertion.NotNull(packageEntry, "packageEntry"); Destroy(GetStatusPanel(packageEntry)?.gameObject); //Log.Succeeded(); } catch (Exception ex) { ex.Log(); } }
public override void Put(PackageEntry entry) { this._skipAll = (bool)typeof(Sitecore.Install.Security.AccountInstaller).GetField("_skipAll", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object)this); if (this._skipAll) { return; } string[] strArray = entry.Key.Split('/'); if (strArray[0] != "security") { return; } if (!AccountInstaller.ContextUserHasEnoughRights()) { JobContext.Alert(Translate.Text("You do not have enough permissions to install security accounts")); this._skipAll = true; } else if (strArray.Length < 3) { Log.Error(string.Format("Bad entry key '{0}'", (object)entry.Key), (object)this); } else { if (strArray.Length > 3) { string domainName = strArray[2]; if (!DomainManager.DomainExists(domainName)) { this.UIEvents.ShowWarning(string.Format(Translate.Text("Unable to create the user '{0}' because domain '{1}' doesn't exist."), (object)AccountInstaller.GetAccountName(entry.Key), (object)domainName), "domain doesn't exist" + domainName); return; } } string str = strArray[1]; try { if (str == "users") { this.InstallUser(entry); } else if (str == "roles") { this.InstallRole(entry); } else { Log.Error(string.Format("Unexpected account type '{0}'", (object)entry.Key), (object)this); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { Log.Error(string.Format("Error installing entry '{0}'", (object)entry.Key), ex, (object)this); } } }
public void DefaultConstructor_InitializesDefaultValues() { var packageEntry = new PackageEntry(); Assert.Null(packageEntry.FullName); Assert.Null(packageEntry.Name); Assert.Equal(0, packageEntry.CompressedLength); Assert.Equal(0, packageEntry.Length); }
/// <summary> /// Grants access to the database. /// </summary> private void GrantOnly() { PackageEntry schemaFile = package["/Schema/Schema.sql"]; PackageEntry delProcFile = package["/Schema/DeleteProcs.sql"]; PackageEntry grantFile = package["/Schema/GrantAccess.sql"]; PackageEntry funcFolder = package["/Funcs"]; PackageEntry procFolder = package["/Procs"]; string script; string cs; SqlConnection sqlCon; QueryDisposition[] qd; if (schemaFile == null || !schemaFile.IsFile) { throw new InvalidOperationException("Invalid Database Package: /Schema/Schema.sql missing."); } if (delProcFile == null || !delProcFile.IsFile) { throw new InvalidOperationException("Invalid Database Package: /Schema/DeleteProcs.sql missing."); } if (grantFile == null || !grantFile.IsFile) { throw new InvalidOperationException("Invalid Database Package: /Schema/GrantAccess.sql missing."); } cs = string.Format("server={0};database={1};{2}", server, database, dbParams.AdminSecurity); sqlCon = new SqlConnection(cs); sqlCon.Open(); try { // Grant access to the application account if (account == null) { script = Helper.FromAnsi(grantFile.GetContents()); script = script.Replace("%account%", account); qd = new SqlScriptRunner(script).Run(sqlCon, true); for (int i = 0; i < qd.Length; i++) { if (qd[i].Message != null) { throw new InvalidOperationException(qd[i].Message); } } } } finally { sqlCon.Close(); } }
public static EntryStatusPanel GetStatusPanel(PackageEntry packageEntry) { var ret = packageEntry?.GetComponentInChildren <EntryStatusPanel>(); if (!ret || !ret.enabled) { ret = null; } return(ret);//.LogRet(CurrentMethod(1, packageEntry?.entryName)); }
private static void ConvertCPackageEntry( NativeEnvironment e, PackageEntry src, CPackageEntry *dst) { dst->offset = src.Offset; dst->length = src.Length; dst->bytes = src.Bytes == null ? null : e.Pin(src.Bytes); dst->type = src.Type; dst->full_path = e.ToCString(src.FullPath); }
public static byte[] Decrypt(byte[] entryBytes, byte[] keySeed, PackageEntry entry) { var iv_key = Sha256( entry.ToArray() .Concat(keySeed) .ToArray()); var tmp = new byte[entryBytes.Length]; AesCbcCfb128Decrypt(tmp, entryBytes, tmp.Length, iv_key.Skip(16).Take(16).ToArray(), iv_key.Take(16).ToArray()); return(tmp); }
private static void ExtractEntry(PackageEntry entry, ref string outputDirectory) { if (Program.Closing) { Environment.Exit(0); } // save raw var filePathWithoutExtension = _options.SingleDir ? Path.Combine(outputDirectory, entry.Name) : Path.Combine(outputDirectory, entry.DirectoryPath, entry.Name); var filePath = filePathWithoutExtension + entry.Extension; Directory.CreateDirectory(Path.GetDirectoryName(filePathWithoutExtension)); if (!_options.Overwrite && File.Exists(filePath)) { Console.WriteLine($"* Skipping, already exists: {filePath}"); } else { Console.WriteLine($"* Extracting: {entry.FullPath}"); File.WriteAllBytes(filePath, entry.Bytes); } // decompile and save if (_options.NoTexDecompile || entry.Type != EntryType.Tex) { return; } var tex = LoadTex(entry.Bytes, entry.FullPath); if (tex == null) { return; } try { TexPreviewWriter.WriteTexture(tex, filePathWithoutExtension, _options.Overwrite); var jsonInfo = _texJsonInfoGenerator.GenerateInfo(tex); File.WriteAllText($"{filePathWithoutExtension}.tex-json", jsonInfo); } catch (Exception e) { Console.WriteLine("Failed to write texture"); Console.WriteLine(e); } }
public void AddFile(PackageEntry macro) { if (macro.Name.Length <= 32) { fileEntries.Enqueue(macro); } else { NotifyDetails(String.Format("Error :> Filename overflow :> \"{0}\"", macro.Name)); HasErrors = true; } }
static EntryStatusPanel Create(PackageEntry packageEntry) { Log.Called(); Assertion.Assert(packageEntry, "packageEntry"); var topPanel = packageEntry.GetComponent <UIPanel>(); Assertion.Assert(topPanel, "topPanel"); var ret = topPanel.AddUIComponent <EntryStatusPanel>(); ret.StatusButton.UGCDetails = m_WorkshopDetails(packageEntry); return(ret);//.LogRet(ThisMethod); }
public void AddPackageAsync(PackageEntry package) { BsonDocument bd = package.ToBsonDocument(); Console.WriteLine($"adding package: {package.Package}"); m_Packagecollection.InsertOneAsync(bd); ObjectId id = bd["_id"].AsObjectId; Sha1Db.Instance.AddHashAsync(package.Sha1, id); Md5Db.Instance.AddHashAsync(package.Md5Sum, id); Sha256Db.Instance.AddHashAsync(package.Sha256, id); }
public void Constructor_WithValidArguments_InitializesInstance() { using (var zipArchive = CreateZipArchive()) { var zipArchiveEntry = zipArchive.Entries[0]; var packageEntry = new PackageEntry(zipArchiveEntry); Assert.Equal(zipArchiveEntry.FullName, packageEntry.FullName); Assert.Equal(zipArchiveEntry.Name, packageEntry.Name); Assert.Equal(zipArchiveEntry.CompressedLength, packageEntry.CompressedLength); Assert.Equal(zipArchiveEntry.Length, packageEntry.Length); } }
public void JsonSerialization_ReturnsCorrectJson() { var packageEntry = new PackageEntry() { FullName = "a/b", Name = "b", CompressedLength = 2, Length = 1 }; var json = JsonConvert.SerializeObject(packageEntry); Assert.Equal("{\"fullName\":\"a/b\",\"name\":\"b\",\"length\":1,\"compressedLength\":2}", json); }
void SaveEntry(ITextOutput output, PackageEntry entry, string targetFileName) { output.Write(entry.Name + ": "); using Stream stream = entry.TryOpenStream(); if (stream == null) { output.WriteLine("Could not open stream!"); return; } stream.Position = 0; using FileStream fileStream = new FileStream(targetFileName, FileMode.OpenOrCreate); stream.CopyTo(fileStream); output.WriteLine("Written to " + targetFileName); }
public override void Put(PackageEntry entry) { this._skipAll = (bool)typeof(Sitecore.Install.Security.AccountInstaller).GetField("_skipAll", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object)this); if (this._skipAll) return; string[] strArray = entry.Key.Split('/'); if (strArray[0] != "security") return; if (!AccountInstaller.ContextUserHasEnoughRights()) { JobContext.Alert(Translate.Text("You do not have enough permissions to install security accounts")); this._skipAll = true; } else if (strArray.Length < 3) { Log.Error(string.Format("Bad entry key '{0}'", (object)entry.Key), (object)this); } else { if (strArray.Length > 3) { string domainName = strArray[2]; if (!DomainManager.DomainExists(domainName)) { this.UIEvents.ShowWarning(string.Format(Translate.Text("Unable to create the user '{0}' because domain '{1}' doesn't exist."), (object)AccountInstaller.GetAccountName(entry.Key), (object)domainName), "domain doesn't exist" + domainName); return; } } string str = strArray[1]; try { if (str == "users") this.InstallUser(entry); else if (str == "roles") this.InstallRole(entry); else Log.Error(string.Format("Unexpected account type '{0}'", (object)entry.Key), (object)this); } catch (ThreadAbortException) { throw; } catch (Exception ex) { Log.Error(string.Format("Error installing entry '{0}'", (object)entry.Key), ex, (object)this); } } }
private static void Convert(string[] args) { string output = args.FirstOrDefault(); ulong[] guids = args.Skip(1).Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); if (string.IsNullOrWhiteSpace(output)) { return; } Dictionary <ulong, PackageRecord[]> records = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, PackageHeader> packages = new Dictionary <ulong, PackageHeader>(); var apm = TankHandler.m_packageManifest; for (int i = 0; i < apm.m_packageEntries.Length; ++i) { PackageEntry entry = apm.m_packageEntries[i]; if (!guids.Contains(teResourceGUID.LongKey(entry.m_packageGUID)) && !guids.Contains(teResourceGUID.Index(entry.m_packageGUID)) && !guids.Contains(entry.m_packageGUID)) { continue; } packages[entry.m_packageGUID] = apm.m_packages[i]; records[entry.m_packageGUID] = apm.m_packageRecords[i]; } ICLIFlags flags = FlagParser.Parse <ExtractFlags>(); void Body(ulong key) { DataTool.FindLogic.Combo.ComboInfo info = new DataTool.FindLogic.Combo.ComboInfo(); string dest = Path.Combine(output, teResourceGUID.AsString(key)); foreach (PackageRecord record in records[key]) { DataTool.FindLogic.Combo.Find(info, record.m_GUID); } var context = new DataTool.SaveLogic.Combo.SaveContext(info); DataTool.SaveLogic.Combo.Save(flags, dest, context); context.Wait(); } Parallel.ForEach(records.Keys, Body); }
Func <IPackage> LoadPackage(PackageEntry packageEntry) { return(() => { var response = _client.CreateRequest(packageEntry.PackageHref).Get().Send(); if (response.Entity == null) { return null; } var tempFile = _fileSystem.CreateTempFile(); var tempDirectory = _fileSystem.CreateTempDirectory(); using (var tempStream = tempFile.OpenWrite()) NuGetConverter.Convert(response.Entity.Stream, tempStream); return new CachedZipPackage(this, tempFile, tempDirectory).Load(); }); }
private static void SearchType(IEnumerable <string> args) { ulong[] guids = args.Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); ApplicationPackageManifest apm = TankHandler.m_packageManifest; for (int i = 0; i < apm.m_packageEntries.Length; ++i) { PackageEntry entry = apm.m_packageEntries[i]; PackageRecord[] records = apm.m_packageRecords[i]; foreach (PackageRecord record in records.Where(x => guids.Contains(teResourceGUID.Type(x.m_GUID)))) { Log("Found {0} in package {1:X12}", teResourceGUID.AsString(record.m_GUID), teResourceGUID.LongKey(entry.m_packageGUID)); } } }
private static void Info(IEnumerable <string> args) { ulong[] guids = args.Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); ApplicationPackageManifest apm = TankHandler.m_packageManifest; for (int i = 0; i < apm.m_packageEntries.Length; ++i) { PackageEntry entry = apm.m_packageEntries[i]; if (!guids.Contains(teResourceGUID.LongKey(entry.m_packageGUID)) && !guids.Contains(teResourceGUID.Index(entry.m_packageGUID))) { continue; } Log("Package {0:X12}:", teResourceGUID.LongKey(entry.m_packageGUID)); Log("\tUnknowns: {0}, {1}", entry.m_unknown1, entry.m_unknown2); Log("\t{0} records", apm.m_packageRecords[i].Length); } }
private static void SearchType(string[] args) { ulong[] guids = args.Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); foreach (ApplicationPackageManifest apm in Root.APMFiles) { for (int i = 0; i < apm.PackageEntries.Length; ++i) { PackageEntry entry = apm.PackageEntries[i]; PackageRecord[] records = apm.Records[i]; foreach (PackageRecord record in records.Where(x => guids.Contains(teResourceGUID.Type(x.GUID)))) { Log("Found {0} in package {1:X12}", teResourceGUID.AsString(record.GUID), teResourceGUID.LongKey(entry.PackageGUID)); } } } }
protected new void InstallUser(PackageEntry entry) { string accountName = AccountInstaller.GetAccountName(entry.Key); if (User.Exists(accountName)) { Log.Info(string.Format("Installing of entry '{0}' was skipped. User already exists.", (object)accountName), (object)this); this.UIEvents.ShowWarning(string.Format(Translate.Text("User '{0}' will not be installed since the user already exists."), (object)accountName), "user already exists"); } else { XmlDocument xml = AccountInstaller.ReadXml(entry); if (!Context.User.IsAdministrator && this.TryingToInstallAdmin(xml, accountName)) { return; } string password = AccountInstaller.GetPassword(xml); User user = (User)null; try { user = User.Create(accountName, password); this.SetUserProfile(user, xml); this.SetUserProperties(user, xml); this.SetUserRoles(user, xml); } catch (Exception ex) { try { if ((Account)user != (Account)null) { user.Delete(); } } catch { } Log.Error(string.Format("Failed to install the user '{0}'", (object)accountName), ex, (object)this); throw; } Log.Info(string.Format("User '{0}' has been installed successfully", (object)user.Name), (object)this); } }
private static void Extract(string[] args) { string output = args.FirstOrDefault(); ulong[] guids = args.Skip(1).Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); if (string.IsNullOrWhiteSpace(output)) { return; } Dictionary <ulong, PackageRecord[]> records = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, PackageRecord[]> totalRecords = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, ulong[]> siblings = new Dictionary <ulong, ulong[]>(); Dictionary <ulong, Package> packages = new Dictionary <ulong, Package>(); foreach (ApplicationPackageManifest apm in (CASC.Root as OwRootHandler).APMFiles) { for (int i = 0; i < apm.PackageEntries.Length; ++i) { PackageEntry entry = apm.PackageEntries[i]; if (guids.Contains(GUID.LongKey(entry.PackageGUID)) || guids.Contains(GUID.Index(entry.PackageGUID))) { packages[entry.PackageGUID] = apm.Packages[i]; siblings[entry.PackageGUID] = apm.PackageSiblings[i]; records[entry.PackageGUID] = apm.Records[i]; } totalRecords[entry.PackageGUID] = apm.Records[i]; } } foreach (ulong key in records.Keys) { Save(output, key, records[key]); foreach (ulong sibling in siblings[key]) { if (totalRecords.ContainsKey(sibling)) { Save(output, key, sibling, totalRecords[sibling]); } } } }
private static void Convert(string[] args) { string output = args.FirstOrDefault(); ulong[] guids = args.Skip(1).Select(x => ulong.Parse(x, NumberStyles.HexNumber)).ToArray(); if (string.IsNullOrWhiteSpace(output)) { return; } Dictionary <ulong, PackageRecord[]> records = new Dictionary <ulong, PackageRecord[]>(); Dictionary <ulong, Package> packages = new Dictionary <ulong, Package>(); foreach (ApplicationPackageManifest apm in Root.APMFiles) { for (int i = 0; i < apm.PackageEntries.Length; ++i) { PackageEntry entry = apm.PackageEntries[i]; if (guids.Contains(teResourceGUID.LongKey(entry.PackageGUID)) || guids.Contains(teResourceGUID.Index(entry.PackageGUID))) { packages[entry.PackageGUID] = apm.Packages[i]; records[entry.PackageGUID] = apm.Records[i]; } } } ICLIFlags flags = FlagParser.Parse <ExtractFlags>(); MapCMF(); LoadGUIDTable(); Sound.WwiseBank.GetReady(); Parallel.ForEach(records.Keys, (key) => { DataTool.FindLogic.Combo.ComboInfo info = new DataTool.FindLogic.Combo.ComboInfo(); string dest = Path.Combine(output, teResourceGUID.AsString(key)); foreach (PackageRecord record in records[key]) { DataTool.FindLogic.Combo.Find(info, record.GUID); } DataTool.SaveLogic.Combo.Save(flags, dest, info); }); }
public AFSPackageLoader(ExStream exs, String title = null) : base(exs) { if (StreamTools.ReadASCII(m_bs, 4) != "AFS\0") throw new InvalidDataException(); Int32 fcount = StreamTools.ReadI32(m_bs, BitSequence.LittleEndian); List<PackageEntry> files = new List<PackageEntry>(); for (int i = 0; i < fcount; i++) { PackageEntry macro = new PackageEntry(); macro.Offset = StreamTools.ReadI32(m_bs, BitSequence.LittleEndian); macro.Length = StreamTools.ReadI32(m_bs, BitSequence.LittleEndian); files.Add(macro); } Int32 indx_start = StreamTools.ReadI32(m_bs, BitSequence.LittleEndian); Int32 indx_len = m_bs.ReadInt(BitSequence.LittleEndian); m_bs.Position = indx_start; for (int i = 0; i < fcount; i++) { files[i].Name = StreamTools.ReadASCII(m_bs, 0x20).Replace("\0", ""); Int16 f_dy = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int16 f_dd = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int16 f_dm = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int16 f_th = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int16 f_tm = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int16 f_ts = StreamTools.ReadI16(m_bs, BitSequence.LittleEndian); Int32 f_rsize = StreamTools.ReadI32(m_bs, BitSequence.LittleEndian); files[i].SetAdditionalProperty("Date", new DateTime(f_dy, f_dd, f_dm, f_th, f_tm, f_ts)); files[i].SetAdditionalProperty("Data", f_rsize.ToString()); } foreach (PackageEntry entry in files) { PushEntry(entry); GetInputStream(entry); } m_root.Title = title; }
/// <summary> /// Adds a node to the tree based on the passed file information. This is useful when building a directory-based tree. /// </summary> /// <param name="file">File entry.</param> public void AddFileNode(PackageEntry file) { TreeNode currentNode = null; if (file.DirectoryName != null) { var subPaths = file.DirectoryName.Split(Package.DirectorySeparatorChar); foreach (var subPath in subPaths) { if (currentNode == null) { currentNode = Nodes[subPath] ?? Nodes.Add(subPath, subPath, @"_folder", @"_folder"); } else { currentNode = currentNode.Nodes[subPath] ?? currentNode.Nodes.Add(subPath, subPath, @"_folder", @"_folder"); } currentNode.Tag = new TreeViewFolder(file.DirectoryName, currentNode.Nodes.Count + 1); //is this enough? } } var fileName = file.GetFileName(); var ext = ExtensionIconList[file.TypeName]; if (currentNode == null) { currentNode = Nodes.Add(fileName, fileName, ext, ext); } else { currentNode = currentNode.Nodes.Add(fileName, fileName, ext, ext); } currentNode.Tag = file; //so we can use it later }
public void ExtractSingle(PackageEntry entry, String path) { String dir = Path.GetFileDirectory(path); if (dir != "" && !System.IO.Directory.Exists(dir)) System.IO.Directory.CreateDirectory(dir); ExtractSingleInner(entry, path); }
public abstract void SetEntryLengthInPhysicalFileDB(PackageEntry entry, Int64 value);
protected override void PushEntry(PackageEntry f, PackageEntry dir) { base.PushEntry(f, dir); m_sortedEntries.Add(f, f.Offset); }
public Stream GetContent(PackageEntry entry) { Stream parentStream; var offset = dataStart + entry.Offset + SegmentStream.GetOverallNestedOffset(s, out parentStream); var path = ((FileStream)parentStream).Name; return new SegmentStream(File.OpenRead(path), offset, entry.Length); }
protected virtual void PushEntry(PackageEntry f, PackageEntry dir) { PushEntryToDir(f, dir); Int32 n = m_entries.Count; m_entries.Add(f); m_map.Add(f, n); }
protected void PushEntryToDir(PackageEntry f, PackageEntry dir) { String d = ""; String tn = f.Name; if (f.Name.Contains("\\") || f.Name.Contains("/")) { d = Path.PopFirstDir(ref tn); f.Name = tn; } if (d == "") { dir.SubEntries.Add(f); dir.SubEntriesMap.Add(f.Name, f); f.Parent = dir; } else { if (!dir.SubEntriesMap.ContainsKey(d)) { PackageEntry dir_entry = PackageEntry.CreateDir(d); dir.SubEntries.Add(dir_entry); dir.SubEntriesMap.Add(dir_entry.Name, dir_entry); dir_entry.Parent = dir; } PushEntryToDir(f, dir.SubEntriesMap[d]); } }
//============================ public static Queue<PackageEntry> BuildFileList(string bpath, string path, Queue<PackageEntry> q) { string[] sfs = System.IO.Directory.GetFiles(path); foreach (string ds in sfs) { FileInfo fi = new FileInfo(ds); PackageEntry entry = new PackageEntry(); entry.Name = Path.GetRelativePath(ds, bpath); entry.Length = fi.Length; entry.SetAdditionalProperty("Date", fi.LastWriteTime); entry.SetAdditionalProperty("Data", new ExStream(ds, FileMode.Open, FileAccess.Read)); q.Enqueue(entry); } string[] sds = System.IO.Directory.GetDirectories(path); foreach (string dds in sds) { q = BuildFileList(bpath, dds, q); } return q; }
public void ExtractMultiple(PackageEntry[] entries, String[] paths) { if (entries.Length != paths.Length) throw new ArgumentException(); for (int i = 0; i < paths.Length; i++) { String dir = Path.GetFileDirectory(paths[i]); if (dir != "" && !System.IO.Directory.Exists(dir)) System.IO.Directory.CreateDirectory(dir); } ExtractMultipleInner(entries, paths); }
protected virtual void PushEntry(PackageEntry f) { PushEntry(f, m_root); }
public void Extract(PackageEntry entry, ExStreamBase exs) { if (entry.Type != PackageEntry.EntryType.File) throw new InvalidOperationException("PackageBase.Extract(...) :> Cannot directly extract directories"); ExtractInner(entry, exs); }
protected virtual ExPartStream GetInputStreamInner(PackageEntry entry) { return new ExPartStream(m_bs, new Range() { Lower = entry.Offset, Length = entry.Length }, System.IO.FileAccess.Read); }
internal virtual void InitFrom(PackageEntry entry) { this.Name = entry.Name; }
protected virtual void ExtractSingleInner(PackageEntry entry, String path) { using (ExStream exs = new ExStream(path, System.IO.FileMode.Create)) { Extract(entry, exs); } }
public Stream LoadPackage(PackageEntry packageEntry) { throw new NotSupportedException(); }
protected virtual void ExtractMultipleInner(PackageEntry[] entries, String[] paths) { for (int i = 0; i < entries.Length - 1; i++) { ExtractSingle(entries[i], paths[i]); } }
public override void SetEntryLengthInPhysicalFileDB(PackageEntry entry, long value) { Int32 index = m_map[entry]; Int64 pos = index * 12 + 8; m_bs.Position = pos; m_bs.WriteInt((int)value, BitSequence.LittleEndian); }
protected virtual void ExtractInner(PackageEntry entry, ExStreamBase exs) { using (ExPartStream fout = new ExPartStream(m_bs, new Range() { Lower = entry.Offset, Length = entry.Length })) { fout.WriteTo(exs); } }
public override long GetEntryLengthInPhysicalFileDB(PackageEntry entry) { Int32 index = m_map[entry]; Int64 pos = index * 12 + 8; m_bs.Position = pos; return m_bs.ReadInt(BitSequence.LittleEndian); }
public ExPartStream GetInputStream(PackageEntry entry) { if (entry.Type != PackageEntry.EntryType.File) throw new InvalidOperationException("PackageBase.Extract(...) :> Cannot directly extract directories"); return GetInputStreamInner(entry); }
private static XmlDocument ReadXml(PackageEntry entry) { return (XmlDocument)AccountInstaller.ReadXmlMI.Invoke((object)null, new object[1] { (object) entry }); }
public abstract Int64 GetEntryLengthInPhysicalFileDB(PackageEntry entry);
protected new void InstallUser(PackageEntry entry) { string accountName = AccountInstaller.GetAccountName(entry.Key); if (User.Exists(accountName)) { Log.Info(string.Format("Installing of entry '{0}' was skipped. User already exists.", (object)accountName), (object)this); this.UIEvents.ShowWarning(string.Format(Translate.Text("User '{0}' will not be installed since the user already exists."), (object)accountName), "user already exists"); } else { XmlDocument xml = AccountInstaller.ReadXml(entry); if (!Context.User.IsAdministrator && this.TryingToInstallAdmin(xml, accountName)) return; string password = AccountInstaller.GetPassword(xml); User user = (User)null; try { user = User.Create(accountName, password); this.SetUserProfile(user, xml); this.SetUserProperties(user, xml); this.SetUserRoles(user, xml); } catch (Exception ex) { try { if ((Account)user != (Account)null) user.Delete(); } catch { } Log.Error(string.Format("Failed to install the user '{0}'", (object)accountName), ex, (object)this); throw; } Log.Info(string.Format("User '{0}' has been installed successfully", (object)user.Name), (object)this); } }
public Stream GetContent(PackageEntry entry) { Stream parentStream; var baseOffset = dataStart + entry.Offset; var nestedOffset = baseOffset + SegmentStream.GetOverallNestedOffset(s, out parentStream); // Special case FileStream - instead of creating an in-memory copy, // just reference the portion of the on-disk file that we need to save memory. // We use GetType instead of 'is' here since we can't handle any derived classes of FileStream. if (parentStream.GetType() == typeof(FileStream)) { var path = ((FileStream)parentStream).Name; return new SegmentStream(File.OpenRead(path), nestedOffset, entry.Length); } // For all other streams, create a copy in memory. // This uses more memory but is the only way in general to ensure the returned streams won't clash. s.Seek(baseOffset, SeekOrigin.Begin); return new MemoryStream(s.ReadBytes((int)entry.Length)); }