743 proc move_to_trash {fname isdir} {
749 switch -glob $::tcl_platform(os) {
752 set cmd "tell app \"Finder\" to move the POSIX file \"$fname\" to trash"
753 if {[
catch {
exec -ignorestderr osascript -e $cmd} rc]} {
754 return -code error $rc
761 if {![
catch {
exec -ignorestderr which gio 2>@1}]} {
762 if {[
catch {
exec -ignorestderr gio trash $fname} rc]} {
763 return -code error $rc
767 }
elseif {![
catch {
exec -ignorestderr which gvfs-trash 2>@1}]} {
768 if {[
catch {
exec -ignorestderr gvfs-trash $fname} rc]} {
769 return -code error $rc
773 }
elseif {![
catch {
exec -ignorestderr which kioclient 2>@1}]} {
774 if {[
catch {
exec -ignorestderr kioclient move $fname trash:/} rc]} {
775 return -code error $rc
779 }
elseif {[
file exists [
set trash [
file join ~ .local share Trash]]]} {
780 if {[
info exists ::env(XDG_DATA_HOME)] && ($::env(XDG_DATA_HOME) ne "") && [
file exists $::env(XDG_DATA_HOME)]} {
781 set trash $::env(XDG_DATA_HOME)
783 set trash_path [
get_unique_path [
file join $trash files] [
file tail $fname]]
784 if {![
catch { open [
file join $trash info [
file tail $trash_path].trashinfo] w} rc]} {
785 puts $rc "\[Trash Info\]"
786 puts $rc "Path=$fname"
787 puts $rc "DeletionDate=[
clock format [
clock seconds] -format {%Y-%m-%dT%T}]"
790 return -code error $rc
792 }
elseif {[
file exists [
set trash [
file join ~ .Trash]]]} {
793 set trash_path [
get_unique_path [
file join $trash files] [
file tail $fname]]
795 return -code error [msgcat::mc "Unable to determine how to move to trash"]
800 set binit [
file join $::tke_dir Win binit binit.exe]
801 if {[
namespace exists ::freewrap] && [zvfs::exists $binit]} {
802 if {[
catch {
exec -ignorestderr [freewrap::unpack $binit] [
file normalize $fname]} rc]} {
803 return -code error $rc
807 }
elseif {[
file exists $binit]} {
808 if {[
catch {
exec -ignorestderr $binit [
file normalize $fname]} rc]} {
809 return -code error $rc
813 }
elseif {[
file exists [
file join C: RECYCLER]]} {
814 set trash_path [
file join C: RECYCLER]
815 }
elseif {[
file exists [
file join C: {$Recycle.bin}]]} {
816 set trash_path [
file join C: {$Recycle.bin}]
818 return -code error [msgcat::mc "Unable to determine how to move to trash"]
823 return -code error [msgcat::mc "Unable to determine platform"]
829 if {[
catch {
file rename -force $fname $trash_path} rc]} {
830 return -code error $rc