/* * [PrepareRollcall.java] * * Summary: Compose Rollcall.btm. * * Copyright: (c) 2013-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2013-04-03 initial version * 1.1 2014-07-25 mark the rollcall.btm file as generated. */ package com.mindprod.repair; import com.mindprod.common18.BigDate; import com.mindprod.common18.Misc; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.macro.Global; import com.mindprod.htmlmacros.support.ConfigurationForMindprod; import com.mindprod.htmlmacros.support.QuoteFlock; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import static java.lang.System.*; /** * Compose Rollcall.btm. * * @author Roedy Green, Canadian Mind Products * @version 1.1 2014-07-25 mark the rollcall.btm file as generated. * @since 2013-04-03 */ public class PrepareRollcall { static final String[] EMBS = { "acronyms.csv", "embellishment.csv", "obsoleterfcs.csv", "spellings.csv" }; /** * year first released */ private static final int FIRST_COPYRIGHT_YEAR = 2013; /** * undisplayed copyright notice. * * @noinspection UnusedDeclaration */ private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2013-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; /** * date this version released. * * @noinspection UnusedDeclaration */ private static final String RELEASE_DATE = "2014-07-25"; /** * how to use the program */ private static final String USAGE = "\nPrepareRollcall needs no parms"; /** * embedded version string. * * @noinspection UnusedDeclaration */ private static final String VERSION_STRING = "1.1"; private static String postlude() { return "rem -30-\n"; } private static String prelude() { return "@echo off\n" + "rem rollcall.btm make sure crucial files are present and big enough.\n" + "rem This script was generated on " + BigDate.localToday().toString() + " by E:\\env\\preparerollcall.btm com.mindprod.repair.PrepareRollcall D o N o t E d i t .\n" + "Rem protects against accidentally tossing quotations or two bat files conflicting.\n" + "Rem There are three mechanisms to guard against Tidy screwing up the quotation files.\n" + "Rem 1. rollcall file exist\n" + "rem 2. rollcall file minimum size\n" + "rem 3. HTMLMacros QuoteFlock has a minimum number of quotations, configured per file stored in quotes\\flocks.csv.\n" + "E:\n" + "cd \\mindprod\\quote\n"; } /** * generate Rollcall.btm * * @param args dirs and files to process */ public static void main( final String[] args ) { // need configuration for flock. Global.installConfiguration( new ConfigurationForMindprod() ); QuoteFlock.fireup(); // must StripGenerated quote dir first // must condense.btm the embellishment dir first final FastCat sb = new FastCat( QuoteFlock.values().length * 14 + EMBS.length * 13 + 5 ); sb.append( prelude() ); for ( QuoteFlock f : QuoteFlock.values() ) { final File file = f.getFile(); final String quoteFlock = file.getName(); final long fileSize = file.length(); sb.append( "IF NOT EXIST ", quoteFlock, " PAUSE \"rollcall.btm: missing quote ", quoteFlock, "\"\n" ); sb.append( "set shrunk=%[", fileSize, " - %@filesize[", quoteFlock, "]]\n" ); sb.append( "IF %shrunk gt 25 PAUSE \"rollcall.btm: quote ", quoteFlock, " shrunk by %shrunk bytes\"\n" ); } final File embDir = new File( "E:/mindprod/embellishment" ); sb.append( "E:\\\n" ); sb.append( "CD E:\\mindprod\\embellishment\n" ); for ( String embName : EMBS ) { final File file = new File( embDir, embName ); final long fileSize = file.length(); sb.append( "IF NOT EXIST ", embName, " PAUSE \"rollcall.btm: missing embellishment ", embName, "\"\n" ); sb.append( "set shrunk=%[", fileSize, " - %@filesize[", embName, "]]\n" ); sb.append( "IF %shrunk gt 25 PAUSE \"rollcall.btm: embellishment ", embName, " shrunk by %shrunk bytes\"\n" ); } final File quoteDir = new File( "E:/mindprod/quote" ); sb.append( "E:\\\n" ); sb.append( "CD E:\\mindprod\\quote\n" ); final String fname = "flocks.csv"; final File file = new File( quoteDir, fname ); final long fileSize = file.length(); sb.append( "IF NOT EXIST ", fname, " PAUSE \"rollcall.btm: missing quote file ", fname, "\"\n" ); sb.append( "set shrunk=%[", fileSize, " - %@filesize[", fname, "]]\n" ); sb.append( "IF %shrunk gt 25 PAUSE \"rollcall.btm: quote ", fname, " shrunk by %shrunk bytes\"\n" ); sb.append( postlude() ); try { HunkIO.writeEntireFile( new File( "E:/env/rollcall.btm" ), sb.toString(), HunkIO.IBM437 ); } catch ( IOException e ) { err.println( e.getMessage() ); } Misc.trackLastThread(); System.exit( 0 ); } }