-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrsCopy.swift
More file actions
52 lines (38 loc) · 1.07 KB
/
Copy pathrsCopy.swift
File metadata and controls
52 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Foundation
var path = "/Users/alphabo/temp/CodingRoadmap/"
var src = "/Users/alphabo/temp/CodingRoadmap/src/"
var dest = "/Users/alphabo/temp/"
let fm = FileManager.default
var fileURLs: [String] = []
do {
let items = try fm.contentsOfDirectory(atPath: path)
for item in items {
print("Found \(item)")
}
} catch {
// failed to read directory – bad permissions, perhaps?
}
let s = fm.subpaths(atPath: src)
print(s!)
//for i in s! {
// do {
// try fm.copyItem(atPath: src + i, toPath: dest + i)
// } catch (let error) {
// print("Cannot copy item at \(src) to \(dest): \(error)")
// }
//}
//if let dirContents = FileManager.default.enumerator(atPath: src) {
//
// for i in dirContents {
// print(i)
// }
//}
let srcUrl = URL(string: "file://" + src + "0/0.txt")!
let destUrl = URL(string: "file://" + dest)!
do {
try fm.copyItem(at: destUrl, to: srcUrl)
} catch (let error) {
print("Cannot copy item at \(src) to \(dest): \(error)")
}
//let directory = fm.temporaryDirectory
//print(directory.debugDescription)