Update to newer version of Swift: lastPathComponent now an optional
This commit is contained in:
parent
6d6215d47f
commit
9c138a3b6b
|
@ -109,8 +109,8 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||||
ASApplication.newProjectLocation(nil,
|
ASApplication.newProjectLocation(nil,
|
||||||
message: "Save editable copy of project \(template.lastPathComponent)")
|
message: "Save editable copy of project \(template.lastPathComponent)")
|
||||||
{ (saveTo) -> Void in
|
{ (saveTo) -> Void in
|
||||||
let oldName = template.lastPathComponent
|
let oldName = template.lastPathComponent!
|
||||||
let newName = saveTo.lastPathComponent
|
let newName = saveTo.lastPathComponent!
|
||||||
let fileManager = NSFileManager.defaultManager()
|
let fileManager = NSFileManager.defaultManager()
|
||||||
fileManager.copyItemAtURL(template, toURL: saveTo, error: nil)
|
fileManager.copyItemAtURL(template, toURL: saveTo, error: nil)
|
||||||
let contents = fileManager.enumeratorAtURL(saveTo,
|
let contents = fileManager.enumeratorAtURL(saveTo,
|
||||||
|
@ -118,7 +118,7 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||||
options: .SkipsHiddenFiles, errorHandler: nil)
|
options: .SkipsHiddenFiles, errorHandler: nil)
|
||||||
while let item = contents?.nextObject() as? NSURL {
|
while let item = contents?.nextObject() as? NSURL {
|
||||||
var renameItem = false
|
var renameItem = false
|
||||||
var itemName = item.lastPathComponent
|
var itemName = item.lastPathComponent!
|
||||||
if itemName.stringByDeletingPathExtension == oldName {
|
if itemName.stringByDeletingPathExtension == oldName {
|
||||||
renameItem = true
|
renameItem = true
|
||||||
itemName = newName.stringByAppendingPathExtension(itemName.pathExtension)!
|
itemName = newName.stringByAppendingPathExtension(itemName.pathExtension)!
|
||||||
|
@ -159,12 +159,12 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||||
{ (saveTo) -> Void in
|
{ (saveTo) -> Void in
|
||||||
let fileManager = NSFileManager.defaultManager()
|
let fileManager = NSFileManager.defaultManager()
|
||||||
fileManager.createDirectoryAtURL(saveTo, withIntermediateDirectories:false, attributes:nil, error:nil)
|
fileManager.createDirectoryAtURL(saveTo, withIntermediateDirectories:false, attributes:nil, error:nil)
|
||||||
let proj = saveTo.URLByAppendingPathComponent(saveTo.lastPathComponent+".avrsackproj")
|
let proj = saveTo.URLByAppendingPathComponent(saveTo.lastPathComponent!+".avrsackproj")
|
||||||
let docController = NSDocumentController.sharedDocumentController() as NSDocumentController
|
let docController = NSDocumentController.sharedDocumentController() as NSDocumentController
|
||||||
if let doc = docController.openUntitledDocumentAndDisplay(true, error:nil) as? ASProjDoc {
|
if let doc = docController.openUntitledDocumentAndDisplay(true, error:nil) as? ASProjDoc {
|
||||||
doc.fileURL = proj
|
doc.fileURL = proj
|
||||||
doc.updateProjectURL()
|
doc.updateProjectURL()
|
||||||
doc.createFileAtURL(saveTo.URLByAppendingPathComponent(saveTo.lastPathComponent+".ino"))
|
doc.createFileAtURL(saveTo.URLByAppendingPathComponent(saveTo.lastPathComponent!+".ino"))
|
||||||
doc.writeToURL(proj, ofType: "Project", forSaveOperation: .SaveAsOperation, originalContentsURL: nil, error: nil)
|
doc.writeToURL(proj, ofType: "Project", forSaveOperation: .SaveAsOperation, originalContentsURL: nil, error: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ASBuilder {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
args.append("toolchain="+toolChain)
|
args.append("toolchain="+toolChain)
|
||||||
args.append("project="+dir.lastPathComponent)
|
args.append("project="+dir.lastPathComponent!)
|
||||||
args.append("board="+board)
|
args.append("board="+board)
|
||||||
args.append("mcu="+boardProp["build.mcu"]!)
|
args.append("mcu="+boardProp["build.mcu"]!)
|
||||||
args.append("f_cpu="+boardProp["build.f_cpu"]!)
|
args.append("f_cpu="+boardProp["build.f_cpu"]!)
|
||||||
|
@ -143,7 +143,7 @@ class ASBuilder {
|
||||||
if hasBootloader {
|
if hasBootloader {
|
||||||
args += ["-D"]
|
args += ["-D"]
|
||||||
}
|
}
|
||||||
args += ["-U", "flash:w:build/"+board+"/"+dir.lastPathComponent+".hex:i"]
|
args += ["-U", "flash:w:build/"+board+"/"+dir.lastPathComponent!+".hex:i"]
|
||||||
continuation = {
|
continuation = {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(2*NSEC_PER_SEC)), dispatch_get_main_queue(), {
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(2*NSEC_PER_SEC)), dispatch_get_main_queue(), {
|
||||||
ASSerialWin.portAvailableAfterUpload(port)
|
ASSerialWin.portAvailableAfterUpload(port)
|
||||||
|
@ -245,7 +245,7 @@ class ASBuilder {
|
||||||
|
|
||||||
let showSource = NSUserDefaults.standardUserDefaults().boolForKey("ShowSourceInDisassembly")
|
let showSource = NSUserDefaults.standardUserDefaults().boolForKey("ShowSourceInDisassembly")
|
||||||
var args = showSource ? ["-S"] : []
|
var args = showSource ? ["-S"] : []
|
||||||
args += ["-d", "build/"+board+"/"+dir.lastPathComponent+".elf"]
|
args += ["-d", "build/"+board+"/"+dir.lastPathComponent!+".elf"]
|
||||||
let cmdLine = task!.launchPath+" "+(args as NSArray).componentsJoinedByString(" ")+"\n"
|
let cmdLine = task!.launchPath+" "+(args as NSArray).componentsJoinedByString(" ")+"\n"
|
||||||
logOut.writeData(cmdLine.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)
|
logOut.writeData(cmdLine.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)
|
||||||
task!.arguments = args;
|
task!.arguments = args;
|
||||||
|
|
|
@ -18,7 +18,7 @@ enum ASFileType : String {
|
||||||
case Markdown = "doc.md"
|
case Markdown = "doc.md"
|
||||||
|
|
||||||
static func guessForURL(url: NSURL) -> ASFileType {
|
static func guessForURL(url: NSURL) -> ASFileType {
|
||||||
switch url.pathExtension.lowercaseString {
|
switch url.pathExtension!.lowercaseString {
|
||||||
case "hpp", "hh", "h":
|
case "hpp", "hh", "h":
|
||||||
return .Header
|
return .Header
|
||||||
case "c":
|
case "c":
|
||||||
|
@ -172,7 +172,7 @@ class ASFileItem : ASFileNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override func nodeName() -> String {
|
override func nodeName() -> String {
|
||||||
return "📄 "+url.lastPathComponent
|
return "📄 "+url.lastPathComponent!
|
||||||
}
|
}
|
||||||
|
|
||||||
func relativePath(relativeTo: String) -> String {
|
func relativePath(relativeTo: String) -> String {
|
||||||
|
@ -222,7 +222,7 @@ class ASFileTree : NSObject, NSOutlineViewDataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func setProjectURL(url: NSURL) {
|
func setProjectURL(url: NSURL) {
|
||||||
root.name = url.lastPathComponent.stringByDeletingPathExtension
|
root.name = url.lastPathComponent!.stringByDeletingPathExtension
|
||||||
dir = url.URLByDeletingLastPathComponent!.standardizedURL!
|
dir = url.URLByDeletingLastPathComponent!.standardizedURL!
|
||||||
}
|
}
|
||||||
func apply(closure: (ASFileNode) -> ()) {
|
func apply(closure: (ASFileNode) -> ()) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
|
||||||
}
|
}
|
||||||
|
|
||||||
func importProject(url: NSURL, error outError: NSErrorPointer) -> Bool {
|
func importProject(url: NSURL, error outError: NSErrorPointer) -> Bool {
|
||||||
let existingProject = url.URLByAppendingPathComponent(url.lastPathComponent+".avrsackproj")
|
let existingProject = url.URLByAppendingPathComponent(url.lastPathComponent!+".avrsackproj")
|
||||||
if existingProject.checkResourceIsReachableAndReturnError(nil) {
|
if existingProject.checkResourceIsReachableAndReturnError(nil) {
|
||||||
fileURL = existingProject
|
fileURL = existingProject
|
||||||
return readFromURL(existingProject, ofType:"Project", error:outError)
|
return readFromURL(existingProject, ofType:"Project", error:outError)
|
||||||
|
@ -424,8 +424,8 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
|
||||||
let dateFmt = NSDateFormatter()
|
let dateFmt = NSDateFormatter()
|
||||||
dateFmt.dateFormat = "yyyy-MM-dd"
|
dateFmt.dateFormat = "yyyy-MM-dd"
|
||||||
header = firstPfx + "\n" +
|
header = firstPfx + "\n" +
|
||||||
prefix + " Project: " + fileURL!.URLByDeletingLastPathComponent!.lastPathComponent + "\n" +
|
prefix + " Project: " + fileURL!.URLByDeletingLastPathComponent!.lastPathComponent! + "\n" +
|
||||||
prefix + " File: " + url.lastPathComponent + "\n" +
|
prefix + " File: " + url.lastPathComponent! + "\n" +
|
||||||
prefix + " Created: " + dateFmt.stringFromDate(NSDate()) + "\n" +
|
prefix + " Created: " + dateFmt.stringFromDate(NSDate()) + "\n" +
|
||||||
lastPfx + "\n\n"
|
lastPfx + "\n\n"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user