According to https://developer.gnome.org/gio/stable/gio.html I know that the following command used in the terminal work just fine :
Code: Select all
gio trash 'filename'
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : SendToTrash - Module
; File Name : SendToTrash - Module.pb
; File version: 0.0.0
; Programming : OK
; Programmed by : StarBootics
; Date : 11-08-2018
; Last Update : 21-03-2019
; PureBasic code : V5.70 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
DeclareModule SendToTrash
Declare DoIt(FileName.s)
EndDeclareModule
Module SendToTrash
Procedure DoIt(FileName.s)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
Protected lpFileOp.SHFILEOPSTRUCT
If FileSize(FileName) <> -1
If Right(FileName, 1) = "\"
FileName = Left(FileName, Len(FileName) - 1)
EndIf
Memory = AllocateMemory((Len(FileName)+2)*SizeOf(Character), 0)
If Memory
lpFileOp\hwnd = 0
lpFileOp\pTo = 0
lpFileOp\wFunc = #FO_DELETE
lpFileOp\pFrom = Memory
lpFileOp\fFlags = #FOF_ALLOWUNDO | #FOF_NOCONFIRMATION
PokeS(Memory, FileName)
SHFileOperation_(@lpFileOp)
FreeMemory(Memory)
EndIf
EndIf
CompilerCase #PB_OS_Linux
If FileSize(FileName) <> -1
RunProgram("gio", "trash " + #DQUOTE$ + FileName + #DQUOTE$, "")
EndIf
CompilerCase #PB_OS_MacOS
CompilerEndSelect
EndProcedure
EndModule
CompilerIf #PB_Compiler_IsMainFile
If CreateFile(0, GetCurrentDirectory() + "dummy.txt")
WriteString(0, "dummy text in a file to be deleted")
CloseFile(0)
SendToTrash::DoIt(GetCurrentDirectory() + "dummy.txt")
EndIf
CompilerEndIf
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Thanks beforehand.
StarBootics