本文整理汇总了Java中org.apache.commons.vfs2.FileName.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java FileName.getParent方法的具体用法?Java FileName.getParent怎么用?Java FileName.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.FileName
的用法示例。
在下文中一共展示了FileName.getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRoot
import org.apache.commons.vfs2.FileName; //导入方法依赖的package包/类
/**
* find the root of the filesystem.
* @return The root FileName.
*/
public FileName getRoot()
{
FileName root = this;
while (root.getParent() != null)
{
root = root.getParent();
}
return root;
}
示例2: addJunction
import org.apache.commons.vfs2.FileName; //导入方法依赖的package包/类
/**
* Adds a junction to this file system.
* @param junctionPoint The location of the junction.
* @param targetFile The target file to base the junction on.
* @throws FileSystemException if an error occurs.
*/
@Override
public void addJunction(final String junctionPoint,
final FileObject targetFile)
throws FileSystemException
{
final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint);
// Check for nested junction - these are not supported yet
if (getJunctionForFile(junctionName) != null)
{
throw new FileSystemException("vfs.impl/nested-junction.error", junctionName);
}
try
{
// Add to junction table
junctions.put(junctionName, targetFile);
// Attach to file
final DelegateFileObject junctionFile = (DelegateFileObject) getFileFromCache(junctionName);
if (junctionFile != null)
{
junctionFile.setFile(targetFile);
}
// Create ancestors of junction point
FileName childName = junctionName;
boolean done = false;
for (AbstractFileName parentName = (AbstractFileName) childName.getParent();
!done && parentName != null;
childName = parentName, parentName = (AbstractFileName) parentName.getParent())
{
DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName);
if (file == null)
{
file = new DelegateFileObject(parentName, this, null);
putFileToCache(file);
}
else
{
done = file.exists();
}
// As this is the parent of our junction it has to be a folder
file.attachChild(childName, FileType.FOLDER);
}
// TODO - attach all cached children of the junction point to their real file
}
catch (final Exception e)
{
throw new FileSystemException("vfs.impl/create-junction.error", junctionName, e);
}
}