]> gitweb.factorcode.org Git - factor.git/commitdiff
basis/extra: move tools.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 3 Apr 2020 00:06:50 +0000 (17:06 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 3 Apr 2020 00:06:50 +0000 (17:06 -0700)
basis/tools/directory-to-file/authors.txt [deleted file]
basis/tools/directory-to-file/directory-to-file.factor [deleted file]
basis/tools/file-to-directory/authors.txt [deleted file]
basis/tools/file-to-directory/file-to-directory.factor [deleted file]
extra/tools/directory-to-file/authors.txt [new file with mode: 0644]
extra/tools/directory-to-file/directory-to-file.factor [new file with mode: 0644]
extra/tools/file-to-directory/authors.txt [new file with mode: 0644]
extra/tools/file-to-directory/file-to-directory.factor [new file with mode: 0644]

diff --git a/basis/tools/directory-to-file/authors.txt b/basis/tools/directory-to-file/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/basis/tools/directory-to-file/directory-to-file.factor b/basis/tools/directory-to-file/directory-to-file.factor
deleted file mode 100644 (file)
index e8bc9c0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-! Copyright (C) 2018 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: base91 combinators command-line escape-strings fry
-io.backend io.directories io.directories.search
-io.encodings.binary io.encodings.utf8 io.files io.files.info
-io.pathnames kernel locals math namespaces sequences
-sequences.extras splitting ;
-IN: tools.directory-to-file
-
-: file-is-text? ( path -- ? )
-    binary file-contents [ 127 < ] all? ;
-
-: directory-repr ( path -- obj )
-    escape-simplest
-    "DIRECTORY: " prepend ;
-
-: file-repr ( path string -- obj )
-    [ escape-simplest "FILE:: " prepend ] dip " " glue ;
-
-:: directory-to-string ( path -- string )
-    path normalize-path
-    [ path-separator = ] trim-tail "/" append
-    [ recursive-directory-files ] keep
-    dup '[
-        [ _  ?head drop ] map
-        [
-            {
-                { [ dup file-info directory? ] [ directory-repr ] }
-                { [ dup file-is-text? ] [ dup utf8 file-contents escape-string file-repr ] }
-                [
-                    dup binary file-contents >base91
-                    "" like escape-string
-                    "base91" prepend file-repr
-                ]
-            } cond
-        ] map
-    ] with-directory
-    "\n\n" join
-    "<DIRECTORY: " path escape-simplest "\n\n" 3append
-    "\n\n;DIRECTORY>" surround ;
-
-: directory-to-file ( path -- )
-    [ directory-to-string ] keep ".modern" append
-    utf8 set-file-contents ;
-
-: directory-to-file-main ( -- )
-    command-line get dup length 1 = [ "oops" throw ] unless first
-    directory-to-file ;
-
-MAIN: directory-to-file-main
diff --git a/basis/tools/file-to-directory/authors.txt b/basis/tools/file-to-directory/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/basis/tools/file-to-directory/file-to-directory.factor b/basis/tools/file-to-directory/file-to-directory.factor
deleted file mode 100644 (file)
index fed7027..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-! Copyright (C) 2018 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: base91 combinators command-line fry io.directories
-io.encodings.binary io.encodings.utf8 io.files io.pathnames
-kernel modern modern.out namespaces sequences splitting strings ;
-IN: tools.file-to-directory
-
-ERROR: expected-one-path got ;
-ERROR: expected-modern-path got ;
-
-: write-directory-files ( path -- )
-    [ ".modern" ?tail drop dup make-directories ]
-    [ path>literals ] bi
-    '[
-        _ first second rest [
-            dup first "DIRECTORY:" head?
-            [ second first second >string make-directories ]
-            [
-                second first2
-                [ second >string ] [
-                    first3 nip swap "base91" head? [
-                        base91> binary
-                    ] [
-                        utf8
-                    ] if
-                ] bi* swapd
-                [ dup parent-directory make-directories ] dip set-file-contents
-            ] if
-        ] each
-    ] with-directory ;
-
-: get-file-to-directory-path ( array -- path )
-    dup length 1 = [ expected-one-path ] unless
-    first dup ".modern" tail? [ expected-modern-path ] unless ;
-
-: file-to-directory ( -- )
-    command-line get get-file-to-directory-path write-directory-files ;
-
-MAIN: file-to-directory
diff --git a/extra/tools/directory-to-file/authors.txt b/extra/tools/directory-to-file/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/tools/directory-to-file/directory-to-file.factor b/extra/tools/directory-to-file/directory-to-file.factor
new file mode 100644 (file)
index 0000000..e8bc9c0
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2018 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: base91 combinators command-line escape-strings fry
+io.backend io.directories io.directories.search
+io.encodings.binary io.encodings.utf8 io.files io.files.info
+io.pathnames kernel locals math namespaces sequences
+sequences.extras splitting ;
+IN: tools.directory-to-file
+
+: file-is-text? ( path -- ? )
+    binary file-contents [ 127 < ] all? ;
+
+: directory-repr ( path -- obj )
+    escape-simplest
+    "DIRECTORY: " prepend ;
+
+: file-repr ( path string -- obj )
+    [ escape-simplest "FILE:: " prepend ] dip " " glue ;
+
+:: directory-to-string ( path -- string )
+    path normalize-path
+    [ path-separator = ] trim-tail "/" append
+    [ recursive-directory-files ] keep
+    dup '[
+        [ _  ?head drop ] map
+        [
+            {
+                { [ dup file-info directory? ] [ directory-repr ] }
+                { [ dup file-is-text? ] [ dup utf8 file-contents escape-string file-repr ] }
+                [
+                    dup binary file-contents >base91
+                    "" like escape-string
+                    "base91" prepend file-repr
+                ]
+            } cond
+        ] map
+    ] with-directory
+    "\n\n" join
+    "<DIRECTORY: " path escape-simplest "\n\n" 3append
+    "\n\n;DIRECTORY>" surround ;
+
+: directory-to-file ( path -- )
+    [ directory-to-string ] keep ".modern" append
+    utf8 set-file-contents ;
+
+: directory-to-file-main ( -- )
+    command-line get dup length 1 = [ "oops" throw ] unless first
+    directory-to-file ;
+
+MAIN: directory-to-file-main
diff --git a/extra/tools/file-to-directory/authors.txt b/extra/tools/file-to-directory/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/tools/file-to-directory/file-to-directory.factor b/extra/tools/file-to-directory/file-to-directory.factor
new file mode 100644 (file)
index 0000000..fed7027
--- /dev/null
@@ -0,0 +1,39 @@
+! Copyright (C) 2018 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: base91 combinators command-line fry io.directories
+io.encodings.binary io.encodings.utf8 io.files io.pathnames
+kernel modern modern.out namespaces sequences splitting strings ;
+IN: tools.file-to-directory
+
+ERROR: expected-one-path got ;
+ERROR: expected-modern-path got ;
+
+: write-directory-files ( path -- )
+    [ ".modern" ?tail drop dup make-directories ]
+    [ path>literals ] bi
+    '[
+        _ first second rest [
+            dup first "DIRECTORY:" head?
+            [ second first second >string make-directories ]
+            [
+                second first2
+                [ second >string ] [
+                    first3 nip swap "base91" head? [
+                        base91> binary
+                    ] [
+                        utf8
+                    ] if
+                ] bi* swapd
+                [ dup parent-directory make-directories ] dip set-file-contents
+            ] if
+        ] each
+    ] with-directory ;
+
+: get-file-to-directory-path ( array -- path )
+    dup length 1 = [ expected-one-path ] unless
+    first dup ".modern" tail? [ expected-modern-path ] unless ;
+
+: file-to-directory ( -- )
+    command-line get get-file-to-directory-path write-directory-files ;
+
+MAIN: file-to-directory