     var updatesMenuItem: NSMenuItem = NSMenuItem()
     
     override init() {
+
+        let appSupport = URL(fileURLWithPath: AppDelegate.userApplicationSupportDirectory)
+
+        // App version follows mongoDB version. Add it to the directory
+        guard let appVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
+            fatalError("Unable to determine application version from Info.plist")
+        }
+
+        let dataDirectory = appSupport
+            .appendingPathComponent(appName)
+            .appendingPathComponent(appVersion)
+
+        self.dataPath = dataDirectory.appendingPathComponent("Data").path
+        self.logPath = dataDirectory.appendingPathComponent("Logs").path
+
         self.file = self.pipe.fileHandleForReading
-        self.documentsDirectory = self.paths[0] as AnyObject
-        self.dataPath = documentsDirectory.appendingPathComponent("MongoData")
-        self.logPath = documentsDirectory.appendingPathComponent("MongoData/Logs")
-        
+
         super.init()
     }
     

//  Copyright (c) 2015 Giovanni Collazo. All rights reserved.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
    @IBOutlet weak var updater: SUUpdater!
    
    var paths = NSSearchPathForDirectoriesInDomains(
        FileManager.SearchPathDirectory.documentDirectory,
        FileManager.SearchPathDomainMask.userDomainMask, true)
    
    var documentsDirectory: AnyObject
    var dataPath: String
    var logPath: String
    

        if (!FileManager.default.fileExists(atPath: self.dataPath)) {
            do {
                try FileManager.default
                    .createDirectory(atPath: self.dataPath, withIntermediateDirectories: true, attributes: nil)
            } catch {
                print("Something went wrong creating dataPath: \(error)")
            }
        }

        if (!FileManager.default.fileExists(atPath: self.logPath)) {
            do {
                try FileManager.default
                    .createDirectory(atPath: self.logPath, withIntermediateDirectories: true, attributes: nil)
            } catch {
                print("Something went wrong creating logPath: \(error)")
            }
        }

