1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | package Torello.Java; import java.io.*; import java.util.*; import java.util.regex.*; import java.util.concurrent.CompletionException; import java.util.function.Consumer; import Torello.Java.*; import Torello.HTML.*; import Torello.HTML.NodeSearch.*; import Torello.Java.Additional.*; /** * A great tool for invoking commands to an MS-DOS operating-system. * * <EMBED ClASS='external-html' DATA-FILE-ID=MSDOS> * <EMBED ClASS='external-html' DATA-FILE-ID=OSC_WORA> * <EMBED CLASS='external-html' DATA-FILE-ID=OSC_WILD_CARD_02> * <EMBED CLASS='external-html' DATA-CLASS=MSDOS DATA-VAR=dos DATA-FILE-ID=OSC_ALL_FIELDS> * <EMBED CLASS='external-html' DATA-FILE-ID=APPENDABLE> * * @see OSCommands * @see OSResponse */ @Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="OSC_INHERITORS") public class MSDOS extends OSCommands implements Cloneable { // ******************************************************************************************** // ******************************************************************************************** // Constructors // ******************************************************************************************** // ******************************************************************************************** /** <EMBED CLASS='external-html' DATA-FILE-ID=OSC_CTOR_1> */ public MSDOS() { super(); } /** * <EMBED CLASS='external-html' DATA-FILE-ID=OSC_CTOR_2> * @param outputAppendable <EMBED CLASS='external-html' DATA-FILE-ID=OSC_APPENDABLE_PARAM> * @see OSCommands#outputAppendable */ public MSDOS(Appendable outputAppendable) { super(outputAppendable); } /** * <EMBED CLASS='external-html' DATA-FILE-ID=OSC_CTOR_3> * * @param outputAppendable <EMBED CLASS='external-html' DATA-FILE-ID=OSC_APPENDABLE_PARAM> * @param commandStrAppendable <EMBED CLASS='external-html' DATA-FILE-ID=OSC_CSA_PARAM> * @param standardOutput <EMBED CLASS='external-html' DATA-FILE-ID=OSC_STND_OUT_PARAM> * @param errorOutput <EMBED CLASS='external-html' DATA-FILE-ID=OSC_ERROR_OUT_PARAM> * @see OSCommands#outputAppendable * @see OSCommands#commandStrAppendable * @see OSCommands#standardOutput * @see OSCommands#errorOutput */ public MSDOS( Appendable outputAppendable, Appendable commandStrAppendable, Appendable standardOutput, Appendable errorOutput ) { super(outputAppendable, commandStrAppendable, standardOutput, errorOutput); } /** * <EMBED CLASS='external-html' DATA-FILE-ID=OSC_CTOR_4> * * @param standardOutput <EMBED CLASS='external-html' DATA-FILE-ID=OSC_STND_OUT_PARAM> * @param errorOutput <EMBED CLASS='external-html' DATA-FILE-ID=OSC_ERROR_OUT_PARAM> * @see OSCommands#standardOutput * @see OSCommands#errorOutput */ public MSDOS(Appendable standardOutput, Appendable errorOutput) { super(standardOutput, errorOutput); } /** * Used by the method {@code clone()}. * @param other Another instance of this class. */ protected MSDOS(MSDOS other) { super(other); } /** {@inheritDoc} */ public MSDOS clone() { return new MSDOS(this); } // ******************************************************************************************** // ******************************************************************************************** // Commands // ******************************************************************************************** // ******************************************************************************************** /** * MS-DOS Command: {@code COPY} * * <DIV CLASS="SHELL">{@code * C:\>COPY <src> <target> * }</DIV> * * @param src MS-DOS {@code 'COPY'} command's "source" argument * @param target The {@code 'COPY'} command's "target" argument * @return <EMBED CLASS='external-html' DATA-FILE-ID=OSRET> * @see OSCommands#printAndRun(String[]) * @throws IOException If there are problems while invoking the operating-system command */ public OSResponse COPY(String src, String target) throws IOException { String[] command = { "COPY", src, target }; return printAndRun(command); } /** * MS-DOS Command: {@code COPY} * * <DIV CLASS="SHELL">{@code * C:\>COPY <src.elementAt(0)> <src.elementAt(1)> ... <src.elementAt(src.size()-1)> <target> * }</DIV> * * @param src This may be a list of files to be copied to a target directory * @param target This is the target directory for the files listed. * @return <EMBED CLASS='external-html' DATA-FILE-ID=OSRET> * @see OSCommands#printAndRun(String[]) * @throws IOException If there are problems while invoking the operating-system command */ public OSResponse COPY(Vector<String> src, String target) throws IOException { String[] command = new String[src.size() + 2]; command[0] = "COPY"; command[src.size() + 1] = target; for (int i=0; i < src.size(); i++) command[1 + i] = src.elementAt(i); return printAndRun(command); } /** * MS-DOS Command: {@code COPY} * * <DIV CLASS="SHELL">{@code * C:\>COPY <src[0]> <src[1]> ... <src[src.length-1]> <target> * }</DIV> * * @param src This may be a list of files to be copied to a target directory * @param target This is the target directory for the files listed. * @return <EMBED CLASS='external-html' DATA-FILE-ID=OSRET> * @see OSCommands#printAndRun(String[]) * @throws IOException If there are problems while invoking the operating-system command */ public OSResponse COPY(String[] src, String target) throws IOException { String[] command = new String[src.length + 2]; command[0] = "COPY"; command[src.length + 1] = target; for (int i=0; i < src.length; i++) command[1 + i] = src[i]; return printAndRun(command); } /** * MS-DOS Command: {@code DEL} * * <DIV CLASS="SHELL">{@code * C:\>DEL <s1> * }</DIV> * * @param s1 The item to be removed, using an MS-DOS command. * @return <EMBED CLASS='external-html' DATA-FILE-ID=OSRET> * @see OSCommands#printAndRun(String[]) * @throws IOException If there are problems while invoking the operating-system command */ public OSResponse DEL(String s1) throws IOException { String[] command = { "DEL", s1 }; return printAndRun(command); } /** * MS-DOS Command: {@code DEL} * * <DIV CLASS="SHELL">{@code * C:\>DEL <sArr[0]> <sArr[1]> ... <sArr[sArr.length-1]> * }</DIV> * * @param sArr An {@code String[] array} which is added to the end of this MS-DOS command. * These will be the item(s) removed by the {@code 'DEL'} command. * * @return <EMBED CLASS='external-html' DATA-FILE-ID=OSRET> * @see OSCommands#printAndRun(String[]) * @throws IOException If there are problems while invoking the operating-system command */ public OSResponse DEL(String[] sArr) throws IOException { String[] command = new String[sArr.length + 1]; command[0] = "DEL"; for (int i=0; i < sArr.length; i++) command[i + 1] = sArr[i]; return printAndRun(command); } } |