io.files.trash.windows: convert input path to absolute in send-to-trash
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.master
parent
595cf81eb8
commit
a06e9cc3b2
|
@ -0,0 +1,10 @@
|
|||
! 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
|
|
@ -2,8 +2,9 @@
|
|||
! 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
|
||||
|
||||
|
@ -51,7 +52,7 @@ PRIVATE>
|
|||
|
||||
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>
|
||||
|
|
Loading…
Reference in New Issue