|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.vcs.profiles.cvsprofiles.commands; import java.io.*; import java.util.Hashtable; import org.netbeans.lib.cvsclient.CVSRoot; import org.netbeans.modules.vcscore.commands.*; import org.netbeans.modules.vcscore.cmdline.VcsAdditionalCommand; /** * * @author Richard Gregor */ public class CvsAutoFillGlobalConfig extends Object implements VcsAdditionalCommand { private static final String CVS_DIR = "CVS"; // NOI18N private static final String CVS_ROOT = "Root"; // NOI18N private static final String ROOT_DIR = "ROOTDIR"; // NOI18N private static final String CVS_LOCAL = "local"; // NOI18N private static final String CVS_EXT = "ext"; // NOI18N /** * Creates new CvsAutoFillGlobalConfig */ public CvsAutoFillGlobalConfig() { } private static File lookForCVSRoot(String dirName) { File cvsRoot = new File(dirName, CVS_DIR + File.separator + CVS_ROOT); if (!cvsRoot.exists()) { String cvsRootName = CVS_DIR + File.separator + CVS_ROOT; File[] subfiles = new File(dirName).listFiles(); if (subfiles != null) { for (int i = 0; i < subfiles.length; i++) { if (subfiles[i].isDirectory()) { File test = new File(subfiles[i], cvsRootName); if (test.exists()) { cvsRoot = test; break; } } } } } return cvsRoot; } public boolean exec(Hashtable vars, String[] args, CommandOutputListener stdoutNRListener, CommandOutputListener stderrNRListener, CommandDataOutputListener stdoutListener, String dataRegex, CommandDataOutputListener stderrListener, String errorRegex) { String dirName = (String) vars.get(ROOT_DIR); if((dirName == null)|| (dirName.length() ==0)) return false; File dirFile = lookForCVSRoot(dirName); if (!dirFile.exists()) dirFile = lookForCVSRoot(dirName); CVSRoot cvsroot = null; String serverType = null; if (dirFile.exists()) { BufferedReader buff = null; try { buff = new BufferedReader(new InputStreamReader(new FileInputStream(dirFile.getAbsolutePath()))); String line = buff.readLine(); try { cvsroot = CVSRoot.parse(line); serverType = cvsroot.getMethod(); if (serverType == null) { if (cvsroot.isLocal()) { serverType = CVS_LOCAL; } else { serverType = CVS_EXT; } } } catch (IllegalArgumentException iaex) { //ignore } } catch (IOException exc) { } finally { if (buff != null) { try { buff.close(); } catch (IOException eIO) { //ignore } } } } if(cvsroot != null) vars.put("CVS_ROOT",cvsroot.toString()); if((serverType != null)&&(serverType.equals(CVS_LOCAL))){ vars.put("BUILT-IN", ""); } return true; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.