forked from microsoft/vscode-java-dependency
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.ts
More file actions
38 lines (31 loc) · 1.18 KB
/
Copy pathdelete.ts
File metadata and controls
38 lines (31 loc) · 1.18 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { Uri, window, workspace } from "vscode";
import { DataNode } from "../views/dataNode";
import { isMutable } from "./utility";
const confirmMessage = "Move to Recycle Bin";
export async function deleteFiles(node?: DataNode): Promise<void> {
if (!node?.uri || !isMutable(node)) {
return;
}
const children = await node.getChildren();
const isFolder = children && children.length !== 0;
const message = getInformationMessage(node.name, isFolder);
const answer: string | undefined = await window.showInformationMessage(
message,
{ modal: true },
confirmMessage,
);
if (answer === confirmMessage) {
workspace.fs.delete(Uri.parse(node.uri), {
recursive: true,
useTrash: true,
});
}
}
function getInformationMessage(name: string, isFolder: boolean): string {
const folderMsg = isFolder ? " and its contents" : "";
const msg = `Are you sure you want to delete \'${name}\'${folderMsg}?\n\n`;
const additionMsg = "You can restore from the Recycle Bin.";
return msg + additionMsg;
}