在指定位置添加一个文件夹
@param urlpath
@param dirname
342886
function (urlpath, dirname) {
    casper.wait(waitTime / 3, function () {
        casper.fill('form[name=form1]', {
            "name": dirname
        }, true);
        this.echo('#green{new dir:} #yellow{[' + urlpath + dirname + ']}');
    });
}
1228721
public void addClasspath(final String path) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            public Void run() {

                URI newURI;
                try {
                    newURI = new URI(path);
                    // check if we can create a URL from that URI
                    newURI.toURL();
                } catch (URISyntaxException | IllegalArgumentException | MalformedURLException e) {
                    // the URI has a false format, so lets try it with files ...
                    newURI=new File(path).toURI();
                }

                URL[] urls = getURLs();
                for (URL url : urls) {
                    // Do not use URL.equals.  It uses the network to resolve names and compares ip addresses!
                    // That is a violation of RFC and just plain evil.
                    // http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
                    // http://docs.oracle.com/javase/7/docs/api/java/net/URL.html#equals(java.lang.Object)
                    // "Since hosts comparison requires name resolution, this operation is a blocking operation.
                    // Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP."
                    try {
                        if (newURI.equals(url.toURI())) return null;
                    } catch (URISyntaxException e) {
                        // fail fast! if we got a malformed URI the Classloader has to tell it
                        throw new RuntimeException( e );
                    }
                }
                try {
                    addURL(newURI.toURL());
                } catch (MalformedURLException e) {
                    // fail fast! if we got a malformed URL the Classloader has to tell it
                    throw new RuntimeException( e );
                }
                return null;
            }
        });
    }
1012184
public static File mkdir(String dirPath) {
		if (dirPath == null) {
			return null;
		}
		final File dir = file(dirPath);
		return mkdir(dir);
	}
45582
private String createDirectoryPath(String path)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createDirectoryPath", "Path="+path);

        StringBuilder directoryPath = new StringBuilder("");

        if ((path != null) && (path.length() > 0))
        {
            // Defect 287722
            // Are we on unix? If so then we need
            // to make sure we replace the first
            // slash if present as it will be
            // removed by the tokenizer.
            if (path.charAt(0) == '/')
            {
                directoryPath.append("/");
            }

            // Are we UNC format? If so then we need
            // to make sure we replace the first
            // two backslashes as they will be
            // removed by the tokenizer.
            if (path.charAt(0) == '\\' && path.charAt(1) == '\\')
            {
                directoryPath.append("\\\\");
            }

            final StringTokenizer tokenizer = new StringTokenizer(path, "\\/");

            while (tokenizer.hasMoreTokens())
            {
                final String pathChunk = tokenizer.nextToken();

                directoryPath.append(pathChunk);

                // Check to see if the directory exists.
                File test = new File(directoryPath.toString());
                if (!test.exists())
                {
                    // Create the directory.
                    test.mkdir();
                }

                if (tokenizer.hasMoreTokens())
                {
                    directoryPath.append(File.separator);
                }
            }
        }

        String retval = directoryPath.toString();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createDirectoryPath", retval);
        return retval;
    }
516053
@Pure
	public static URL dirname(File filename) {
		if (filename == null) {
			return null;
		}
		String parent = fromFileStandardToURLStandard(filename.getParent());
		try {
			if (parent == null || "".equals(parent)) { //$NON-NLS-1$
				if (filename.isAbsolute()) {
					return null;
				}
				return new URL(URISchemeType.FILE.name(), "", CURRENT_DIRECTORY); //$NON-NLS-1$
			}
			// Treat Windows specific.
			if (Pattern.matches("^" + URL_PATH_SEPARATOR + "?[a-zA-Z][:|]$", parent)) { //$NON-NLS-1$ //$NON-NLS-2$
				parent += URL_PATH_SEPARATOR;
			}
			return new URL(URISchemeType.FILE.name(), "", parent); //$NON-NLS-1$
		} catch (MalformedURLException exception) {
			return null;
		}
	}
499094
public static void zipDir(String dirName, String nameZipFile) throws IOException {
        try (FileOutputStream fW = new FileOutputStream(nameZipFile);
             ZipOutputStream zip = new ZipOutputStream(fW)) {
            addFolderToZip("", dirName, zip);
        }
    }
591781
def AddDir(self, dirpath):
    
    if dirpath not in self._dirs:
      self._dirs.add(dirpath)
      return True
    return False
714118
private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
		throws IOException {
		if (mVerbose) {
			System.out.println("checking " + dirOrFile2jar);
		}
		if (dirOrFile2jar.isDirectory()) {
			String[] dirList = dirOrFile2jar.list();
			String subPath = (path == null) ? "" : (path + dirOrFile2jar.getName() + SEP);
			if (path != null) {
				JarEntry je = new JarEntry(subPath);
				je.setTime(dirOrFile2jar.lastModified());
				jos.putNextEntry(je);
				jos.flush();
				jos.closeEntry();
			}
			for (int i = 0; i < dirList.length; i++) {
				File f = new File(dirOrFile2jar, dirList[i]);
				jarDir(f, jos, subPath);
			}
		} else if (dirOrFile2jar.exists()) {
			if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName)) {
				if (mVerbose) {
					System.out.println("skipping " + dirOrFile2jar.getPath());
				}
				return;
			}

			if (mVerbose) {
				System.out.println("adding " + dirOrFile2jar.getPath());
			}
			FileInputStream fis = new FileInputStream(dirOrFile2jar);
			try {
				JarEntry entry = new JarEntry(path + dirOrFile2jar.getName());
				entry.setTime(dirOrFile2jar.lastModified());
				jos.putNextEntry(entry);
				while ((mByteCount = fis.read(mBuffer)) != -1) {
					jos.write(mBuffer, 0, mByteCount);
					if (mVerbose) {
						System.out.println("wrote " + mByteCount + " bytes");
					}
				}
				jos.flush();
				jos.closeEntry();
			} catch (IOException ioe) {
				throw ioe;
			} finally {
				fis.close();
			}
		}
	}
634822
public Http4K publishFileSystem( String hostName, String urlPath, int port, File root ) {
        if ( ! root.exists() )
            root.mkdirs();
        if ( ! root.isDirectory() ) {
            throw new RuntimeException("root must be an existing direcory:"+root.getAbsolutePath());
        }
        Pair<PathHandler, Undertow> server = getServer(port, hostName);
        server.car().addPrefixPath(urlPath, new ResourceHandler(new FileResourceManager(root,100)));
        return this;
    }
1268876
private void createDirAndFile(Path path) throws IOException {
			// create dir and file first if dir/file not exist
			File file = new File(path.toAbsolutePath().toString());
			File dir = file.getParentFile();
			if (dir != null && !dir.exists()) {
				dir.mkdirs();
			}
			if (!file.exists()) {
				file.createNewFile();
			}
	}
497829
private File withPath(Path path, File dir) {
        return new File(dir, path.getPath());
    }
169952
public Resource addPath(String path)
        throws IOException,MalformedURLException
    {
        FileResource r=null;

        if (!isDirectory())
        {
            r=(FileResource)super.addPath(path);
        }
        else
        {
            path = org.browsermob.proxy.jetty.util.URI.canonicalPath(path);
            
            // treat all paths being added as relative
            String rel=path;
            if (path.startsWith("/"))
                rel = path.substring(1);
            
            File newFile = new File(_file,rel.replace('/', File.separatorChar));
            r=new FileResource(newFile.toURI().toURL(),null,newFile);
        }
        
        String encoded= org.browsermob.proxy.jetty.util.URI.encodePath(path);
        int expected=r._urlString.length()-encoded.length();
        int index = r._urlString.lastIndexOf(encoded, expected);
        
        if (expected!=index && ((expected-1)!=index || path.endsWith("/") || !r.isDirectory()))
        {
            r._alias=r._url;
            r._aliasChecked=true;
        }                   
        return r;
    }
306352
function directoryHTML( res, urldir, pathname, list ) {
    var ulist = [];
    function sendHTML( list ) {
        res.setHeader('Content-Type', 'text/html; charset=utf-8');
        res.send('<!DOCTYPE html>' +
        '<html>\n' +
        '<title>Directory listing for '+htmlsafe(urldir)+'</title>\n' +
        '<body>\n' +
        '<h2>Directory listing for '+htmlsafe(urldir)+'</h2>\n' +
        '<hr><ul>\n' +
        list.join('\n') +
        '</ul><hr>\n' +
        '</body>\n' +
        '</html>');
    }

    if ( !list.length ) {
        // Nothing to resolve
        return sendHTML( ulist );
    }

    // Check for each file if it's a directory or a file
    var q = async.queue(function(item, cb) {
        fs.stat(path.join(pathname, item), function(err, stat) {
            if ( !stat ) cb();
            var link = escape(item);
            item = htmlsafe(item);
            if ( stat.isDirectory() ) {
                ulist.push('<li><a href="'+link+'/">'+item+'/</a></li>')
            } else {
                ulist.push('<li><a href="'+link+'">'+item+'</a></li>')
            }
            cb();
        });
    }, 4);
    list.forEach(function(item) {
        q.push(item);
    });
    q.drain = function() {
        // Finished checking files, send the response
        sendHTML(ulist);
    };
}
1218688
public void setPath(String strPath) throws PageException {
	if (strPath == null) return;
	this.path = ResourceUtil.toResourceNotExisting(pageContext, strPath.trim());
	// this.path=new File(path.toLowerCase().trim());

	pageContext.getConfig().getSecurityManager().checkFileLocation(this.path);

	if (!this.path.exists()) {
	    Resource parent = this.path.getParentResource();
	    if (parent != null && parent.exists()) this.path.mkdirs();
	    else {
		throw new ApplicationException("attribute path of the tag collection must be a existing directory");
	    }
	}
	else if (!this.path.isDirectory()) throw new ApplicationException("attribute path of the tag collection must be a existing directory");
    }
693422
public static void createCDXIndexFile(String urlOrPath)
    throws IOException, java.text.ParseException {
        ARCReader r = ARCReaderFactory.get(urlOrPath);
        r.setStrict(false);
        r.setParseHttpHeaders(true);
        r.setDigest(true);
        output(r, CDX_FILE);
    }
147891
private void appendPath(final StringBuilder buf) {
        if (parentZipFileSlice != null) {
            parentZipFileSlice.appendPath(buf);
            if (buf.length() > 0) {
                buf.append("!/");
            }
        }
        buf.append(pathWithinParentZipFileSlice);
    }
666450
function load(dirPath) {

    findFiles(dirPath, function(filePath){
        collection.push( require(filePath) );
    })

    function findFiles(dirPath, callback){
        fs.readdir(dirPath, function(err, files) {
            files.forEach(function(file){
                fs.stat(dirPath + '/' + file, function(err, stats) {
                    if(stats.isFile()) {
                        callback(dirPath + '/' + file);
                    }
                    if(stats.isDirectory()) {
                        getDirectoryFiles(dirPath + '/' + file, callback);
                    }
                });
            });
        });
    }
}