From 0f54938df35d5955d1404ccd0e97a183d82cdbd4 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 6 Apr 2016 00:53:00 -0700 Subject: [PATCH] Don't cut off extension --- SingleGame/SingleGame.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SingleGame/SingleGame.cs b/SingleGame/SingleGame.cs index c606a179..a77aa713 100644 --- a/SingleGame/SingleGame.cs +++ b/SingleGame/SingleGame.cs @@ -92,8 +92,14 @@ namespace SabreTools XmlElement tempNode = (XmlElement)tempDoc.ImportNode(child, true); // Windows max name length is 260. Taking into account the game name of "!", we can use 259 characters - tempNode.SetAttribute("name", "(" + node.Attributes["name"].Value + ")" + child.Attributes["name"].Value); - tempNode.Attributes["name"].Value = (tempNode.Attributes["name"].Value.Length > 259 ? tempNode.Attributes["name"].Value.Substring(0, 259) : tempNode.Attributes["name"].Value); + string tempname = "(" + node.Attributes["name"].Value + ")" + child.Attributes["name"].Value; + if (tempname.Length > 259) + { + string ext = Path.GetExtension(tempname); + tempname = tempname.Substring(0, 259 - ext.Length); + tempname += ext; + } + tempNode.SetAttribute("name", tempname); outNode.AppendChild(tempNode); } }