org.neo4j.io.fs.FileUtils.path()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(141)

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

FileUtils.path介绍

[英]Useful when you want to move a file from one directory to another by renaming the file and keep eventual sub directories. Example:

You want to move file /a/b1/c/d/file from /a/b1 to /a/b2 and keep the sub path /c/d/file.

fileToMove = new File( "/a/b1/c/d/file" ); 
fromDir = new File( "/a/b1" ); 
toDir = new File( "/a/b2" ); 
fileToMove.rename( pathToFileAfterMove( fromDir, toDir, fileToMove ) ); 
// fileToMove.getAbsolutePath() -> /a/b2/c/d/file

Calls #pathToFileAfterMove(Path,Path,Path) after transforming given files to paths by calling File#toPath().

NOTE: This that this does not perform the move, it only calculates the new file name.

Throws IllegalArgumentException is fileToMove is not a sub path to fromDir.
[中]当您希望通过重命名文件并保留最终子目录将文件从一个目录移动到另一个目录时,此选项非常有用。例子:
您希望将文件/a/b1/c/d/file从/a/b1移动到/a/b2,并保留子路径/c/d/file。

fileToMove = new File( "/a/b1/c/d/file" ); 
fromDir = new File( "/a/b1" ); 
toDir = new File( "/a/b2" ); 
fileToMove.rename( pathToFileAfterMove( fromDir, toDir, fileToMove ) ); 
// fileToMove.getAbsolutePath() -> /a/b2/c/d/file

通过调用File#toPath()将给定文件转换为路径后,调用#pathToFileAfterMove(Path,Path,Path)。
注意:这并不执行移动,它只计算新文件名。
抛出IllegalArgumentException是fileToMove不是fromDir的子路径。

代码示例

代码示例来源:origin: neo4j/neo4j

/**
 * Returns the base schema index directory, i.e.
 *
 * <pre>
 * &lt;db&gt;/schema/index/
 * </pre>
 *
 * @param databaseStoreDir database store directory, i.e. {@code db} in the example above, where e.g. {@code nodestore} lives.
 * @return the base directory of schema indexing.
 */
public static File baseSchemaIndexFolder( File databaseStoreDir )
{
  return path( databaseStoreDir, "schema", "index" );
}

代码示例来源:origin: neo4j/neo4j

@Override
  public File directoryForIndex( long indexId )
  {
    return path( providerRootFolder, String.valueOf( indexId ) );
  }
}

代码示例来源:origin: neo4j/neo4j

public static File path( String root, String... path )
{
  return path( new File( root ), path );
}

代码示例来源:origin: neo4j/neo4j

@Override
  public File directoryForIndex( long indexId )
  {
    return path( parentStructure.directoryForIndex( indexId ), fileNameFriendly( descriptor ) );
  }
};

代码示例来源:origin: neo4j/neo4j

/**
* @param databaseStoreDir store directory of database, i.e. {@code db} in the example above.
* @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like:
*
* <pre>
* &lt;db&gt;/schema/index/&lt;providerKey&gt;-&lt;providerVersion&gt;/&lt;indexId&gt;/
* </pre>
*/
public static Factory directoriesByProvider( File databaseStoreDir )
{
  return descriptor -> new SubDirectoryByIndexId(
      path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor ) ) );
}

代码示例来源:origin: neo4j/neo4j

/**
 * @param databaseStoreDir store directory of database, i.e. {@code db} in the example above.
 * @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like:
 *
 * <pre>
 * &lt;db&gt;/schema/index/&lt;providerKey&gt;/&lt;indexId&gt;/
 * </pre>
 */
public static Factory directoriesByProviderKey( File databaseStoreDir )
{
  return descriptor -> new SubDirectoryByIndexId(
      path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor.getKey() ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldHandleWeirdCharactersInProviderKey()
{
  IndexProviderDescriptor providerWithWeirdName = new IndexProviderDescriptor( "native+lucene", "1.0" );
  assertCorrectDirectories( directoriesByProvider( databaseStoreDir ).forProvider( providerWithWeirdName ),
      path( baseIndexDirectory, "native_lucene-1.0" ),
      path( baseIndexDirectory, "native_lucene-1.0", String.valueOf( indexId ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldSeeCorrectDirectoriesForProviderKey()
{
  assertCorrectDirectories( directoriesByProviderKey( databaseStoreDir ).forProvider( provider ),
      path( baseIndexDirectory, provider.getKey() ),
      path( baseIndexDirectory, provider.getKey(), String.valueOf( indexId ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldSeeCorrectDirectoriesForProvider()
{
  assertCorrectDirectories( directoriesByProvider( databaseStoreDir ).forProvider( provider ),
      path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion() ),
      path( baseIndexDirectory, provider.getKey() + "-" +  provider.getVersion(), String.valueOf( indexId ) ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldSeeCorrectDirectoriesForSubProvider()
{
  IndexDirectoryStructure parentStructure = directoriesByProvider( databaseStoreDir ).forProvider( provider );
  IndexProviderDescriptor subProvider = new IndexProviderDescriptor( "sub", "0.3" );
  assertCorrectDirectories( directoriesBySubProvider( parentStructure ).forProvider( subProvider ),
      path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion() ),
      path( baseIndexDirectory, provider.getKey() + "-" + provider.getVersion(),
          String.valueOf( indexId ), subProvider.getKey() + "-" + subProvider.getVersion() ) );
}

代码示例来源:origin: org.neo4j/neo4j-kernel

/**
 * Returns the base schema index directory, i.e.
 *
 * <pre>
 * &lt;db&gt;/schema/index/
 * </pre>
 *
 * @param databaseStoreDir database store directory, i.e. {@code db} in the example above, where e.g. {@code nodestore} lives.
 * @return the base directory of schema indexing.
 */
public static File baseSchemaIndexFolder( File databaseStoreDir )
{
  return path( databaseStoreDir, "schema", "index" );
}

代码示例来源:origin: org.neo4j/neo4j-kernel

@Override
  public File directoryForIndex( long indexId )
  {
    return path( providerRootFolder, String.valueOf( indexId ) );
  }
}

代码示例来源:origin: org.neo4j/neo4j-io

public static File path( String root, String... path )
{
  return path( new File( root ), path );
}

代码示例来源:origin: org.neo4j/neo4j-kernel

@Override
  public File directoryForIndex( long indexId )
  {
    return path( parentStructure.directoryForIndex( indexId ), fileNameFriendly( descriptor ) );
  }
};

代码示例来源:origin: org.neo4j/neo4j-kernel

/**
* @param databaseStoreDir store directory of database, i.e. {@code db} in the example above.
* @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like:
*
* <pre>
* &lt;db&gt;/schema/index/&lt;providerKey&gt;-&lt;providerVersion&gt;/&lt;indexId&gt;/
* </pre>
*/
public static Factory directoriesByProvider( File databaseStoreDir )
{
  return descriptor -> new SubDirectoryByIndexId(
      path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor ) ) );
}

代码示例来源:origin: org.neo4j/neo4j-kernel

/**
 * @param databaseStoreDir store directory of database, i.e. {@code db} in the example above.
 * @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like:
 *
 * <pre>
 * &lt;db&gt;/schema/index/&lt;providerKey&gt;/&lt;indexId&gt;/
 * </pre>
 */
public static Factory directoriesByProviderKey( File databaseStoreDir )
{
  return descriptor -> new SubDirectoryByIndexId(
      path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor.getKey() ) ) );
}

相关文章