Skip to content

Commit

Permalink
SWORD module save directly to ztext after backing up.
Browse files Browse the repository at this point in the history
  • Loading branch information
sabdelmalik committed Feb 13, 2023
1 parent 4bd9030 commit 7e44ade
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion src/BibleTaggingUtil/BibleTaggingUtil/BibleTaggingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ private void generateOSISToolStripMenuItem_Click(object sender, EventArgs e)

private void generateSWORDFilesOsisToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveUpdates();
new Thread(
() =>
{
Expand All @@ -1259,6 +1260,7 @@ private void generateSWORDFilesOsisToolStripMenuItem_Click(object sender, EventA
#region USFM Menu
private void generateUSFMFilesToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveUpdates();
new Thread(
() =>
{
Expand Down Expand Up @@ -1297,9 +1299,40 @@ private void RunOsis2mod(string sourceFileName, string targetFolderName)
{
WaitCursorControl(true);
string biblesFolder = Properties.Settings.Default.BiblesFolder;
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string modulesFolder = Path.Combine(appData, "Sword\\modules\\texts\\ztext");
string backupFolderName = string.Format("{0:s}_{1:s}", targetFolderName, DateTime.Now.ToString("yyyy_MM_dd_HH_mm"));
string backupPath = Path.Combine(biblesFolder, backupFolderName);
string targetFolder = Path.Combine(modulesFolder, targetFolderName);
if (Directory.Exists(targetFolder))
{
// backup currentModule
if(Directory.Exists(backupPath))
{
DialogResult res = MessageBox.Show("Overwrite old backup", "Do you want to overwrite existing Backup folder\r\n" + backupPath, MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
{
Directory.Delete(backupPath, true);
}
else
{
return;
}
}
Directory.CreateDirectory(backupPath);

// copy targetFolder to backupPath
var allFiles = Directory.GetFiles(targetFolder, "*.*");
foreach (string file in allFiles)
{
File.Copy(file, file.Replace(targetFolder, backupPath));
}
}


string parentFolder = Directory.GetParent(biblesFolder).FullName;
string executable = Path.Combine(parentFolder, "osis2mod.exe");
string targetFolder = Path.Combine(biblesFolder, targetFolderName);
// string targetFolder = Path.Combine(biblesFolder, targetFolderName);
string xmlFile = Path.Combine(biblesFolder, sourceFileName);
if (!Directory.Exists(targetFolder))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Copyright>Copyright © 2023 by Sami Abdel Malik</Copyright>
<RepositoryUrl>https://github.com/sabdelmalik/BibleTagging</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<Title>Bible Text Tagging with Strong's Numbers</Title>
</PropertyGroup>

Expand Down

0 comments on commit 7e44ade

Please sign in to comment.