aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models/FileInfo.swift
blob: 0e2c76d17b0c246547d9c1aaf32ffa1e861a4108 (plain)
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
import SwiftUI

@Observable class FileInfo: Identifiable {
  let id: UUID = UUID()
  
  let path: [String]
  let name: String
  
  let type: String
  let creator: String
  let fileSize: UInt
  
  let isFolder: Bool
  var children: [FileInfo]? = nil
  
  init(hotlineFile: HotlineFile) {
    self.path = hotlineFile.path
    self.name = hotlineFile.name
    self.type = hotlineFile.type
    self.creator = hotlineFile.creator
    self.fileSize = UInt(hotlineFile.fileSize)
    self.isFolder = hotlineFile.isFolder
    if self.isFolder {
      self.children = []
    }
  }
  
  static func == (lhs: FileInfo, rhs: FileInfo) -> Bool {
    return lhs.id == rhs.id
  }
}