--- /dev/null
+! Copyright (C) 2023 Alexander Ilin.
+! See https://factorcode.org/license.txt for BSD license.
+USING: io.files.windows kernel math windows.kernel32 ;
+IN: wipe.windows
+
+: extract-bit ( n mask -- n' ? )
+ [ bitnot bitand ] [ bitand 0 = not ] bi-curry bi ; inline
+
+: remove-read-only ( file-name -- )
+ dup GetFileAttributesW FILE_ATTRIBUTE_READONLY extract-bit
+ [ set-file-attributes ] [ 2drop ] if ;
! See https://factorcode.org/license.txt for BSD license.
USING: accessors
io io.directories io.encodings.binary io.files io.files.info
-io.files.unique io.files.windows io.streams.limited
-io.streams.random
-kernel math namespaces random windows.kernel32 ;
+io.files.unique io.streams.limited io.streams.random
+kernel math namespaces random system vocabs ;
IN: wipe
-: extract-bit ( n mask -- n' ? )
- [ bitnot bitand ] [ bitand 0 = not ] bi-curry bi ; inline
-
: remove-read-only ( file-name -- )
- dup GetFileAttributesW FILE_ATTRIBUTE_READONLY extract-bit
- [ set-file-attributes ] [ 2drop ] if ;
+ drop ; ! Do nothing by default.
+
+! Load a Windows-specific implementation of remove-read-only.
+os windows? [ "wipe.windows" require ] when
: overwrite-with-random-bytes ( file-name -- )
[ remove-read-only ] [ file-info size>> ] [ ] tri binary [