Create .writeas dir on start if non-existent
This commit is contained in:
parent
cb93c3874f
commit
35133ae7c4
@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
330711A70F03BFB84FB889AB /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071648B80C4188CAC44CA1 /* Constants.swift */; };
|
||||||
33071D332D5799D36FBC1DDD /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3307150C0D2CA1C8A71C5E26 /* Preferences.swift */; };
|
33071D332D5799D36FBC1DDD /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3307150C0D2CA1C8A71C5E26 /* Preferences.swift */; };
|
||||||
C98EE9AC1F29532F002F646E /* writeas in Resources */ = {isa = PBXBuildFile; fileRef = C98EE9AB1F29532F002F646E /* writeas */; };
|
C98EE9AC1F29532F002F646E /* writeas in Resources */ = {isa = PBXBuildFile; fileRef = C98EE9AB1F29532F002F646E /* writeas */; };
|
||||||
C9953E7D1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C9953E791F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf */; };
|
C9953E7D1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C9953E791F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf */; };
|
||||||
@ -29,6 +30,7 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
3307150C0D2CA1C8A71C5E26 /* Preferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Preferences.swift; path = writeas/Preferences.swift; sourceTree = "<group>"; };
|
3307150C0D2CA1C8A71C5E26 /* Preferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Preferences.swift; path = writeas/Preferences.swift; sourceTree = "<group>"; };
|
||||||
|
33071648B80C4188CAC44CA1 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||||
C98EE9AB1F29532F002F646E /* writeas */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = writeas; sourceTree = "<group>"; };
|
C98EE9AB1F29532F002F646E /* writeas */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = writeas; sourceTree = "<group>"; };
|
||||||
C9953E791F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf"; sourceTree = "<group>"; };
|
C9953E791F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600.ttf"; sourceTree = "<group>"; };
|
||||||
C9953E7A1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600italic.ttf"; sourceTree = "<group>"; };
|
C9953E7A1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-600italic.ttf"; sourceTree = "<group>"; };
|
||||||
@ -107,6 +109,7 @@
|
|||||||
C99B91101C33841F00A91990 /* Assets.xcassets */,
|
C99B91101C33841F00A91990 /* Assets.xcassets */,
|
||||||
C99B91121C33841F00A91990 /* Main.storyboard */,
|
C99B91121C33841F00A91990 /* Main.storyboard */,
|
||||||
C99B91151C33841F00A91990 /* Info.plist */,
|
C99B91151C33841F00A91990 /* Info.plist */,
|
||||||
|
33071648B80C4188CAC44CA1 /* Constants.swift */,
|
||||||
);
|
);
|
||||||
path = writeas;
|
path = writeas;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -200,6 +203,7 @@
|
|||||||
C99B910F1C33841E00A91990 /* ViewController.swift in Sources */,
|
C99B910F1C33841E00A91990 /* ViewController.swift in Sources */,
|
||||||
C99B910D1C33841E00A91990 /* AppDelegate.swift in Sources */,
|
C99B910D1C33841E00A91990 /* AppDelegate.swift in Sources */,
|
||||||
33071D332D5799D36FBC1DDD /* Preferences.swift in Sources */,
|
33071D332D5799D36FBC1DDD /* Preferences.swift in Sources */,
|
||||||
|
330711A70F03BFB84FB889AB /* Constants.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
if vc == nil {
|
if vc == nil {
|
||||||
vc = NSApplication.shared().mainWindow?.contentViewController as? ViewController
|
vc = NSApplication.shared().mainWindow?.contentViewController as? ViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DispatchQueue.global(qos: .background).async {
|
||||||
|
if !FileManager.default.fileExists(atPath: Constants.draftDir, isDirectory: nil) {
|
||||||
|
do {
|
||||||
|
try FileManager.default.createDirectory(atPath: Constants.draftDir, withIntermediateDirectories: false, attributes: nil)
|
||||||
|
} catch let error as NSError {
|
||||||
|
print(error.localizedDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func toggleNightMode(_ sender: NSMenuItem) {
|
@IBAction func toggleNightMode(_ sender: NSMenuItem) {
|
||||||
|
11
writeas/Constants.swift
Normal file
11
writeas/Constants.swift
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// Created by Matt Baer on 8/2/17.
|
||||||
|
// Copyright (c) 2017 A Bunch Tell. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct Constants {
|
||||||
|
static let draftDir = "\(NSHomeDirectory())/.writeas"
|
||||||
|
static let draftFile = "\(draftDir)/draft.txt"
|
||||||
|
}
|
@ -12,7 +12,6 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe
|
|||||||
|
|
||||||
@IBOutlet var writerText: NSTextView!
|
@IBOutlet var writerText: NSTextView!
|
||||||
|
|
||||||
let draftFile = "\(NSHomeDirectory())/.writeas/draft.txt"
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
@ -56,7 +55,7 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func getDraftPath() -> URL? {
|
fileprivate func getDraftPath() -> URL? {
|
||||||
return URL(fileURLWithPath: draftFile)
|
return URL(fileURLWithPath: Constants.draftFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveDocument() {
|
func saveDocument() {
|
||||||
|
Loading…
Reference in New Issue
Block a user