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 ? ) { 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 = await window . showInformationMessage ( message , { modal : true } , confirmMessage ) ; if ( answer === confirmMessage ) { workspace . fs . delete ( Uri . parse ( node . uri ) , { recursive : true , useTrash : true , } ) ; } } function getInformationMessage ( name , isFolder ) { 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 ; }