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