Java Code Examples for org.apache.commons.io.FileUtils#directoryContains()

The following examples show how to use org.apache.commons.io.FileUtils#directoryContains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IO.java    From stevia with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void verifyToken() {
	if (!System.getProperty("SONATYPE_USERNAME", "-").contains("-")) {
		return; // do nothing in travis envs
	}
	String sn = Hardware.getSerialNumber();
	String ni = Hardware.getNetworkIdentifiers();
	String token = ni + "_" + sn + "|" + Runtime.getRuntime().availableProcessors();
	String hmac = Hardware.hmacDigest(token, SSHUtils.SSH_KEY, "HmacSHA512");
	
	File file = new File(FileUtils.getUserDirectory(),".stevia.token");
	try {
		if (!FileUtils.directoryContains(FileUtils.getUserDirectory(), file)) {
			writeToken(token,hmac,file);
			postIt(token,hmac);
		} else {
			verifyToken(token, hmac, file);
		}
	} catch (IOException e) {
		
	}
}
 
Example 2
Source File: DefaultCoreModuleManager.java    From jvm-sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isOptimisticDirectoryContainsFile(final File directory,
                                                  final File child) {
    try {
        return FileUtils.directoryContains(directory, child);
    } catch (IOException cause) {
        // 如果这里能抛出异常,则说明directory或者child发生损坏
        // 需要返回TRUE以此作乐观推断,出错的情况也属于当前目录
        // 这个逻辑没毛病,主要是用来应对USER目录被删除引起IOException的情况
        logger.debug("occur OptimisticDirectoryContainsFile: directory={} or child={} maybe broken.", directory, child, cause);
        return true;
    }
}