net.roboconf.core.utils.Utils.isAncestorFile()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中net.roboconf.core.utils.Utils.isAncestorFile()方法的一些代码示例,展示了Utils.isAncestorFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.isAncestorFile()方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:isAncestorFile

Utils.isAncestorFile介绍

[英]Determines whether a file is a parent of another file.

This method handles intermediate '.' and '..' segments.
[中]确定一个文件是否是另一个文件的父级。
此方法处理中间“.”还有“…”部分。

代码示例

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testIsAncestorFile() throws Exception {
  File parent = new File( "home/toto/whatever" );
  Assert.assertTrue( Utils.isAncestorFile( parent, parent ));
  File comp = new File( "home/toto/whatever/" );
  Assert.assertTrue( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/./whatever/" );
  Assert.assertTrue( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/../toto/whatever/" );
  Assert.assertTrue( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/whatever/some-file.txt" );
  Assert.assertTrue( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/whatever/some/dir/some-file.txt" );
  Assert.assertTrue( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/" );
  Assert.assertFalse( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/whateve" );
  Assert.assertFalse( Utils.isAncestorFile( parent, comp ));
  comp = new File( "home/toto/whatevereeeeeee" );
  Assert.assertFalse( Utils.isAncestorFile( parent, comp ));
}

代码示例来源:origin: net.roboconf/roboconf-dm

try {
  if( ! applicationFilesDirectory.equals( targetDirectory )) {
    if( Utils.isAncestorFile( targetDirectory, applicationFilesDirectory ))
      throw new IOException( "Cannot move " + applicationFilesDirectory + " in Roboconf's work directory. Already a child directory." );
    else

相关文章