27 lines
666 B
Swift
27 lines
666 B
Swift
//
|
|
// Shared.swift
|
|
// Docsis Toolkit
|
|
//
|
|
// Created by Kilian Hofmann on 15.06.17.
|
|
// Copyright © 2017 Kilian Hofmann. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
func log(_ entry: String, path: String) {
|
|
let file: FileHandle? = FileHandle(forUpdatingAtPath: path)
|
|
if file == nil {
|
|
do{
|
|
try (entry).write(toFile: path, atomically: true, encoding: String.Encoding.utf8)
|
|
}
|
|
catch {
|
|
NSLog("WRITE TO FILE FAILED\n");
|
|
}
|
|
} else {
|
|
file?.seekToEndOfFile();
|
|
let data = (entry as NSString).data(using: String.Encoding.utf8.rawValue)
|
|
file?.write(data!)
|
|
file?.closeFile()
|
|
}
|
|
}
|