package com.sun.solarisinstall.panels;

/*
 *
 * SolarisProduct -- replaces the old SolarisProduct and CFGFiles classes
 * Largely copied from WebStart's Product.java
 *
 */

import java.lang.Object;
import java.lang.*;
import java.io.*;
import java.util.*;
import com.sun.wizards.core.*;

public class SolarisProduct implements Serializable, Cloneable, Sortable {

	public String file;
	public String cluster;
	public boolean orig;
	public String path;
	public int isabits;

	private String name, cdname, version, imagedir;
	private String prodID, compID;
	private String depend, script, input, helpurl;
	private boolean miniroot=false;
	private boolean reboot, pkgadd;
	private int imagesize;
	private boolean installedbydefault;
	private int[] fs;
        private int total;
	private String def_lang = null;
	private String help_path = null;
	private String[] rlocales, slocales, pkgs;
	private String[] packages, patches, scripts, installtags, proddir;
	private boolean issetisa = false;

// Save space in serialization output file by making these transient -- 
// not needed by backend
	private transient Vector locales_req = new Vector();
	private transient Vector locales_sup = new Vector();
	private transient Vector pkgs_vec = new Vector();
	private transient Vector packages_vec = new Vector();
	private transient Vector patches_vec = new Vector();
	private transient Vector scripts_vec = new Vector();
	private transient Vector proddir_vec = new Vector();
	private transient Vector installtags_vec = new Vector();
	private transient String pathfile, arch;
	private transient boolean initialized = false;
	private transient boolean incopy = false;
	private transient Vector crls;
        private transient Object customData = null;

	public SolarisProduct(String filename, String ar, Vector vl, String defloc) 
	{
		super();
		String[] locales = new String[vl.size()];
		vl.copyInto(locales);
		initialize (filename, false, ar, locales, defloc);
	}

	public SolarisProduct (String filename, boolean deflt, String ar, Vector vl, 
		String defloc)
	{
		super();
		String[] locales = new String[vl.size()];
		vl.copyInto(locales);
		initialize (filename, deflt, ar, locales, defloc);
	}

	public SolarisProduct(String filename, String ar, String[] locales, String defloc) 
	{
		super();
		initialize (filename, false, ar, locales, defloc);
	}

	public SolarisProduct(String filename, boolean deflt, String ar, String[] locales,
		 String defloc)
	{ 
	    	super();
		initialize(filename, deflt, ar, locales,defloc);
	}

	private void initialize(String filename, boolean deflt, String ar, 
		String[] locales, String defloc)
	{
                if (Def.DEBUG)
                   System.out.println("SolarisProduct: Initialize product info " + filename);
		file = filename.substring(filename.lastIndexOf("/")+1);
		path = filename.substring(0,filename.lastIndexOf("/"));

                /*
                 * Initialize Isabits
                 */
		if (!(issetisa)) {
			String arch;
    			try {
      				FileAgent fc = new FileAgent();
      				fc.readOpen(ProfileConstants.installDir+"/uname.out");
      				arch = fc.readLine();
      				arch = arch.trim();
      				fc.close();
      				fc = null;
    			} catch (FileAgentException ex) {
      				System.err.println(ex);
      				arch = "sun4u";           //Assume sun4u
    			}
			
			//System.out.println("Initializing isabits");
			if ( arch.startsWith("sun4u")) 
				setIsabits(64);
			else 
				setIsabits(32);
   		}
	 	orig = deflt;
		installedbydefault = deflt;
		pathfile = filename;
		arch = ar;
		createConf(locales);

		locales_sup = (Vector)locales_req.clone();
		
		Vector l = new Vector();
		for (int i = 0; i < locales_sup.size(); i++) {
			if (!(((String)locales_sup.elementAt(i)).startsWith("C")))
				l.addElement(locales_sup.elementAt(i));
		}
		slocales = new String[l.size()];
		l.copyInto(slocales);

		proddir = new String[proddir_vec.size()];
		proddir_vec.copyInto(proddir);

		sethelp(defloc);

		if (orig == true)
			writeCfg();
		initialized = true;
	}

        public boolean isInstalledByDefault() {
                return installedbydefault; }

        public boolean getState() {
                return orig; }

	public void setState(boolean state) {
		orig = state; 
	        if (state == true)
		    add();
	   	else
		    remove();
	}

	public void add() {
		orig = true; 
                if (file.startsWith(ProfileConstants.osFilePrefix)) { 
		    if (cluster != null) {
	  	    	Profile profile = ProfileUtil.getProfile();
	  	    	profile.setCluster(cluster);
		    }
                } else 
		    writeCfg(); 
        }

	public void remove() {
		orig = false; 
                if (!file.startsWith(ProfileConstants.osFilePrefix)) 
			truncateCfg(); 
	}

        public void setInstalledByDefault(boolean value) {
		installedbydefault = value; 
	}

	public int getFSsize (int i) {
		return fs[i]; }
		
	public int[] getsize () {
		return fs; }
		
	public String getHelpURL() {
		return helpurl; }

	public String getImageDir() {
		return imagedir; }
	
	public int getImageSize() {
		return imagesize; }
	
	public String getCDname() {
		return cdname; }

	public String getProdID() {
		return prodID; }

	public String getCompID() {
		return compID; }

	public String getVersion() {
		return version; }

	public String getName() {
		return name; }

	public int getIsabits() {
		return isabits; }

	public String getMouseOverHelpFile() {
		return help_path; }

	public String[] getProddir() {
		return proddir; }

        public Vector getProddir_v() {
               Vector v = new Vector();
               for (int i = 0; i < proddir.length; i++)
                       v.addElement(proddir[i]);
                return v; }

	public String[] getPkgs() {
		return pkgs; }

        public Vector getPkgs_v() {
               Vector v = new Vector();
               for (int i = 0; i < pkgs.length; i++)
                       v.addElement(pkgs[i]);
               return v; }

	public String[] getPackages() {
		return packages; }

        public Vector getPackages_v() {
               Vector v = new Vector();
               for (int i = 0; i < packages.length; i++)
                       v.addElement(packages[i]);
               return v; }

	public String[] getPatches() {
		return patches; }

        public Vector getPatches_v() {
               Vector v = new Vector();
               for (int i = 0; i < patches.length; i++)
                       v.addElement(patches[i]);
               return v; }

	public String[] getScripts() {
		return scripts; }

        public Vector getScripts_v() {
               Vector v = new Vector();
               for (int i = 0; i < scripts.length; i++)
                       v.addElement(scripts[i]);
               return v; }

	public String[] getInstallTags() {
		return installtags; }

        public Vector getInstallTags_v() {
               Vector v = new Vector();
               for (int i = 0; i < installtags.length; i++)
                       v.addElement(installtags[i]);
               return v; }

	public String[] getSuppLocales() {
		return slocales; }

        public Vector getSuppLocales_v() {
                Vector v = new Vector();
                for (int i = 0; i < slocales.length; i++)
                        v.addElement(slocales[i]);
               return v; }

	public String[] getReqLocales() {
		return rlocales; }

        public Vector getReqLocales_v() {
               Vector v = new Vector();
               for (int i = 0; i < rlocales.length; i++)
                      v.addElement(rlocales[i]);
              return v; }

	public void setLocales(String[] locales) {
		createConf(locales);
		if (orig == true)
			writeCfg();} 

        public void setLocales(Vector vl) {
               String[] locales = new String[vl.size()];
               vl.copyInto(locales);
               createConf(locales);
		if (orig == true)
              		writeCfg(); }

	public boolean addLocale(String locale) {
		if (locales_sup.indexOf(locale) == -1 || 
				locales_req.indexOf(locale) != -1)
		    return false;
		else {
		    locales_req.addElement(locale);
	    	    String[] nlocs = new String[locales_req.size()];
	    	    locales_req.copyInto(nlocs);
		    createConf(nlocs);
		    if (orig == true)
		    	writeCfg();
		    return true;
		}

	}

	public void setIsabits(int ibits) {
		isabits = ibits;
		issetisa = true;
		if (orig = true)
			writeCfg();
	}
	public boolean isSetIsa() {
		return issetisa;
	}
		
	public boolean removeLocale(String locale) {
		if (locales_req.indexOf(locale) == -1 || locale.equals("C"))
		    return false;
		else {
		    locales_req.removeElement(locale);
	    	    String[] nlocs = new String[locales_req.size()];
	    	    locales_req.copyInto(nlocs);
		    createConf(nlocs);
		    if (orig == true)
		    	writeCfg();
		    return true;
		}
	}

	public boolean isARequestedLocale(String locale) {
               for (int i = 0; i < rlocales.length; i++) {
		   if (locale.equals(rlocales[i])) {
		       return (true);
		   }
               }

	       return (false);
        }

	public boolean usePkgadd() {
		return pkgadd; }
	
	public String getFilename() {
		return file; }

	public String getInstallscript() {
		return script; }

	public String getInput() {
		return input; }

	public boolean reqReboot() {
		return reboot; }

	public boolean isMiniRootInstall() {
		return miniroot; }

	public String getDepend() {
		return depend; }

	public SolarisProduct copy() {
		Object p = null;
		boolean save = incopy;
		incopy = true;
		try {
			p = super.clone();

		} catch (CloneNotSupportedException ex) {
			System.err.println ("SolarisProduct clone exception");
		} finally {
			incopy = save;
			return (SolarisProduct)p;
		}	
	}

        public Object getData() {return customData;}

        public void setData(Object customData) {this.customData = customData;}

  // For Sortable interface
  //
  // This does a comparison by total size.
  //
  public int compareTo(Object o) {
    SolarisProduct other = (SolarisProduct) o;
    
    // Returns >0 if total >, <0 if o.total >, and 0 if ==
    return (total - other.total);
  }


// Read config file 
  private void createConf(String[] locales)
  {
    boolean notdone = true;
    try 
    {
      FileAgent fc;
      fc =  new FileAgent();

      InputStream in = fc.getInputStream(pathfile);
      //StreamTokenizer strm = new StreamTokenizer(new BufferedInputStream(in,512));
      Reader r = new BufferedReader(new InputStreamReader(in));
      StreamTokenizer strm = new StreamTokenizer(r);
	
      strm.commentChar('#');
      strm.ordinaryChar('[');
      strm.ordinaryChar(']');
      strm.ordinaryChar('=');
      strm.wordChars('*','+');
      strm.wordChars('_', '_');
      strm.wordChars('-', '9');
      strm.wordChars('&', '&');
      strm.eolIsSignificant(true);

      locales_req.setSize(0);
      pkgs_vec.setSize(0);
      packages_vec.setSize(0);
      patches_vec.setSize(0);
      scripts_vec.setSize(0);
      installtags_vec.setSize(0);

      fs = new int[SolarisFileSystem.FSname.length];
      for (int i = 0; i < (SolarisFileSystem.FSname.length); i++)
        fs[i] = 0;
      crls = new Vector();

      while (notdone) {
        switch (strm.nextToken()) {
          case strm.TT_EOF:
              fc.closeInputStream(in);
              fc.close();
              notdone = false;
              break;

          case '[':
              while (checkmode(strm,locales,arch) == false) {
                skiptonextmode(strm);
              }
              break;

          case strm.TT_WORD:
              processline(strm);
              break;
          default:
              break;
			
        }
      }
    }
    catch (IOException e) {
      System.err.println (e);
      return;
    }
    rlocales = new String[locales_req.size()];
    locales_req.copyInto(rlocales);
 
    pkgs = new String[pkgs_vec.size()];
    pkgs_vec.copyInto(pkgs);

    packages = new String[packages_vec.size()];
    packages_vec.copyInto(packages);

    installtags = new String[installtags_vec.size()];
    installtags_vec.copyInto(installtags);

    patches = new String[patches_vec.size()];
    patches_vec.copyInto(patches);

    scripts = new String[scripts_vec.size()];
    scripts_vec.copyInto(scripts);

    total = 0;
    for (int i=0; i < fs.length; i++) {
      total += fs[i];
    }

    /*
     * If this is a non-miniroot pd product and the required
     * cluster is core, bump it up to End User
     */
    if (file.startsWith("pd") && (depend != null)) {
      int coreIndex = depend.indexOf("SUNWCreq");
      if ((coreIndex != -1) && (! miniroot)) {
        String core = "SUNWCreq";
        String enduser = "SUNWCuser";
        String newdep = depend.substring(0,coreIndex) + enduser +
                               depend.substring(coreIndex + core.length());
        if (Def.DEBUG) {
           System.out.println("SolarisProduct createConf: " + name + 
                     " set to " + depend + ", setting to " + newdep );
        }
        depend = newdep;
      }
    }
    return;
  }


// Process each line.  Return after reaching EOL.
	private void processline(StreamTokenizer strm) 
	{
	  try {
		if (strm.ttype == strm.TT_EOL) 
			return;
		else if (strm.sval.equals("CD_NAME")) {
		    strm.wordChars(' ',' ');
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				cdname = strm.sval;
		    strm.whitespaceChars(' ',' ');
		}
		else if (strm.sval.equals("CD_VERSION")) {
		    if (strm.nextToken() == '=' && 
					strm.nextToken() == strm.TT_NUMBER) { 
		    	version = String.valueOf(strm.nval);
			}
		}
		else if (strm.sval.equals("PRODNAME")) {
		    strm.wordChars(' ',' ');
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				name = strm.sval;
		    strm.whitespaceChars(' ',' ');
		}
		else if (strm.sval.equals("PRODID")) {
		    strm.wordChars(' ',' ');
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				prodID = strm.sval;
		    strm.whitespaceChars(' ',' ');
		}
		else if (strm.sval.equals("COMPID")) {
		    strm.wordChars(' ',' ');
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				compID = strm.sval;
		    strm.whitespaceChars(' ',' ');
		}
		else if (strm.sval.equals("PRODDIR")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
			while (strm.ttype == strm.TT_WORD && 
					proddir_vec.indexOf(strm.sval) == -1) {
				proddir_vec.addElement(strm.sval);
				strm.nextToken();
			} 
		}
		else if (strm.sval.equals("IMAGEDIR")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD
			&& !initialized) 
				imagedir = strm.sval;
		}
		else if (strm.sval.equals("CLUSTER")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				cluster = strm.sval;
		}
		else if (strm.sval.equals("IMAGESIZE")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_NUMBER
			&& !initialized) {
			Double db = new Double(strm.nval);
			imagesize = db.intValue();
		    }
		}
		else if (strm.sval.equals("REQUIRED")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				depend = strm.sval;
		}
		else if (strm.sval.equals("HELPURL")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				helpurl = strm.sval;
		}
		else if (strm.sval.equals("REBOOT")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
			if (strm.sval.equals ("REQUIRED")) 
				reboot = true;
			else	
				reboot = false;
		}
		else if (strm.sval.equals("PKGS")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) {
			
			while (strm.ttype == strm.TT_WORD && 
					pkgs_vec.indexOf(strm.sval) == -1) {
				pkgs_vec.addElement(strm.sval);
				strm.nextToken();
			} 
		    }
		    if (!crls.isEmpty()) {
			for (int i = 0; i < crls.size(); i++)
			   if (locales_req.indexOf(crls.elementAt(i)) == -1) 
				locales_req.addElement(crls.elementAt(i));
			
		    }
		}
		else if (strm.sval.equals("PACKAGES")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) {
			
			while (strm.ttype == strm.TT_WORD && 
				installtags_vec.indexOf(strm.sval) == -1) {
				packages_vec.addElement(strm.sval);
				installtags_vec.addElement(strm.sval);
				strm.nextToken();
			} 
		    }
		    if (!crls.isEmpty()) {
			for (int i = 0; i < crls.size(); i++)
			   if (locales_req.indexOf(crls.elementAt(i)) == -1) 
				locales_req.addElement(crls.elementAt(i));
			
		    }
		}
		// Added for installation of Co packaged patches.	
		else if (strm.sval.equals("PATCHES")) {
                    //
                    // A patch name typically starts with one or more
                    // numerical characters, and since I cannot find a
                    // way to get StreamTokenizer to treat these as part
                    // of a word token, I am going to read the whole line
                    // (including the '=' prefix) into a String, then use
                    // StringTokenizer to parse it. Ugly, but it gets the
                    // job done.
                    //
		    strm.wordChars('=','=');	// treat = as part of a word
		    strm.wordChars(' ',' ');	// same with space
		    strm.nextToken();
                    String val = "";
                    while (strm.ttype != strm.TT_EOL &&
                        strm.ttype != strm.TT_EOF)
                    {
                        val += strm.sval;
                        strm.nextToken();
                    }
                    //
                    // now that we got the whole line, reset the Tokenizer
                    // flags back to their original settings so that it can
                    // continue to parse the rest of the os table correctly 
                    //
                    strm.ordinaryChar('=');
                    strm.whitespaceChars(' ',' ');
                    //
                    // switch Tokenizer
                    // parse the PATCHES line using StringTokenizer
                    //
                    int equalPos;
                    if (val.length() > 0 &&
                        (equalPos = val.indexOf('=')) >= 0)
                    {
                        // skip the = sign
                        val = val.substring(equalPos + 1);
                        StringTokenizer tok = new StringTokenizer(val);
                        while (tok.hasMoreTokens())
                        {
                            String tokVal = tok.nextToken();
                            if (installtags_vec.indexOf(tokVal) == -1)
                                installtags_vec.addElement(tokVal);
                                patches_vec.addElement(tokVal);
                        } 
                    }
		    if (!crls.isEmpty()) {
			for (int i = 0; i < crls.size(); i++)
			   if (locales_req.indexOf(crls.elementAt(i)) == -1) 
				locales_req.addElement(crls.elementAt(i));
			
		    }
		}
		else if (strm.sval.equals("SCRIPTS")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) {
			
			while (strm.ttype == strm.TT_WORD && 
				installtags_vec.indexOf(strm.sval) == -1) {
				scripts_vec.addElement(strm.sval);	
				installtags_vec.addElement(strm.sval);	
				strm.nextToken();
			} 
		    }
		    if (!crls.isEmpty()) {
			for (int i = 0; i < crls.size(); i++)
			   if (locales_req.indexOf(crls.elementAt(i)) == -1) 
				locales_req.addElement(crls.elementAt(i));
			
		    }
                }
		// Added for installation of Co packaged 64 bit products.	
		else if ((strm.sval.equals("PKGS_64")) && (isabits == 64)) {
                    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) {
                        while (strm.ttype == strm.TT_WORD &&
                                        pkgs_vec.indexOf(strm.sval) == -1) {
                                pkgs_vec.addElement(strm.sval);
                                strm.nextToken();
                        }
                    }
                    if (!crls.isEmpty()) {
                        for (int i = 0; i < crls.size(); i++)
                           if (locales_req.indexOf(crls.elementAt(i)) == -1)
                                locales_req.addElement(crls.elementAt(i));

                    }
                }
		else if (strm.sval.equals("INSTALL_SCRIPT")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				script = strm.sval;
		}
		else if (strm.sval.equals("INPUT")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
				input = strm.sval;
		}
		else if (strm.sval.equals("MINIROOT")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
			if (strm.sval.equals ("YES"))
				miniroot = true;
			else
				miniroot = false;
		}
		else if (strm.sval.equals("PKGADD")) {
		    if (strm.nextToken() == '=' && strm.nextToken() == strm.TT_WORD) 
			if (strm.sval.equals ("YES"))
				pkgadd = true;
			else
				pkgadd = false;
		}
		else {
		    for (int i = 0; i < (SolarisFileSystem.FSname.length); i++) {
		  	if (strm.sval.equals(SolarisFileSystem.FSname[i])) {
		    	    if (strm.nextToken() == '=' && 
					strm.nextToken() == strm.TT_NUMBER) {
				Double db = new Double(strm.nval);
				fs[i] = fs[i] + db.intValue();
		    	    }
		    	break;
		  	}
		    }
		}
		while (strm.ttype != strm.TT_EOL && strm.ttype != strm.TT_EOF)
			strm.nextToken();
		if (strm.ttype == strm.TT_EOF)
			strm.pushBack();
	  }
	  catch (IOException e) {
			return;
	  }
	}

	private boolean checkmode(StreamTokenizer strm, String[] locales, String arch) 
	{
	  boolean a_match = false;
	  boolean loc_match = false;

	  crls.setSize(0);
	  try {
		if( strm.nextToken() == strm.TT_WORD) { 			
		    if (strm.sval.equals (arch)  || strm.sval.equals("*"))
			a_match = true;
		    else 
			return false;
		}
		while (strm.ttype != strm.TT_EOL && strm.ttype != strm.TT_EOF) {
			if (strm.nextToken() != ']' && 
					strm.ttype == strm.TT_WORD) {
				boolean tb = checklocale(strm, locales);
				loc_match = tb || loc_match;
			}
		}
		if (strm.ttype == strm.TT_EOF) {
			strm.pushBack();
			return true;
		}
		return (a_match && loc_match);
	  }
	  catch (IOException e) {
		System.out.println("checkmode exception");
		return false;
	  }
	}

	private boolean checklocale(StreamTokenizer strm, String[] locales) 
	{
	    boolean match = false;
//	    if (strm.sval.equals("C") && locales_req.indexOf("C") == -1){
// Don't return "C" in locale lists
//		locales_req.addElement("C");
//		return true;
//	    }
	    if (!initialized) {
	        if (strm.sval.equals("C") && locales_req.indexOf("C") == -1){
			locales_req.addElement("C");
			return true;
		}
		if (strm.sval.startsWith("C.")) {
	    		for (int i = 0; i < locales.length; i++) {
			    if (strm.sval.substring(2).equals(locales[i]) && 
					locales_req.indexOf(strm.sval) == -1) {
				locales_req.addElement(strm.sval);
				return true;
			    }
			}
		}
	    } else if (strm.sval.equals("C") || (strm.sval.startsWith("C.") && 
			(locales_sup.indexOf(strm.sval) != -1))) 
		return true;
		
	    for (int i = 0; i < locales.length; i++) {
		if (strm.sval.equals(locales[i])) {  
			if (!initialized || 
				locales_sup.indexOf(strm.sval) != -1) {
                	    if (file.startsWith(ProfileConstants.osFilePrefix)) { 
			        if (locales_req.indexOf(strm.sval) == -1) 
				    locales_req.addElement(strm.sval);
			    } else
				    crls.addElement(strm.sval);
			    match = true;
			}
			break;
		}
	   }
	   return match;
	}	

	private void skiptonextmode(StreamTokenizer strm) {
	  try {
		while (true) {
			switch (strm.nextToken()) {
				case '[':
					return;
				case strm.TT_EOF:
					strm.pushBack();
					return;
			}
		}
	  }
	  catch (IOException e) {
		return;
	  }
	}

	private void sethelp(String defloc) {
            String filename = new String();
	    String def_lang = new String();
	    FileAgent f;

            if (file.startsWith(ProfileConstants.pdFilePrefix)) {
	    	filename = file.substring(ProfileConstants.pdFilePrefix.length());
            } else {
		filename = file;
	    }

	    if (defloc != null) {
	        help_path = defloc.concat("/" + filename);

	        try {
	    	    f = new FileAgent();

	    	    if (!(f.doesExist(path + "/help/" + help_path))) { 

                        if (defloc.length() > 1) {
  	    	          def_lang = defloc.substring(0,2);
                        }
	                help_path = def_lang.concat("/" + filename);

	    	        if (!(f.doesExist(path + "/help/" + help_path))) 
			    help_path = "C/" + filename;	
		    }

	    	    f.close();
	        } catch (FileAgentException ex) {
	            System.err.println (ex);
	        }
	    } else {
		help_path = "C/" + filename;	
	    }
	}

	private void writeCfg() {
	    if (incopy == true)
		return;
	    try {

		String ofile = ProfileConstants.installDir + "/" + file;

		FileAgent fc;
	        fc = new FileAgent();

		OutputStream f = fc.getOutputStream(ofile);

		ObjectOutput s = new ObjectOutputStream(f);
		s.writeObject(this);
		s.flush();
		s.close();
		fc.closeOutputStream(f);
		fc.close();
	    }
	    catch (IOException e) {
		System.err.println(e);
	    }

	}

	private void truncateCfg() {
	}
}
