Added *.xml.rawclobber suffix to preserve whitespace

This commit is contained in:
Vhati 2014-10-21 21:28:50 -04:00
parent 0fa72e5779
commit ae2cb23cbf
4 changed files with 40 additions and 5 deletions

View file

@ -281,6 +281,28 @@ public class ModPatchThread extends Thread {
}
}
}
else if ( fileName.endsWith( ".xml.rawclobber" ) || fileName.endsWith( ".rawclobber.xml" ) ) {
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
log.warn( String.format( "Copying xml as raw text: %s", innerPath ) );
// Normalize line endings to CR-LF.
// decodeText() reads anything and returns an LF string.
String fixedText = ModUtilities.decodeText( zis, modFile.getName()+":"+parentPath+fileName ).text;
fixedText = Pattern.compile("\n").matcher( fixedText ).replaceAll( "\r\n" );
InputStream fixedStream = ModUtilities.encodeText( fixedText, "windows-1252", modFile.getName()+":"+parentPath+fileName+" (with new EOL)" );
if ( !moddedItems.contains(innerPath) ) {
moddedItems.add( innerPath );
} else {
log.warn( String.format( "Clobbering earlier mods: %s", innerPath ) );
}
if ( ftlP.contains( innerPath ) )
ftlP.remove( innerPath );
ftlP.add( innerPath, fixedStream );
}
else if ( fileName.endsWith( ".xml" ) ) {
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );

View file

@ -457,11 +457,18 @@ public class ModUtilities {
modValid = false;
}
}
else if ( innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml|[.]xml[.]rawappend|[.]rawappend[.]xml|[.]xml|[.]txt)$" ) ) {
else if ( innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml)$" ) ||
innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ||
innerPath.matches( "^.*(?:[.]xml[.]rawclobber|[.]rawclobber[.]xml)$" ) ||
innerPath.matches( "^.*(?:[.]xml|[.]txt)$" ) ) {
boolean isTxt = innerPath.matches( "^.*(?:[.]txt)$" );
boolean isXML = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml|[.]xml)$" );
boolean isXMLAppend = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml)$" );
if ( innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ) {
if ( innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ||
innerPath.matches( "^.*(?:[.]xml[.]rawclobber|[.]rawclobber[.]xml)$" ) ) {
isXML = false; // Raw xml is exempt from normal processing.
}