当前位置: 首页>>代码示例>>Java>>正文


Java FileName.getParent方法代码示例

本文整理汇总了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;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:15,代码来源:AbstractFileName.java

示例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);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:61,代码来源:VirtualFileSystem.java


注:本文中的org.apache.commons.vfs2.FileName.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。