Create a PathFileObject in a file system such as a jar file, such that
the binary name can be inferred from its position within the filesystem.
546591
static PathFileObject createJarPathFileObject(JavacPathFileManager fileManager,
            final Path path) {
        return new PathFileObject(fileManager, path) {
            @Override
            String inferBinaryName(Iterable<? extends Path> paths) {
                return toBinaryName(path);
            }
        };
    }
804113
public Directory createDirectory(JimfsPath path, FileAttribute<?>... attrs) throws IOException {
    return (Directory) createFile(path, store.directoryCreator(), true, attrs);
  }
507967
public static final FileSystem newFileSystem(Path path, Map<String,?> env) throws IOException
    {
        return getDefault().provider().newFileSystem(path, env);
    }
1104568
def file2abspath(filename, this_file=__file__):
    
    return os.path.abspath(
        os.path.join(os.path.dirname(os.path.abspath(this_file)), filename))
470998
public static FileSystem createInstance(
      Configuration config, Path workingDirectory, Collection<FileStatus> fileStatuses) {
    checkNotNull(config, "configuration can not be null");

    FileSystem fileSystem = new InMemoryGlobberFileSystem(workingDirectory, fileStatuses);
    fileSystem.setConf(config);

    return fileSystem;
  }
1238446
function (fileObj) {
            if (typeof fileObj === "string") {
                fileObj = new java.io.File(fileObj);
            }
            return (fileObj.getCanonicalPath() + "").replace(file.backSlashRegExp, "/");
        }
382873
public static File file(String path) {
		if (StrUtil.isBlank(path)) {
			throw new NullPointerException("File path is blank!");
		}
		return new File(getAbsolutePath(path));
	}
574644
public static void create(String zipFilename, String... filenames)
            throws IOException {

        try (FileSystem zipFileSystem = createZipFileSystem(zipFilename, true)) {
            final Path root = zipFileSystem.getPath("/");

            //iterate over the files we need to add
            for (String filename : filenames) {
                final Path src = Paths.get(filename);

                //add a file to the zip file system
                if(!Files.isDirectory(src)){
                    final Path dest = zipFileSystem.getPath(root.toString(),
                            src.toString());
                    final Path parent = dest.getParent();
                    if(Files.notExists(parent)){
                        if(logger.isDebugEnabled()) logger.debug("Creating directory %s", parent);
                        Files.createDirectories(parent);
                    }
                    Files.copy(src, dest, StandardCopyOption.REPLACE_EXISTING);
                }
                else{
                    //for directories, walk the file tree
                    Files.walkFileTree(src, new SimpleFileVisitor<Path>(){
                        @Override
                        public FileVisitResult visitFile(Path file,
                                                         BasicFileAttributes attrs) throws IOException {
                            final Path dest = zipFileSystem.getPath(root.toString(),
                                    file.toString());
                            Files.copy(file, dest, StandardCopyOption.REPLACE_EXISTING);
                            return FileVisitResult.CONTINUE;
                        }

                        @Override
                        public FileVisitResult preVisitDirectory(Path dir,
                                                                 BasicFileAttributes attrs) throws IOException {
                            final Path dirToCreate = zipFileSystem.getPath(root.toString(),
                                    dir.toString());
                            if(Files.notExists(dirToCreate)){
                                if(logger.isDebugEnabled()) logger.debug("Creating directory %s\n", dirToCreate);
                                Files.createDirectories(dirToCreate);
                            }
                            return FileVisitResult.CONTINUE;
                        }
                    });
                }
            }
        }
    }
278919
public static Pair<Descriptor, String> fromFilename(Path directory, String name) {
        // tokenize the filename
        StringTokenizer st = new StringTokenizer(name, String.valueOf(separator));
        String nexttok;

        // all filenames must start with keyspace and column family
        String ksname = st.nextToken();
        String cfname = st.nextToken();

        // optional temporary marker
        nexttok = st.nextToken();
        boolean temporary = false;
        if (nexttok.equals(SSTable.TEMPFILE_MARKER)) {
            temporary = true;
            nexttok = st.nextToken();
        }

        // optional version string
        Version version = Version.LEGACY;
        if (Version.validate(nexttok)) {
            version = new Version(nexttok);
            nexttok = st.nextToken();
        }
        int generation = Integer.parseInt(nexttok);

        // component suffix
        String component = st.nextToken();
        directory = directory != null ? directory : new Path(".");
        return Pair.create(new Descriptor(version, directory, ksname, cfname, generation, temporary), component);
    }
1091137
private static Path[] provisionClassPath(FileSystem fs, String applicationName, String[] classPathExclusions){
		String genJarProperty = System.getProperty(TezConstants.GENERATE_JAR);
		boolean generateJar = genJarProperty != null && Boolean.parseBoolean(genJarProperty);
		List<Path> provisionedPaths = new ArrayList<Path>();
		List<File> generatedJars = new ArrayList<File>();

		boolean confFromHadoopConfDir = generateConfigJarFromHadoopConfDir(fs, applicationName, provisionedPaths, generatedJars);

		TezConfiguration tezConf = new TezConfiguration(fs.getConf());
		boolean provisionTez = true;
		if (tezConf.get("tez.lib.uris") != null){
			provisionTez = false;
		}
		URL[] classpath = ((URLClassLoader) ClassLoader.getSystemClassLoader()).getURLs();
		for (URL classpathUrl : classpath) {
			File f = new File(classpathUrl.getFile());
			if (f.isDirectory()) {
				if (generateJar){
					String jarFileName = ClassPathUtils.generateJarFileName("application");
					f = doGenerateJar(f, jarFileName, generatedJars, "application");
				}
				else if (f.getName().equals("conf") && !confFromHadoopConfDir){
					String jarFileName = ClassPathUtils.generateJarFileName("conf_application");
					f = doGenerateJar(f, jarFileName, generatedJars, "configuration");
				}
				else {
					f = null;
				}
			}
			if (f != null){
				if (f.getName().startsWith("tez-") && !provisionTez){
					logger.info("Skipping provisioning of " + f.getName() + " since Tez libraries are already provisioned");
					continue;
				}
				String destinationFilePath = applicationName + "/" + f.getName();
				Path provisionedPath = new Path(fs.getHomeDirectory(), destinationFilePath);
				if (shouldProvision(provisionedPath.getName(), classPathExclusions)){
					try {
						provisioinResourceToFs(fs, new Path(f.getAbsolutePath()), provisionedPath);
						provisionedPaths.add(provisionedPath);
					} catch (Exception e) {
						logger.warn("Failed to provision " + provisionedPath + "; " + e.getMessage());
						if (logger.isDebugEnabled()){
							logger.trace("Failed to provision " + provisionedPath, e);
						}
					}
				}
			}

		}

		for (File generatedJar : generatedJars) {
			try {
				generatedJar.delete();
			} catch (Exception e) {
				logger.warn("Failed to delete generated jars", e);
			}
		}
		return provisionedPaths.toArray(new Path[]{});
	}
1094655
public static WasbUnderFileSystem createInstance(AlluxioURI uri,
      UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) {
    Configuration wasbConf = createConfiguration(conf);
    return new WasbUnderFileSystem(uri, conf, wasbConf, alluxioConf);
  }
131369
private void createSystemFolder() throws IOException {
        if(!Files.exists(systemLocation.toPath()))
            Files.createDirectories(systemLocation.toPath());
    }
263001
public static <T> StreamSorterStorageImpl<T> create(Executor executor,
			BinarySerializer<T> serializer, Path path) {
		checkArgument(!path.getFileName().toString().contains("%d"), "Filename should not contain '%d'");
		try {
			Files.createDirectories(path);
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
		return new StreamSorterStorageImpl<>(executor, serializer, path);
	}
1361024
private static FileSystem createZipFileSystem(String zipFilename, boolean create) throws IOException {

        // convert the filename to a URI
        final Path path = Paths.get(zipFilename);
        if(Files.notExists(path.getParent())) {
            Files.createDirectories(path.getParent());
        }
        final URI uri = URI.create("jar:file:" + path.toUri().getPath());

        final Map<String, String> env = new HashMap<>();
        if (create) {
            env.put("create", "true");
        }
        return FileSystems.newFileSystem(uri, env);
    }
714937
def fileobj(path_or_file, mode='r'):
    """"""
    if isinstance(path_or_file, six.string_types):
        try:
            return open(path_or_file, mode)
        except IOError:
            log = logging.getLogger('sos')
            log.debug("fileobj: %s could not be opened" % path_or_file)
            return closing(six.StringIO())
    else:
        return closing(path_or_file)
1060067
def filename(self):
        """"""
        if self._filename is None:
            if os.path.splitext(self.destination)[1]:
                # If the filename has been given make use of it
                target_file = self.destination
            else:
                # Otherwise create it from the build details
                target_file = os.path.join(self.destination,
                                           self.build_filename(self.binary))

            self._filename = os.path.abspath(target_file)

        return self._filename
727228
protected Nfs3File newFile(String path, LinkTracker<Nfs3, Nfs3File> linkTracker) throws IOException {
        return new Nfs3File(getNfs(), path, linkTracker);
    }