protected HTTPFile(FileURL fileURL, URL url) throws IOException { super(fileURL); String scheme = fileURL.getScheme().toLowerCase(); if((!scheme.equals(FileProtocols.HTTP) && !scheme.equals(FileProtocols.HTTPS)) || fileURL.getHost()==null) throw new IOException(); this.url = url; attributes = getDefaultAttributes(); String mimeType; String filename = fileURL.getFilename(); // Simple/fuzzy heuristic to avoid file resolution (HEAD) in cases where we have good reasons to believe that // the URL denotes a HTML/XTHML document: // - URL's path has no filename (e.g. http://www.mucommander.com/) or path ends with '/' (e.g. http://www.mucommander.com/download/) // - URL has a query part (works most of the time, must not always) // - URL has an extension that registered with an HTML/XHTML mime type if((filename==null || fileURL.getPath().endsWith("/") || fileURL.getQuery()!=null || ((mimeType=MimeTypes.getMimeType(this))!=null && isParsableMimeType(mimeType)))) { attributes.setDirectory(true); resolve = false; } else { resolve = true; } }
attributes.setDirectory(true);
protected S3Root(FileURL url, S3Service service) { super(url, service); atts = new SimpleFileAttributes(); atts.setPath("/"); atts.setExists(true); atts.setDate(0); atts.setSize(0); atts.setDirectory(true); atts.setPermissions(DEFAULT_PERMISSIONS); atts.setOwner(null); atts.setGroup(null); }
/** * Creates a new SimpleFileAttributes instance whose attributes are set to those of the given AbstractFile. * Note that the path attribute is set to the file's {@link com.mucommander.commons.file.AbstractFile#getAbsolutePath() absolute path}. * * @param file the file from which to fetch the attribute values */ public SimpleFileAttributes(AbstractFile file) { setPath(file.getAbsolutePath()); setExists(file.exists()); setDate(file.getDate()); setSize(file.getSize()); setDirectory(file.isDirectory()); setPermissions(file.getPermissions()); setOwner(file.getOwner()); setGroup(file.getGroup()); }