]> gitweb.factorcode.org Git - factor.git/commitdiff
wipe.windows: move Windows-specific functionality to the new vocab
authorAlexander Ilin <alex.ilin@protonmail.com>
Mon, 14 Aug 2023 21:41:27 +0000 (23:41 +0200)
committerAlexander Ilin <alex.ilin@protonmail.com>
Mon, 14 Aug 2023 21:42:06 +0000 (23:42 +0200)
extra/wipe/windows/authors.txt [new file with mode: 0644]
extra/wipe/windows/platforms.txt [new file with mode: 0644]
extra/wipe/windows/windows.factor [new file with mode: 0644]
extra/wipe/wipe.factor

diff --git a/extra/wipe/windows/authors.txt b/extra/wipe/windows/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/extra/wipe/windows/platforms.txt b/extra/wipe/windows/platforms.txt
new file mode 100644 (file)
index 0000000..8e1a559
--- /dev/null
@@ -0,0 +1 @@
+windows
diff --git a/extra/wipe/windows/windows.factor b/extra/wipe/windows/windows.factor
new file mode 100644 (file)
index 0000000..5f06f1b
--- /dev/null
@@ -0,0 +1,11 @@
+! 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 ;
index 1f1ae29207b640337ffa252eef3da17552ccd232..81f290383ffc9dffd4b88fc188f82351c2b558bc 100644 (file)
@@ -2,17 +2,15 @@
 ! 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 [