本文整理汇总了Java中org.apache.commons.vfs.FileType.FOLDER属性的典型用法代码示例。如果您正苦于以下问题:Java FileType.FOLDER属性的具体用法?Java FileType.FOLDER怎么用?Java FileType.FOLDER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.vfs.FileType
的用法示例。
在下文中一共展示了FileType.FOLDER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileType
public FileType getFileType(String filename) throws KettleJobException
{
try {
SftpATTRS attrs=c.stat(filename);
if (attrs == null) return FileType.IMAGINARY;
if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0)
throw new KettleJobException("Unknown permissions error");
if (attrs.isDir())
return FileType.FOLDER;
else
return FileType.FILE;
} catch (Exception e) {
throw new KettleJobException(e);
}
}
示例2: doGetType
@Override
protected FileType doGetType() throws Exception {
synchronized (proactiveFS) {
if (fileInfo.getType() == null) {
return FileType.IMAGINARY;
}
switch (fileInfo.getType()) {
case FILE:
return FileType.FILE;
case DIRECTORY:
return FileType.FOLDER;
default:
throw new RuntimeException("Unexpected file type");
}
}
}
示例3: doGetType
/**
* Returns the file's type.
*/
protected FileType doGetType()
throws Exception
{
// JDK BUG: 6192331
// if (!file.exists())
if (!file.exists() && file.length() < 1)
{
return FileType.IMAGINARY;
}
if (file.isDirectory())
{
return FileType.FOLDER;
}
// In doubt, treat an existing file as file
// if (file.isFile())
// {
return FileType.FILE;
// }
// throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
示例4: listChildren
/**
* Lists the children of a folder.
*/
private void listChildren(final FileObject dir,
final boolean recursive,
final String prefix)
throws FileSystemException
{
final FileObject[] children = dir.getChildren();
for (int i = 0; i < children.length; i++)
{
final FileObject child = children[i];
System.out.print(prefix);
System.out.print(child.getName().getBaseName());
if (child.getType() == FileType.FOLDER)
{
System.out.println("/");
if (recursive)
{
listChildren(child, recursive, prefix + " ");
}
}
else
{
System.out.println();
}
}
}
示例5: setZipEntry
/**
* Sets the details for this file object.
*/
protected void setZipEntry(final ZipEntry entry)
{
if (this.entry != null)
{
return;
}
if ((entry == null) || (entry.isDirectory()))
{
type = FileType.FOLDER;
}
else
{
type = FileType.FILE;
}
this.entry = entry;
}
示例6: doGetType
protected FileType doGetType() throws Exception {
if ("".equals(this.getS3Key()) || this.getS3Key().endsWith("/") ) {
return FileType.FOLDER;
}else{
return FileType.FILE;
}
}
示例7: createFileSystem
/**
* Creates an empty virtual file system.
* @param rootUri The root of the file system.
* @return A FileObject in the FileSystem.
* @throws FileSystemException if an error occurs.
*/
public FileObject createFileSystem(final String rootUri) throws FileSystemException
{
final FileName rootName =
new VirtualFileName(rootUri, FileName.ROOT_PATH, FileType.FOLDER);
// final FileName rootName =
// new BasicFileName(rootUri, FileName.ROOT_PATH);
final VirtualFileSystem fs = new VirtualFileSystem(rootName, null);
addComponent(fs);
return fs.getRoot();
}
示例8: doCreateFileSystem
/**
* Creates a layered file system. This method is called if the file system
* is not cached.
*
* @param scheme The URI scheme.
* @param file The file to create the file system on top of.
* @return The file system.
*/
protected FileSystem doCreateFileSystem(final String scheme,
final FileObject file,
final FileSystemOptions fileSystemOptions)
throws FileSystemException
{
final FileName name =
new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
return new JarFileSystem(name, file, fileSystemOptions);
}
示例9: addFolder
/**
* Adds a child folder.
*/
public FileInfo addFolder(final String baseName)
{
final FileInfo child = new FileInfo(baseName, FileType.FOLDER, null);
addChild(child);
return child;
}
示例10: setType
/**
* sets the type of this file e.g. when it will be attached.
*
* @param type {@link FileType#FOLDER} or {@link FileType#FILE}
* @throws FileSystemException if an error occurs.
*/
void setType(FileType type) throws FileSystemException
{
if (type != FileType.FOLDER && type != FileType.FILE && type != FileType.FILE_OR_FOLDER)
{
throw new FileSystemException("vfs.provider/filename-type.error");
}
this.type = type;
}
示例11: doGetType
/**
* Determines the type of the file, returns null if the file does not
* exist.
*/
protected FileType doGetType()
throws Exception
{
// VFS-210
synchronized (getFileSystem())
{
if (this.fileInfo == null)
{
getInfo(false);
}
if (this.fileInfo == UNKNOWN)
{
return FileType.IMAGINARY;
}
else if (this.fileInfo.isDirectory())
{
return FileType.FOLDER;
}
else if (this.fileInfo.isFile())
{
return FileType.FILE;
}
else if (this.fileInfo.isSymbolicLink())
{
return getLinkDestination().getType();
}
}
throw new FileSystemException("vfs.provider.ftp/get-type.error", getName());
}
示例12: doCreateFileSystem
/**
* Creates a layered file system. This method is called if the file system
* is not cached.
*
* @param scheme The URI scheme.
* @param file The file to create the file system on top of.
* @return The file system.
*/
protected FileSystem doCreateFileSystem(final String scheme,
final FileObject file,
final FileSystemOptions fileSystemOptions)
throws FileSystemException
{
final FileName name =
new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
return createFileSystem(name, file, fileSystemOptions);
}
示例13: getChildren
/**
* Returns the file's list of children.
*
* @return The list of children
* @throws FileSystemException If there was a problem listing children
* @see AbstractFileObject#getChildren()
* @since 1.0
*/
public FileObject[] getChildren() throws FileSystemException
{
try
{
if (doGetType() != FileType.FOLDER)
{
throw new FileNotFolderException(getName());
}
}
catch (Exception ex)
{
throw new FileNotFolderException(getName(), ex);
}
try
{
/* Wrap our parent implementation, noting that we're refreshing so
* that we don't refresh() ourselves and each of our parents for
* each children. Note that refresh() will list children. Meaning,
* if if this file has C children, P parents, there will be (C * P)
* listings made with (C * (P + 1)) refreshes, when there should
* really only be 1 listing and C refreshes. */
this.inRefresh = true;
return super.getChildren();
}
finally
{
this.inRefresh = false;
}
}
示例14: isDirectory
public boolean isDirectory() throws FileSystemException {
if ( fileObject != null )
return (fileObject.getType() == FileType.FOLDER);
else
return file.isDirectory();
}
示例15: execute
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob)
{
LogWriter log = LogWriter.getInstance();
Result result = previousResult;
result.setResult( false );
result.setNrErrors(1);
filescount=0;
folderscount=0;
pattern = null;
if (!Const.isEmpty(getWildcard())) pattern = Pattern.compile(getRealWildcard());
if (foldername!=null)
{
String realFoldername = getRealFoldername();
FileObject FolderObject = null;
try {
FolderObject = KettleVFS.getFileObject(realFoldername);
if ( FolderObject.exists() )
{
//Check if it's a folder
if(FolderObject.getType() == FileType.FOLDER)
{
// File provided is a folder, so we can process ...
FolderObject.findFiles(new TextFileSelector(FolderObject.toString()));
if(log.isBasic()) log.logBasic("Total files", "We found : "+filescount + " file(s)");
if(filescount==0)
{
result.setResult(true);
result.setNrErrors(0);
}
}
else
{
// Not a folder, fail
log.logError("Found files", "[" + realFoldername+"] is not a folder, failing.");
}
}
else
{
// No Folder found
if(log.isBasic()) log.logBasic(toString(), "we can not find ["+realFoldername+"] !");
}
} catch (IOException e) {
log.logError(toString(), "Could not create Folder ["+realFoldername+"], exception: " + e.getMessage());
result.setResult( false );
result.setNrErrors(1);
}
finally {
if ( FolderObject != null )
{
try {
FolderObject.close();
}
catch ( IOException ex ) {};
}
}
}
else
{
log.logError(toString(), "No Foldername is defined.");
}
return result;
}