/// <summary> /// Return a bitmap for a given path /// </summary> /// <param name="path"></param> /// <returns></returns> public Bitmap IconForPath(Path path, IconSize size) { if (path.getType().contains(AbstractPath.Type.decrypted)) { Bitmap overlay = IconForName("unlockedbadge", size); if (path.isDirectory()) { return(IconForFolder(overlay, size)); } Bitmap unlocked = IconForFilename(path.getName(), size); return(OverlayImages(unlocked, overlay)); } if (path.isSymbolicLink()) { Bitmap overlay = IconForName("aliasbadge", size); if (path.isDirectory()) { return(IconForFolder(overlay, size)); } Bitmap symlink = IconForFilename(path.getName(), size); return(OverlayImages(symlink, overlay)); } if (path.isFile()) { if (String.IsNullOrEmpty(path.getExtension())) { if (path.attributes().getPermission().isExecutable()) { return(IconForName("executable", size)); } } return(IconForFilename(path.getName(), size)); } if (path.isDirectory()) { if (!Permission.EMPTY.equals(path.attributes().getPermission())) { if (!path.attributes().getPermission().isExecutable()) { return(IconForFolder(IconForName("privatefolderbadge", size), size)); } if (!path.attributes().getPermission().isReadable()) { if (path.attributes().getPermission().isWritable()) { return(IconForFolder(IconForName("dropfolderbadge", size), size)); } } if (!path.attributes().getPermission().isWritable()) { return(IconForFolder(IconForName("readonlyfolderbadge", size), size)); } } return(IconForFolder(size)); } return(ResizeImage(IconForName("notfound", size), size)); }
/// <summary> /// Return a bitmap for a given path /// </summary> /// <param name="path"></param> /// <returns></returns> public Bitmap IconForPath(Path path, IconSize size) { if (path.attributes().isSymbolicLink()) { Bitmap overlay = IconForName("aliasbadge", size); if (path.attributes().isDirectory()) { return(IconForFolder(overlay, size)); } Bitmap symlink = IconForFilename(path.getName(), size); return(OverlayImages(symlink, overlay)); } if (path.attributes().isFile()) { if (String.IsNullOrEmpty(path.getExtension())) { if (path.attributes().getPermission().isExecutable()) { return(IconForName("executable", size)); } } return(IconForFilename(path.getName(), size)); } if (path.attributes().isVolume()) { return(IconForName(path.getHost().getProtocol().disk(), size)); } if (path.attributes().isDirectory()) { if (OverlayFolderImage) { if (!path.attributes().getPermission().isExecutable() || (path.isCached() && !path.cache().get(path.getReference()).attributes().isReadable())) { return(IconForFolder(IconForName("privatefolderbadge", size), size)); } if (!path.attributes().getPermission().isReadable()) { if (path.attributes().getPermission().isWritable()) { return(IconForFolder(IconForName("dropfolderbadge", size), size)); } } if (!path.attributes().getPermission().isWritable()) { return(IconForFolder(IconForName("readonlyfolderbadge", size), size)); } } return(IconForFolder(size)); } return(ResizeImage(IconForName("notfound", size), size)); }
/// <summary> /// Get file extension. Ignores OS specific special characters. Includes the dot if available. /// </summary> /// <param name="filename"></param> /// <returns></returns> public static string GetSafeExtension(string filename) { if (IsNotBlank(filename)) { //see http://windevblog.blogspot.com/2008/09/get-default-application-in-windows-xp.html string extension = Path.getExtension(filename); if (IsBlank(extension)) { return(String.Empty); } return("." + extension); } return(String.Empty); }