use of org.geotoolkit.gml.xml.v321.FileType in project commons-vfs by apache.
the class LocalFileNameParser method parseUri.
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String uri) throws FileSystemException {
final StringBuilder nameBuilder = new StringBuilder();
// Extract the scheme
String scheme = UriParser.extractScheme(getSchemes(context, base, uri), uri, nameBuilder);
if (scheme == null && base != null) {
scheme = base.getScheme();
}
if (scheme == null) {
scheme = "file";
}
// Remove encoding, and adjust the separators
UriParser.canonicalizePath(nameBuilder, 0, nameBuilder.length(), this);
UriParser.fixSeparators(nameBuilder);
// Extract the root prefix
final String rootFile = extractRootPrefix(uri, nameBuilder);
// Normalise the path
final FileType fileType = UriParser.normalisePath(nameBuilder);
final String path = nameBuilder.toString();
return createFileName(scheme, rootFile, path, fileType);
}
use of org.geotoolkit.gml.xml.v321.FileType in project commons-vfs by apache.
the class DefaultFileSystemManager method resolveName.
/**
* Resolves a name, relative to the root.
*
* @param base the base file name
* @param name the name
* @param scope the {@link NameScope}
* @return The FileName of the file.
* @throws FileSystemException if an error occurs.
*/
@Override
public FileName resolveName(final FileName base, final String name, final NameScope scope) throws FileSystemException {
FileSystemException.requireNonNull(base, "Invalid base FileName.");
FileSystemException.requireNonNull(name, "Invalid name FileName.");
final FileName realBase;
if (VFS.isUriStyle() && base.isFile()) {
realBase = base.getParent();
} else {
realBase = base;
}
final StringBuilder buffer = new StringBuilder(name);
// Adjust separators
UriParser.fixSeparators(buffer);
String scheme = UriParser.extractScheme(getSchemes(), buffer.toString());
// Determine whether to prepend the base path
if (name.isEmpty() || scheme == null && buffer.charAt(0) != FileName.SEPARATOR_CHAR) {
// Supplied path is not absolute
if (!VFS.isUriStyle()) {
// when using URIs the parent already do have the trailing "/"
buffer.insert(0, FileName.SEPARATOR_CHAR);
}
buffer.insert(0, realBase.getPath());
}
// Normalise the path
final FileType fileType = UriParser.normalisePath(buffer);
// Check the name is ok
final String resolvedPath = buffer.toString();
if (!AbstractFileName.checkName(realBase.getPath(), resolvedPath, scope)) {
throw new FileSystemException("vfs.provider/invalid-descendent-name.error", name);
}
final String fullPath;
if (scheme != null) {
fullPath = resolvedPath;
} else {
scheme = realBase.getScheme();
fullPath = realBase.getRootURI() + resolvedPath;
}
final FileProvider provider = providers.get(scheme);
if (provider != null) {
return provider.parseUri(realBase, fullPath);
}
// An unknown scheme - hand it to the default provider - if possible
if (scheme != null && defaultProvider != null) {
return defaultProvider.parseUri(realBase, fullPath);
}
// this happens if we have a virtual filesystem (no provider for scheme)
return ((AbstractFileName) realBase).createName(resolvedPath, fileType);
}
use of org.geotoolkit.gml.xml.v321.FileType in project agileway by fangjinuo.
the class SftpFileObject method doGetType.
@Override
protected FileType doGetType() throws Exception {
com.jn.agileway.ssh.client.sftp.attrs.FileType fileType = getFileAttrs().getFileType();
FileType ft = FileType.IMAGINARY;
if (fileType != null) {
switch(fileType) {
case REGULAR:
ft = FileType.FILE;
break;
case DIRECTORY:
ft = FileType.FOLDER;
break;
case SYMBOLIC_LINK:
ft = FileType.FILE_OR_FOLDER;
break;
case CHAR_SPECIAL:
case FIFO_SPECIAL:
case SOCKET_SPECIAL:
case BLOCK_SPECIAL:
case UNKNOWN:
break;
default:
break;
}
}
return ft;
}
use of org.geotoolkit.gml.xml.v321.FileType in project hop by apache.
the class AzureFileNameParser method parseUri.
@Override
public FileName parseUri(final VfsComponentContext context, FileName base, String filename) throws FileSystemException {
final StringBuilder name = new StringBuilder();
Authority auth = null;
String path = null;
FileType fileType;
int eidx = filename.indexOf("@/");
if (eidx != -1)
filename = filename.substring(0, eidx + 1) + "windowsazure.com" + filename.substring(eidx + 1);
String scheme;
try {
auth = extractToPath(filename, name);
if (auth.getUserName() == null) {
scheme = UriParser.extractScheme(filename, name);
UriParser.canonicalizePath(name, 0, name.length(), this);
UriParser.fixSeparators(name);
} else {
scheme = auth.getScheme();
}
fileType = UriParser.normalisePath(name);
path = name.toString();
if (path.equals("")) {
path = "/";
}
} catch (FileSystemException fse) {
scheme = UriParser.extractScheme(filename, name);
UriParser.canonicalizePath(name, 0, name.length(), this);
UriParser.fixSeparators(name);
fileType = UriParser.normalisePath(name);
path = name.toString();
}
return new AzureFileName(scheme, path, fileType);
}
use of org.geotoolkit.gml.xml.v321.FileType in project hop by apache.
the class S3FileNameParser method parseUri.
@Override
public FileName parseUri(VfsComponentContext context, FileName base, String uri) throws FileSystemException {
StringBuilder name = new StringBuilder();
String scheme = UriParser.extractScheme(uri, name);
UriParser.canonicalizePath(name, 0, name.length(), this);
// Normalize separators in the path
UriParser.fixSeparators(name);
// Normalise the path
FileType fileType = UriParser.normalisePath(name);
String fullPath = name.toString();
// Extract bucket name
final String bucketName = UriParser.extractFirstElement(name);
return new S3FileName(scheme, bucketName, fullPath, fileType);
}
Aggregations