Works out the folder where JBake is running from.

@return File referencing folder JBake is running from
@throws Exception when application is not able to work out where is JBake running from
427864
public static File getRunningLocation() throws Exception {
        String codePath = FileUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath();
        String decodedPath = URLDecoder.decode(codePath, "UTF-8");
        File codeFile = new File(decodedPath);
        if (!codeFile.exists()) {
            throw new Exception("Cannot locate running location of JBake!");
        }
        File codeFolder = codeFile.getParentFile().getParentFile();
        if (!codeFolder.exists()) {
            throw new Exception("Cannot locate running location of JBake!");
        }

        return codeFolder;
    }
247921
public File getParentDirectory() {
        if (this.parentDirectory == null) {
            // the conventions are:
            // 1. jar in the function's method folder or
            // 2. in the function method's parent folder where all the method directories are children

            if (isJarInMethodFolder()) { 
                this.parentDirectory = getJarDirectory().getAbsoluteFile().getParentFile(); //up one level
            }
            this.parentDirectory = this.jarDirectory.getAbsoluteFile(); // otherwise convention #2
        }
        return this.parentDirectory;
    }
733697
public static String getCategoryPath(String rootPath, String baseFolder) throws Exception {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new Exception("Invalid category location \"" + rootPath + "\".");
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
1373544
def get_jvm_path(self):
        
        for method in self._methods:
            try:
                jvm = method()

                # If found check the architecture 
                if jvm:
                    self.check(jvm)
            except NotImplementedError:
                # Ignore missing implementations
                pass
            except JVMNotFoundException:
                # Ignore not successful methods
                pass
            except JVMNotSupportedException:
                pass

            else:
                if jvm is not None:
                    return jvm

        else:
            raise JVMNotFoundException("No JVM shared library file ({0}) "
                                       "found. Try setting up the JAVA_HOME "
                                       "environment variable properly."
                                       .format(self._libfile))
223761
private static String getExtractDirectory() {
        createExtractor();
        String containerPath = extractor.container.getName();
        File containerFile = new File(containerPath);
        if (containerFile.isDirectory()) {
            extractor.allowNonEmptyInstallDirectory(true);
            return containerFile.getAbsolutePath();
        }
        // check if user specified explicit directory
        String extractDirVar = System.getenv("WLP_JAR_EXTRACT_DIR");

        // if so, return it and done
        if (extractDirVar != null && extractDirVar.length() > 0) {
            String retVal = createIfNeeded(extractDirVar.trim());
            return retVal;
        } else {

            String extractDirVarRoot = System.getenv("WLP_JAR_EXTRACT_ROOT");
            if (extractDirVarRoot == null || extractDirVarRoot.length() == 0) {
                extractDirVarRoot = getUserHome() + File.separator + "wlpExtract";
            }
            createIfNeeded(extractDirVarRoot);

            try {
                String basedir = (new File(extractDirVarRoot)).getAbsolutePath();
                return createTempDirectory(basedir, jarFileName() + "_");
            } catch (Exception e) {
                throw new RuntimeException("Could not create temp directory under: " + extractDirVarRoot);
            }
        }
    }
245205
public File output() throws IOException {
        File o = new File(output);
        if (!o.exists() && !o.mkdirs()) {
            throw new IOException("Unable to create output folder '" + output + "'");
        }
        return o;
    }
711542
private File getNextTempDirectory() throws AnalysisException {
        File directory;

        // getting an exception for some directories not being able to be
        // created; might be because the directory already exists?
        do {
            final int dirCount = DIR_COUNT.incrementAndGet();
            directory = new File(tempFileLocation, String.valueOf(dirCount));
        } while (directory.exists());
        if (!directory.mkdirs()) {
            throw new AnalysisException(String.format(
                    "Unable to create temp directory '%s'.",
                    directory.getAbsolutePath()));
        }
        return directory;
    }
1181202
private static File getCodeSourceArchive() {
        try {
            CodeSource codeSource = DocumentRootHelper.class.getProtectionDomain().getCodeSource();
            URL location = (codeSource == null ? null : codeSource.getLocation());
            if (location == null) {
                return null;
            }
            String path = location.getPath();
            URLConnection connection = location.openConnection();
            if (connection instanceof JarURLConnection) {
                path = ((JarURLConnection) connection).getJarFile().getName();
            }
            if (path.indexOf("!/") != -1) {
                path = path.substring(0, path.indexOf("!/"));
            }
            return new File(path);
        } catch (IOException ex) {
            return null;
        }
    }
660495
public JCRPath getLocation() throws RepositoryException
   {
      if (this.location == null)
      {
         this.location = session.getLocationFactory().createJCRPath(qpath);
      }

      return this.location;
   }
328748
public function getRealPath()
	{
		$path	= realpath( $this->folderName );
		if( FALSE === $path )
			throw new RuntimeException( 'Folder "'.$this->folderName.'" is not existing and therefore has no Path' );
		return dirname( $path )."/";
	}
1154639
protected Node getFolderNode()
        throws EFapsException, RepositoryException
    {
        Node ret = getSession().getRootNode();
        if (getProperties().containsKey(JCRStoreResource.PROPERTY_BASEFOLDER)) {
            if (ret.hasNode(getProperties().get(JCRStoreResource.PROPERTY_BASEFOLDER))) {
                ret = ret.getNode(getProperties().get(JCRStoreResource.PROPERTY_BASEFOLDER));
            } else {
                ret = ret.addNode(getProperties().get(JCRStoreResource.PROPERTY_BASEFOLDER), NodeType.NT_FOLDER);
            }
        }
        final String subFolder = new DateTime().toString("yyyy-MM");
        if (ret.hasNode(subFolder)) {
            ret = ret.getNode(subFolder);
        } else {
            ret = ret.addNode(subFolder, NodeType.NT_FOLDER);
        }
        return ret;
    }
131807
public String getClassPath()
  {
    String rawClassPath = buildClassPath();

    if (true)
      return rawClassPath;

    char sep = CauchoUtil.getPathSeparatorChar();
    String []splitClassPath = rawClassPath.split("[" + sep + "]");

    String javaHome = System.getProperty("java.home");

    PathImpl pwd = VfsOld.lookup(System.getProperty("user.dir"));

    ArrayList<String> cleanClassPath = new ArrayList<String>();
    StringBuilder sb = new StringBuilder();

    for (String pathName : splitClassPath) {
      PathImpl path = pwd.lookup(pathName);
      pathName = path.getNativePath();

      if (! pathName.startsWith(javaHome)
          && ! cleanClassPath.contains(pathName)) {
        cleanClassPath.add(pathName);
        if (sb.length() > 0)
          sb.append(sep);
        sb.append(pathName);
      }
    }

    return sb.toString();
  }
225879
public List<File> processFiles() throws Exception {
        List<File> changed = new ArrayList<>();
        for (File child : files) {
            File file = processFile(child);
            if (file != null) {
                changed.add(file);
            }
        }
        return changed;
    }
224947
protected File getCorrectOutputDirectory(MavenProject current) {
        final Object obj = current.getContextValue("dependency-check-output-dir");
        if (obj != null && obj instanceof File) {
            return (File) obj;
        }//else we guess
        File target = new File(current.getBuild().getDirectory());
        if (target.getParentFile() != null && "target".equals(target.getParentFile().getName())) {
            target = target.getParentFile();
        }
        return target;
    }
44245
protected String getDirectory() {
        //get the default filepath of the permanet storage file
        String directory = storageConfiguration.getDirectory();

        if(directory == null || directory.isEmpty()) {
            directory = System.getProperty("java.io.tmpdir"); //write them to the tmp directory
        }

        return directory;
    }
697007
String getDocumentationDir() {
        String baseDir = project.getBuild().getDirectory();
        if (baseDir == null || new File(baseDir).exists()) {
            baseDir = project.getBasedir().getAbsolutePath();
            baseDir = baseDir + "/target";
            if (!new File(baseDir).exists()) {
                //maven plugin declared in child module
                baseDir = project.getBasedir().getAbsolutePath();
            }
        }
        if (!baseDir.endsWith("/")) {
            baseDir = baseDir + "/";
        }

        if (outputDir == null) {
            outputDir = "cukedoctor/";
        }

        if (!outputDir.endsWith("/")) {
            outputDir = outputDir + "/";
        }

        return baseDir + outputDir;

    }
998046
public void ls() throws Exception {

        String folder = CmsResource.getFolderPath(m_cms.getRequestContext().getUri());
        List<CmsResource> resources = m_cms.getResourcesInFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION);
        m_shell.getOut().println(
            "\n" + getMessages().key(Messages.GUI_SHELL_LS_2, folder, new Integer(resources.size())));
        Iterator<CmsResource> i = resources.iterator();
        while (i.hasNext()) {
            CmsResource r = i.next();
            m_shell.getOut().println(m_cms.getSitePath(r));
        }
        m_shell.getOut().println();
    }