motion/cdq/store.rb in cdq-0.1.8 vs motion/cdq/store.rb in cdq-0.1.9

- old
+ new

@@ -31,10 +31,11 @@ coordinator = NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(@model_manager.current) error = Pointer.new(:object) options = { NSMigratePersistentStoresAutomaticallyOption => true, NSInferMappingModelAutomaticallyOption => true } url = @config.database_url + mkdir_p File.dirname(url.path) store = coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration:nil, URL:url, options:options, error:error) @@ -45,8 +46,19 @@ raise error[0].userInfo['reason'] end coordinator end end + + def mkdir_p dir + error = Pointer.new(:object) + m = NSFileManager.defaultManager + r = m.createDirectoryAtPath dir, withIntermediateDirectories:true, attributes:nil, error:error + unless r + NSLog "#{error[0].localizedDescription}" + raise error[0].localizedDescription + end + end + end end