Skip to content

Commit

Permalink
Fixed FileNotFoundException while exporting individual XML img to pri…
Browse files Browse the repository at this point in the history
…vate server format
  • Loading branch information
eaxvac committed Jun 3, 2018
1 parent 9954f03 commit 77ac743
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions HaRepacker/GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,19 @@ private void RemoveSelectedNodes()
private void RunWzFilesExtraction(object param)
{
ChangeApplicationState(false);

string[] wzFilesToDump = (string[])((object[])param)[0];
string baseDir = (string)((object[])param)[1];
WzMapleVersion version = (WzMapleVersion)((object[])param)[2];
IWzFileSerializer serializer = (IWzFileSerializer)((object[])param)[3];
UpdateProgressBar(MainPanel.mainProgressBar, 0, false, true);
UpdateProgressBar(MainPanel.mainProgressBar, wzFilesToDump.Length, true, true);

if (!Directory.Exists(baseDir))
{
Directory.CreateDirectory(baseDir);
}

foreach (string wzpath in wzFilesToDump)
{
if (WzTool.IsListFile(wzpath))
Expand Down
16 changes: 9 additions & 7 deletions MapleLib/WzLib/WzSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ private void exportXmlInternal(WzImage img, string path)
bool parsed = img.Parsed || img.Changed;
if (!parsed) img.ParseImage();
curr++;
TextWriter tw = new StreamWriter(path);
tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + lineBreak);
tw.Write("<imgdir name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
foreach (WzImageProperty property in img.WzProperties)
WritePropertyToXML(tw, indent, property);
tw.Write("</imgdir>" + lineBreak);
tw.Close();

using (TextWriter tw = new StreamWriter(File.Create(path)))
{
tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + lineBreak);
tw.Write("<imgdir name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
foreach (WzImageProperty property in img.WzProperties)
WritePropertyToXML(tw, indent, property);
tw.Write("</imgdir>" + lineBreak);
}

if (!parsed)
img.UnparseImage();
Expand Down

0 comments on commit 77ac743

Please sign in to comment.