source: launchers/macosx/I2PLauncher/userinterface/DownloadJavaViewController.swift @ e3ab9f8e

Last change on this file since e3ab9f8e was e3ab9f8e, checked in by meeh <meeh@…>, 20 months ago

OSX Launcher: Swift GUI code updates, most related to the new launch method.

  • Property mode set to 100644
File size: 1.0 KB
Line 
1//
2//  DownloadJavaViewController.swift
3//  I2PLauncher
4//
5//  Created by Mikal Villa on 30/09/2018.
6//  Copyright © 2018 The I2P Project. All rights reserved.
7//
8
9import AppKit
10
11class DownloadJavaViewController: NSViewController {
12 
13  func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask,
14                  didFinishDownloadingTo location: URL) {
15    guard let httpResponse = downloadTask.response as? HTTPURLResponse,
16      (200...299).contains(httpResponse.statusCode) else {
17        print ("server error")
18        return
19    }
20    do {
21      let documentsURL = try
22        FileManager.default.url(for: .documentDirectory,
23                                in: .userDomainMask,
24                                appropriateFor: nil,
25                                create: false)
26      let savedURL = documentsURL.appendingPathComponent(
27        location.lastPathComponent)
28      try FileManager.default.moveItem(at: location, to: savedURL)
29    } catch {
30      print ("file error: \(error)")
31    }
32  }
33 
34}
Note: See TracBrowser for help on using the repository browser.