public void MakeBloomPack(string path, bool forReaderTools = false)
{
try
{
if(RobustFile.Exists(path))
{
// UI already got permission for this
RobustFile.Delete(path);
}
Logger.WriteEvent("Making BloomPack at "+path+" forReaderTools="+forReaderTools.ToString());
using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack...", "Bloom"))
{
try
{
pleaseWait.Show();
pleaseWait.BringToFront();
Application.DoEvents(); // actually show it
Cursor.Current = Cursors.WaitCursor;
var dir = TheOneEditableCollection.PathToDirectory;
var rootName = Path.GetFileName(dir);
if (rootName == null) return;
var dirNameOffest = dir.Length - rootName.Length;
Logger.WriteEvent("BloomPack path will be " + path + ", made from " + dir + " with rootName " + rootName);
using (var fsOut = RobustFile.Create(path))
{
using (ZipOutputStream zipStream = new ZipOutputStream(fsOut))
{
zipStream.SetLevel(9);
CompressDirectory(dir, zipStream, dirNameOffest, forReaderTools);
zipStream.IsStreamOwner = true; // makes the Close() also close the underlying stream
zipStream.Close();
}
}
// show it
Logger.WriteEvent("Showing BloomPack on disk");
PathUtilities.SelectFileInExplorer(path);
Analytics.Track("Create BloomPack");
}
finally
{
Cursor.Current = Cursors.Default;
pleaseWait.Close();
}
}
}
catch (Exception e)
{
ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack");
}
}