The input path must be absolute, but normalize-path can't be used, because
that returns UNC path, and SHFileOperation fails on any path prefixed with
"\\?", see https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shfileopstructa
Use absolute-path instead. The mixture of slashes and backslashes in the
path is tolerated, at least on Windows 10.
Add a simple unit-test.
--- /dev/null
+! Copyright (C) 2020 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.directories io.files.trash kernel tools.test ;
+IN: io.files.trash.tests
+
+{ } [
+ ! temp-file is not used here, because it returns the absolute path, and we
+ ! want to ensure send-to-trash works without giving it the full path.
+ [ "io.files.trash-tests" dup touch-file send-to-trash ] with-test-directory
+] unit-test
! See http://factorcode.org/license.txt for BSD license
USING: accessors alien.c-types alien.data alien.strings
-alien.syntax classes.struct destructors io.files.trash kernel
-libc literals math sequences system windows.types ;
+alien.syntax classes.struct destructors io.files.trash
+io.pathnames kernel libc literals math sequences system
+windows.types ;
IN: io.files.trash.windows
M: windows send-to-trash ( path -- )
[
- native-string>alien B{ 0 0 } append
+ absolute-path native-string>alien B{ 0 0 } append
malloc-byte-array &free
SHFILEOPSTRUCTW <struct>