/// <summary> /// Returns a UniFile based on the information from this FSNodeVirtualFile. It will first search for a local file and if there's no local file it'll get the virtual file. /// </summary> /// <param name="onlyVirtual">Set to true to ignore local files.</param> /// <param name="onlyLocal">Set to true to ignore virtual files.</param> /// <returns></returns> public override UniFile GetUniFile(bool onlyVirtual = false, bool onlyLocal = false) { UniFile uniFile = null; if (!onlyVirtual && HasLocal) { try { // try to open it uniFile = new UniFile(GetPath()); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it still exists! Info: {0}", e.Message); if (uniFile != null) { uniFile.Close(); } LoggingManager.HandleException(e); } return(uniFile); } // is it stored in a SGA archive? if (!onlyLocal || !HasLocal) { SGAStoredFile sgasfExtract = VirtualFile; try { // try to extract that file for our use into RAM uniFile = new UniFile(sgasfExtract.SGA.ExtractFile(sgasfExtract, (sgasfExtract.SGA.Stream))); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it's SGA archive still exists! Info: {0}", e.Message); if (uniFile != null) { uniFile.Close(); } LoggingManager.HandleException(e); } // set a pseudo path that will be used when saving the file if (uniFile != null) { uniFile.FilePath = GetPath(); } } return(uniFile); }
public FSNodeVirtualFile(string name, SGAStoredFile sgasf, FileTree tree, FSNodeDir parent = null) : base(name, tree, parent) { m_virtual = sgasf; }
public override void Deconstruct() { Parent = null; m_virtual = null; m_tree = null; }