         
         let task = NSTask()
         task.launchPath = "/usr/bin/env"
-        task.arguments = ["unzip", file, "-d", target]
+        task.arguments = ["unzip", "-o", file, "-d", target]
         task.launch()
         task.waitUntilExit()
         

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!


    func applicationDidFinishLaunching(aNotification: NSNotification) {
//        let u = NSURL(string: "http://donnees.ville.montreal.qc.ca/dataset/37450231-e4d4-4e9c-99b3-5e88afa6e053/resource/67a95c30-4e21-4346-83f7-491d4ca54a7e/download/cataloguebibliotheque.zip")!

            return nil
        }
        
        let csv = NSFileManager.defaultManager().enumeratorAtPath(target)?.allObjects.filter({file -> Bool in
            println("Current file in extracted folder is \(file)")

            return (file as String).pathExtension == "csv"
        }).first as NSString?
        
        return csv != nil ? target.stringByAppendingPathComponent(csv!) : nil
    }
    
    func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) {
        switch eventCode {
        case NSStreamEvent.OpenCompleted:
            println("Stream has opened")
            buffer = NSMutableData()
            break
        case NSStreamEvent.EndEncountered:
            println("Stream has reached end")
            break
        case NSStreamEvent.HasBytesAvailable:
            println("Stream has bytes available")
            
            let bufferSize = 1024
            var localBuffer = Array<UInt8>(count: bufferSize, repeatedValue: 0)
            
            let read = (aStream as NSInputStream).read(&localBuffer, maxLength: bufferSize)
            println("Read \(read) bytes")
            buffer.appendBytes(localBuffer, length: localBuffer.count)
            
            break
        default:
            println("Not handling stream event: \(eventCode)")
            
            
        }
    }
}

