/// <summary> /// Retrieves the list of files in the specified BSA. /// </summary> /// <param name="p_strBsa">The BSA whose file listing is requested.</param> /// <returns>The list of files contained in the specified BSA.</returns> /// <exception cref="IllegalFilePathException">Thrown if <paramref name="p_strBsa"/> /// contains illegal characters or refers to a file outside of the Data directory.</exception> /// <exception cref="BSAArchive.BSALoadException">Thrown if the specified BSA cannot be loaded.</exception> public string[] GetBSAFileList(string p_strBsa) { FileManagement.AssertFilePathIsSafe(p_strBsa); if (Path.GetDirectoryName(p_strBsa).Length > 0) throw new IllegalFilePathException(p_strBsa); PermissionsManager.CurrentPermissions.Assert(); if (!m_dicBSAs.ContainsKey(p_strBsa)) m_dicBSAs[p_strBsa] = new BSAArchive(Path.Combine(Program.GameMode.PluginsPath, p_strBsa)); return (string[])m_dicBSAs[p_strBsa].FileNames.Clone(); }
/// <summary> /// Gets the specified file from the specified BSA. /// </summary> /// <param name="p_strBsa">The BSA from which to extract the specified file.</param> /// <param name="p_strFile">The files to extract form the specified BSA.</param> /// <returns>The data of the specified file.</returns> /// <exception cref="IllegalFilePathException">Thrown if <paramref name="p_strBsa"/> /// contains illegal characters or refers to a file outside of the Data directory, or /// if <paramref name="p_strFile"/> refers to an unsafe location.</exception> /// <exception cref="BSAArchive.BSALoadException">Thrown if the specified BSA cannot be loaded.</exception> public byte[] GetDataFileFromBSA(string p_strBsa, string p_strFile) { FileManagement.AssertFilePathIsSafe(p_strBsa); FileManagement.AssertFilePathIsSafe(p_strFile); if (Path.GetDirectoryName(p_strBsa).Length > 0) throw new IllegalFilePathException(p_strBsa); PermissionsManager.CurrentPermissions.Assert(); string strLoweredBsa = p_strBsa.ToLowerInvariant(); if (!m_dicBSAs.ContainsKey(strLoweredBsa)) m_dicBSAs[strLoweredBsa] = new BSAArchive(Path.Combine(Program.GameMode.PluginsPath, strLoweredBsa)); return m_dicBSAs[strLoweredBsa].GetFile(p_strFile); }
internal BSAFileInfo(BSAArchive _bsa, int _offset, int _size) { bsa = _bsa; offset = _offset; size = _size; if ((size & (1 << 30)) != 0) { size ^= 1 << 30; compressed = !bsa.defaultCompressed; } else { compressed = bsa.defaultCompressed; } }