public static void Extract(string ba2Archive, string outputFolder) { Archive2.Call($"\"{ba2Archive}\" -extract=\"{outputFolder}\" -quiet"); if (!Directory.Exists(outputFolder)) { throw new Archive2Exception("Extraction failed, folder has not been created."); } else if (Utils.IsDirectoryEmpty(outputFolder)) { throw new Archive2Exception("Extraction failed, folder is empty."); } }
public static void Create(string ba2Archive, string folder, Archive2.Compression compression, Archive2.Format format) { if (!Directory.Exists(folder) || Utils.IsDirectoryEmpty(folder)) { throw new DirectoryNotFoundException($"The specified folder \"{folder}\" does not exist or is empty."); } string compressionStr = Enum.GetName(typeof(Archive2.Compression), (int)compression); string formatStr = Enum.GetName(typeof(Archive2.Format), (int)format); folder = Path.GetFullPath(folder); Archive2.Call($"\"{folder}\" -create=\"{ba2Archive}\" -compression={compressionStr} -format={formatStr} -root=\"{folder}\" -tempFiles -quiet"); if (!File.Exists(ba2Archive)) { throw new Archive2Exception("Packing failed, archive has not been created."); } }