Fix project import

This commit is contained in:
Matthias Neeracher 2014-12-22 07:00:05 +01:00 committed by Matthias Neeracher
parent 8bc7fa53f4
commit beb70e0158
2 changed files with 8 additions and 3 deletions

View File

@ -162,7 +162,11 @@ class ASFileItem : ASFileNode {
}
init(_ prop: NSDictionary, withRootURL rootURL: NSURL) {
type = ASFileType(rawValue: prop[kKindKey] as String)!
url = NSURL(string: prop[kPathKey] as NSString, relativeToURL: rootURL)!.standardizedURL!
if let relativeURL = NSURL(string: prop[kPathKey] as NSString, relativeToURL: rootURL) {
url = relativeURL.standardizedURL!
} else {
url = NSURL(fileURLWithPath: prop[kPathKey] as NSString)!.standardizedURL!
}
}
override func nodeName() -> String {
return "📄 "+url.lastPathComponent

View File

@ -166,6 +166,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
let filesInProject =
NSFileManager.defaultManager().contentsOfDirectoryAtURL(url, includingPropertiesForKeys: nil,
options: .SkipsHiddenFiles, error: nil)!
files.setProjectURL(fileURL!)
for file in filesInProject {
files.addFileURL(file as NSURL)
}
@ -178,8 +179,8 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
let projectURL = url.URLByDeletingPathExtension!.URLByAppendingPathExtension("avrsackproj")
success = importProject(url.URLByDeletingLastPathComponent!, error: outError)
if success {
files.setProjectURL(fileURL!)
builder.setProjectURL(fileURL!)
files.setProjectURL(projectURL)
builder.setProjectURL(projectURL)
fileURL = projectURL
success = writeToURL(projectURL, ofType: "Project", forSaveOperation: .SaveAsOperation, originalContentsURL: nil, error: outError)
}