This method will return a bundle entry URL for the supplied path, it will test for both a normal entry and a directory entry for it.

@param pathAndName The path to the entry
@return The URL for the bundle entry
172068
@FFDCIgnore(IllegalStateException.class)
    public URL getBundleEntry(Bundle bundleToTest, String pathAndName) {
        try {
            URL bundleEntry = bundleToTest.getEntry(pathAndName);

            /*
             * Defect 54588 discovered that if a directory does not have a zip entry then calling getEntry will return null unless the path has a "/" on the end so if we have null
             * still then add a "/" on the end of the path and retest
             */
            if (bundleEntry == null) {
                bundleEntry = bundleToTest.getEntry(pathAndName + "/");
            }
            return bundleEntry;
        } catch (IllegalStateException ise) {
            //bundle context was no longer valid, so we cannot use getEntry any more.
            return null;
        }
    }
973124
public String path() {
    if (path == null) {
      if (!hasPath) {
        return path = "";
      }

      int pathEndPos = uri.indexOf('?');
      if (pathEndPos < 0) {
        path = uri;
      } else {
        return path = uri.substring(0, pathEndPos);
      }
    }
    return path;
  }
938116
String getPathName(boolean url) {
        if (pathName == null || pathName.isEmpty()) {
            VirtualFile[] path = getParentFiles();
            final StringBuilder builder = new StringBuilder(path.length * 30 + 50);
            for (int i = path.length - 1; i > -1; i--) {
                final VirtualFile parent = path[i].parent;
                if (parent == null) {
                    builder.append(path[i].name);
                } else {
                    if (parent.parent != null) {
                        builder.append('/');
                    }
                    builder.append(path[i].name);
                }
            }
            pathName = builder.toString();
        }
        // Perhaps this should be cached to avoid the fs stat call?
        return (url && isDirectory()) ? pathName.concat("/") : pathName;
    }
1041943
private static String parseRelativeURL(URL url, String spec) {
        String path = url.getPath();
        String result;

        int index = path.indexOf("!/");
        if (index == -1) {
            // The "jar" protocol requires that the path contain an entry path.
            // For backwards compatibility, we do not.  Instead, we just
            // canonicalize the base URL.
            try {
                url = Utils.newURL(Utils.newURL(path), spec);
            } catch (MalformedURLException ex) {
                throw new RuntimeException(ex);
            }

            result = url.toString();
        } else {
            String entry;

            if (spec.startsWith("/")) {
                // This is an absolute entry path, so we ignore the existing
                // entry path.
                entry = canonicalize(spec);
            } else {
                // Extract the existing entry path.
                entry = path.substring(index + 1);

                if (entry.endsWith("/")) {
                    // The entry ends with '/', so we can directly append the
                    // relative entry path.
                    entry = canonicalize(entry + spec);
                } else if (entry.endsWith("/.")) {
                    // We don't want the logic below because "." is not a
                    // "true" basename.
                    entry = canonicalize(entry + '/' + spec);
                } else {
                    // Strip off the basename with a ".." path segment and
                    // append the relative entry path.
                    entry = canonicalize(entry + "/../" + spec);
                }
            }

            result = path.substring(0, index) + '!' + entry;
        }
        return result;
    }
1142247
@Override
    protected URL findResource(String name) {
        URL result = null;
        // Only check the parent bundle loader if the request is outside of "" or "/"
        if (!!!"".equals(name) && !!!"/".equals(name)) {
            // First try the bundleLoader
            result = bundleLoader.getResource(name);
        }
        // This doesn't have access to ALL split packages (it just gets one) so it's augmented with a resource provider  
        return result == null ? resourceProviders.findResource(name) : result;
    }
473873
public static URL getResourceBundleURL(String resourcePath, ServletContext servletContext) {
		URL resourceUrl = null;
		try {
			resourceUrl = ClassLoaderResourceUtils.getResourceURL(resourcePath, LocaleUtils.class);
		} catch (Exception e) {
			// Nothing to do
		}

		if (resourceUrl == null && servletContext != null && resourcePath.startsWith("grails-app/")) {
			try {
				resourceUrl = servletContext.getResource("/WEB-INF/" + resourcePath);
			} catch (MalformedURLException e) {
				// Nothing to do
			}
		}
		return resourceUrl;
	}
557881
@SuppressWarnings("deprecation")
    @Override
    public File getFile(String path, boolean nativeCode) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " asked to getFile for path " + path);

        path = preSlashify(path);
        if (path.equals("/")) {
            // return a file for "/" .. for normal bundles this would be the jar
            // or directory. For loose, we might have a dir mapped to root, or may not
            // if we do, we'll try using it.
            if (container.getPhysicalPath() != null)
                return new File(container.getPhysicalPath());
            else
                return null;
        }
        final Entry entry = container.getEntry(path);
        if (entry == null) {
            //no entry found for path, bundle has been asked for a file/path that doesn't exist.
            //can happen via bundle-classpath entries for paths that don't exist in the bundle.
            return null;
        }
        Container entryContainer = getContainer(entry);
        if (entryContainer == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, " returning file for entry at " + path + " @ " + entry.getPhysicalPath());

            // this is a 'normal entry' we are going to assume we can get a real file
            // we are allowed to use getPhysicalPath, as this layer has to see through the abstraction for
            // leaf nodes that are files.
            final String physical = entry.getPhysicalPath();
            if (physical != null) {
                return AccessController.doPrivileged(new PrivilegedAction<File>() {
                    @Override
                    public File run() {
                        return new File(physical);
                    }

                });
            }
            // TODO Going to have to extract the content out to a file on disk

            // This would be a case where an entry in a container has no physical path. 
            // If loose config allowed jars to be mapped as directories, this would occur there.

            // Jars mapped as files are already handled by equinox natively, so the lack of 
            // physical paths there will not cause issues.

            // The other common source of imaginary physical paths is intermediate directory 
            // creation..  
            // (eg, mapping /etc/fred.txt as /etc/fish/goat/horse/fred.txt and asking for physical path of 'goat')

            // Current artifact implementations always have a physical path, but this may not remain true 
            // forever, so this case DOES need to be handled, else we'll have some very entertaining 
            // bugs to handle for future deployment types. 
            return null;
        }

        if (nativeCode) {
            // native code is not supported as a container
            return null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " entry was a container.. but was it root? " + entryContainer.isRoot());
        if (!entryContainer.isRoot()) {
            // If the container is not a root then it is 
            // a simple directory in an archive; just return null.
            // The framework will handle nested directories in archives
            return null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " leaf node was a root container, so use marker file for equinox");

        // This is a root container and may be on the bundle classpath.
        // Need to create a temp file to return so we can find this container later when a bundle file is created
        final File tempBase = context.getDataFile("nestedTempFiles");
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " creating a temp dir, request was for " + path + " the nested path");

        // create the temp dir, if needed.. not clear
        if (!AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
            @Override
            public Boolean run() {
                return tempBase.exists() || tempBase.mkdirs();
            }
        })) {
            //no chained exception will mean mkdirs failed.
            throw new IllegalStateException();
        }
        try {
            File t = null;
            try {
                t = AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
                    @Override
                    public File run() throws IOException {
                        return File.createTempFile(entry.getName(), null, tempBase);
                    }
                });
            } catch (PrivilegedActionException e) {
                Exception e2 = e.getException();
                if (e2 instanceof IOException)
                    throw (IOException) e2;
                if (e2 instanceof RuntimeException)
                    throw (RuntimeException) e2;
                throw new UndeclaredThrowableException(e);
            }
            final File tempKey = t;

            // Add it to the nestedFiles map so that the ModuleBundleFileFactory impl can
            // find the container if the framework attempts to create a bundle file from it.
            nestedFiles.put(tempKey, entryContainer);
            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                @Override
                public Object run() {
                    tempKey.deleteOnExit();
                    return null;
                }
            });

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, " returning a tempkey file.. " + tempKey.getAbsolutePath());
            return tempKey;
        } catch (IOException e) {
            //chained exception will mean the temp create failed.
            throw new IllegalStateException(e);
        }
    }
623922
public String getURL(String classAndParams) throws IOException, SQLException {
		String className, params;
		int pos=classAndParams.indexOf('?');
		if(pos==-1) {
			className=classAndParams;
			params=null;
		} else {
			className=classAndParams.substring(0, pos);
			params=classAndParams.substring(pos+1);
		}
		return getURL(className, params);
	}
351557
private static URL[] pathToURLs(String path) {
        java.util.List<URL> urls = new ArrayList<>();
        for (String s: path.split(Pattern.quote(File.pathSeparator))) {
            if (!s.isEmpty()) {
                URL url = fileToURL(Paths.get(s));
                if (url != null) {
                    urls.add(url);
                }
            }
        }
        return urls.toArray(new URL[urls.size()]);
    }
1251836
@Override
  public PathImpl getPath(String pathName)
  {
    if (_pathMap != null) {
      String cleanPathName = pathName;
      
      if (cleanPathName.endsWith("/"))
        cleanPathName = cleanPathName.substring(0, cleanPathName.length() - 1);
      
      JarMap.JarList jarEntryList = _pathMap.get(cleanPathName);

      if (jarEntryList != null) {
        return jarEntryList.getEntry().getJarPath().lookup(pathName);
      }
    }
    else {
      for (int i = 0; i < _jarList.size(); i++) {
        JarEntry jarEntry = _jarList.get(i);
        PathImpl path = jarEntry.getJarPath();

        PathImpl filePath = path.lookup(pathName);

        if (filePath.exists())
          return filePath;
      }
    }

    return null;
  }
197450
public static String getUrlParentDir(String url) {
		try {
			UsableURI uri = UsableURIFactory.getInstance(url);
			String path = uri.getPath();
			if(path.length() > 1) {
				int startIdx = path.length()-1;
				if(path.charAt(path.length()-1) == '/') {
					startIdx--;
				}
				int idx = path.lastIndexOf('/',startIdx);
				if(idx >= 0) {
					uri.setPath(path.substring(0,idx+1));
					uri.setQuery(null);
                    return uri.toUnicodeHostString();
				}
			}
		} catch (URIException e) {
			LOGGER.warning(e.getLocalizedMessage() + ": " + url);
		}
		return null;
	}
798495
public function getPathUrl($repositoryId, $path, $selector = null)
    {
        if ($this->getRootUrl($repositoryId) === null) {
            return null;
        }

        $url = $this->buildUrl($this->getRootUrl($repositoryId));
        $url->getPath()->append($path);

        if (!empty($selector)) {
            $url->getQuery()->modify([Constants::PARAM_SELECTOR => $selector]);
        }

        return $url;
    }
1163718
public static String pathLinker(String path1,String path2){
        if ((path1 == null || path1.equals("")) && (path2 == null || path2.equals(""))){
            return null;
        }

        if (path1 == null || path1.equals("")){
            return path2;
        }

        if (path2 == null || path2.equals("")){
            return path1;
        }

        if (path1.endsWith(File.separator)){
            path1 = path1.substring(0,path1.length() - 1);
        }

        if (path2.startsWith(File.separator)){
            path2 = path2.substring(1,path2.length());
        }

        if (path2.endsWith(File.separator)){
            path2 = path2.substring(0,path2.length() - 1);
        }

        return path1 + File.separator + path2;
    }
1252813
def __get_base_bundle_url(self):
        
        return self.__serviceAccount.get_url() + '/' + \
            self.__serviceAccount.get_instance_id() + self.__BUNDLES_PATH
1164373
private String getStoredBundlePath(String rootDir, String bundleName) {
		if (bundleName.indexOf('/') != -1) {
			bundleName = bundleName.replace('/', File.separatorChar);
		}

		if (!bundleName.startsWith(File.separator)) {
			rootDir += File.separator;
		}

		return rootDir + PathNormalizer.escapeToPhysicalPath(bundleName);
	}
417711
protected function getHeaderFromFile(string $pathAndFilename): string
    {
        $header = '';
        $fileHandle = fopen($pathAndFilename, 'r');
        while ($line = fgets($fileHandle)) {
            if (preg_match('/^#/', $line)) {
                $header .= $line;
            } else {
                break;
            }
        }
        fclose($fileHandle);
        return $header;
    }
729149
public final Iterable<URL> getResourcesURL(String name) {
		URL url = loadResourceURL(name);
		if (subLoaders == null)
			return url != null ? Collections.singletonList(url) : null;
		CompoundCollection<URL> list = new CompoundCollection<>();
		if (url != null) list.addSingleton(url);
		for (AbstractClassLoader sub : subLoaders) {
			Iterable<URL> urls = sub.getResourcesURL(name);
			if (urls != null) list.add(urls);
		}
		return list;
	}