@@ -93,30 +93,11 @@ extension CEWorkspaceFileManager {
93
93
/// - file: The file or folder to delete
94
94
/// - Authors: Paul Ebose
95
95
public func trash( file: CEWorkspaceFile ) {
96
- let message : String
97
-
98
- if !file. isFolder || file. isEmptyFolder { // if its a file or an empty folder, call it by its name
99
- message = file. name
100
- } else {
101
- let fileCount = fileManager. enumerator ( atPath: file. url. path) ? . allObjects. count
102
- message = " the \( ( fileCount ?? 0 ) + 1 ) selected items "
103
- }
104
-
105
- let moveFileToTrashAlert = NSAlert ( )
106
- moveFileToTrashAlert. messageText = " Do you want to move \( message) to Trash? "
107
- moveFileToTrashAlert. informativeText = " This operation cannot be undone. "
108
- moveFileToTrashAlert. alertStyle = . critical
109
- moveFileToTrashAlert. addButton ( withTitle: " Move to Trash " )
110
- moveFileToTrashAlert. buttons. last? . hasDestructiveAction = true
111
- moveFileToTrashAlert. addButton ( withTitle: " Cancel " )
112
-
113
- if moveFileToTrashAlert. runModal ( ) == . alertFirstButtonReturn { // "Move to Trash" button
114
- if fileManager. fileExists ( atPath: file. url. path) {
115
- do {
116
- try fileManager. trashItem ( at: file. url, resultingItemURL: nil )
117
- } catch {
118
- print ( error. localizedDescription)
119
- }
96
+ if fileManager. fileExists ( atPath: file. url. path) {
97
+ do {
98
+ try fileManager. trashItem ( at: file. url, resultingItemURL: nil )
99
+ } catch {
100
+ print ( error. localizedDescription)
120
101
}
121
102
}
122
103
}
@@ -129,30 +110,11 @@ extension CEWorkspaceFileManager {
129
110
public func delete( file: CEWorkspaceFile , confirmDelete: Bool = true ) {
130
111
// This function also has to account for how the
131
112
// - file system can change outside of the editor
132
- let messageText : String
133
- let informativeText : String
134
-
135
- if !file. isFolder || file. isEmptyFolder { // if its a file or an empty folder, call it by its name
136
- messageText = " Are you sure you want to delete \" \( file. name) \" ? "
137
- informativeText = " This item will be deleted immediately. You can't undo this action. "
138
- } else {
139
- let childrenCount = try ? fileManager. contentsOfDirectory (
140
- at: file. url,
141
- includingPropertiesForKeys: nil
142
- ) . count
143
-
144
- if let childrenCount {
145
- messageText = " Are you sure you want to delete the \( ( childrenCount) + 1 ) selected items? "
146
- informativeText = " \( childrenCount) items will be deleted immediately. You can't undo this action. "
147
- } else {
148
- messageText = " Are you sure you want to delete the selected items? "
149
- informativeText = " Selected items will be deleted immediately. You can't undo this action. "
150
- }
151
- }
113
+ let fileName = file. name
152
114
153
115
let deleteConfirmation = NSAlert ( )
154
- deleteConfirmation. messageText = messageText
155
- deleteConfirmation. informativeText = informativeText
116
+ deleteConfirmation. messageText = " Do you want to delete “ \( fileName ) ”? "
117
+ deleteConfirmation. informativeText = " This item will be deleted immediately. You can't undo this action. "
156
118
deleteConfirmation. alertStyle = . critical
157
119
deleteConfirmation. addButton ( withTitle: " Delete " )
158
120
deleteConfirmation. buttons. last? . hasDestructiveAction = true
0 commit comments