1 package net.sf.tomp.xtcl.command;
2
3 import java.io.File;
4
5 import net.sf.tomp.xtcl.Context;
6
7 /***
8 * Abstract ancestor of File-related, i.e. Cd, Fil, Load, Save commands.
9 *
10 * @author tomp
11 */
12 public abstract class FileCommand extends VarCommand {
13
14 /*** filename */
15 protected String fileName;
16
17 /***
18 * sets filename
19 *
20 * @param fN filename
21 */
22 public void setFile(String fN) {
23 fileName = fN;
24 }
25
26 public static File getFile(Context context, String fileNameOrRef) {
27 File f = null;
28
29 if (fileNameOrRef.startsWith("$")) {
30 f = context.refToFile(fileNameOrRef);
31 } else {
32 f = context.getFile(fileNameOrRef);
33 }
34 return f;
35 }
36 }
37
38 /*
39 * The contents of this file are subject to the Mozilla Public License Version
40 * 1.1 (the "License"); you may not use this file except in compliance with the
41 * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
42 * Software distributed under the License is distributed on an "AS IS" basis,
43 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
44 * the specific language governing rights and limitations under the License. The
45 * Original Code is: all this file. The Initial Developer of the Original Code
46 * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
47 */