File: programming/cocoa/Filie.zip/Filie/Filie/UKFolderDataSource.m


/* =============================================================================
    PROJECT:    Filie
    FILE:       UKFolderDataSource.m
    
    COPYRIGHT:  (c) 2004 by M. Uli Kusterer, all rights reserved.
    
    AUTHORS:    M. Uli Kusterer - UK
    
    LICENSES:   GNU GPL
    
    REVISIONS:
        2004-12-10  UK  Created.
   ========================================================================== */
 
// -----------------------------------------------------------------------------
//  Headers:
// -----------------------------------------------------------------------------
 
#import "UKFolderDataSource.h"
#import "UKDirectoryEnumerator.h"
#import "IconKit.h"
#import "NSWorkspace+PreviewFile.h"
#import "NSImage+NiceScaling.h"
// -----------------------------------------------------------------------------
//  initWithURL:
//      Create a data source for the folder at the specified URL. This uses a
//      path internally because, obviously, a folder data source always deals
//      in local files, so there's no need to mess with URLs anymore.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//  reload:
//      Request from the data source that it send the delegate its list of files.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//  delegate:
//      Accessor for delegate to get messages during reload:.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//  setDelegate:
//      Mutator for delegate to get messages during reload:.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//  placeholderIconForItem:attributes:
//      Quickly returns a temporary placeholder icon to use for the files
//      until their icons have been loaded. This simply returns generic file
//      and folder icons. We could probably get a tad fancier here and make
//      file packages look like files and not folders, or maybe even do a simple
//      icon resolution based on the suffix/type/creator already.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//  iconForItem:attributes:
//      Returns the actual icon associated with a file, including any icon
//      preview, custom icon or whatever. This is called from a separate thread,
//      so it isn't dangerous if this is a little slower.
//
//  REVISIONS:
//      2004-12-23  UK  Documented.
// -----------------------------------------------------------------------------
// Folders always go through full icon retrieval, otherwise /Library etc. get generic icons.
// SymLinks always go through full icon retrieval, otherwise they get generic icons.
// Couldn't generate a preview, although we want icon previews, and no custom icon?
"jpg""jpeg"] )  // Don't try JPEGs again. If EPEG couldn't do them, they might be corrupt and Cocoa would silently give us an empty image, while we'd prefer it just told us it failed.
    {
        // Load the full file and manually cobble together a preview:
//fileIcon = [fileIcon scaledImageToFitSize: iconSize];
// Still no icon?
// Ask Icon Services for an icon.
 

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.