]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of http://factorcode.org/git/factor
authorEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Tue, 9 Dec 2008 03:35:50 +0000 (21:35 -0600)
committerEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Tue, 9 Dec 2008 03:35:50 +0000 (21:35 -0600)
17 files changed:
basis/io/files/unique/backend/backend.factor [deleted file]
basis/io/files/unique/unique.factor
basis/io/paths/authors.txt [new file with mode: 0755]
basis/io/paths/paths-tests.factor [new file with mode: 0644]
basis/io/paths/paths.factor [new file with mode: 0755]
basis/io/paths/windows/authors.txt [new file with mode: 0644]
basis/io/paths/windows/tags.txt [new file with mode: 0644]
basis/io/paths/windows/windows.factor [new file with mode: 0644]
basis/io/unix/files/unique/unique.factor
basis/io/windows/files/unique/unique.factor
basis/tools/files/files-tests.factor
basis/tools/files/files.factor
extra/io/paths/authors.txt [deleted file]
extra/io/paths/paths.factor [deleted file]
extra/io/paths/windows/authors.txt [deleted file]
extra/io/paths/windows/tags.txt [deleted file]
extra/io/paths/windows/windows.factor [deleted file]

diff --git a/basis/io/files/unique/backend/backend.factor b/basis/io/files/unique/backend/backend.factor
deleted file mode 100644 (file)
index 7b9809f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: io.backend ;
-IN: io.files.unique.backend
-
-HOOK: (make-unique-file) io-backend ( path -- )
-HOOK: temporary-path io-backend ( -- path )
index ec89517bbc707cd749aa91169f4e33dbdc1ce513..66540fb48ed24c71e6264b9b8b5164f6b0818b64 100644 (file)
@@ -1,11 +1,13 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.bitwise math.parser
-random sequences continuations namespaces
-io.files io arrays io.files.unique.backend system
-combinators vocabs.loader fry ;
+USING: kernel math math.bitwise math.parser random sequences
+continuations namespaces io.files io arrays system
+combinators vocabs.loader fry io.backend ;
 IN: io.files.unique
 
+HOOK: touch-unique-file io-backend ( path -- )
+HOOK: temporary-path io-backend ( -- path )
+
 SYMBOL: unique-length
 SYMBOL: unique-retries
 
@@ -26,12 +28,17 @@ SYMBOL: unique-retries
 
 PRIVATE>
 
+: (make-unique-file) ( path prefix suffix -- path )
+    '[
+        _ _ _ unique-length get random-name glue append-path
+        dup touch-unique-file
+    ] unique-retries get retry ;
+
 : make-unique-file ( prefix suffix -- path )
-    temporary-path -rot
-    [
-        unique-length get random-name glue append-path
-        dup (make-unique-file)
-    ] 3curry unique-retries get retry ;
+    [ temporary-path ] 2dip (make-unique-file) ;
+
+: make-unique-file* ( prefix suffix -- path )
+    [ current-directory get ] 2dip (make-unique-file) ;
 
 : with-unique-file ( prefix suffix quot: ( path -- ) -- )
     [ make-unique-file ] dip [ delete-file ] bi ; inline
diff --git a/basis/io/paths/authors.txt b/basis/io/paths/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/io/paths/paths-tests.factor b/basis/io/paths/paths-tests.factor
new file mode 100644 (file)
index 0000000..01763ce
--- /dev/null
@@ -0,0 +1,11 @@
+USING: io.paths kernel tools.test io.files.unique sequences
+io.files namespaces sorting ;
+IN: io.paths.tests
+
+[ t ] [
+    [
+        10 [ "io.paths.test" "gogogo" make-unique-file* ] replicate
+        current-directory get t [ ] find-all-files
+    ] with-unique-directory
+    [ natural-sort ] bi@ =
+] unit-test
diff --git a/basis/io/paths/paths.factor b/basis/io/paths/paths.factor
new file mode 100755 (executable)
index 0000000..212ba9e
--- /dev/null
@@ -0,0 +1,58 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays deques dlists io.files
+kernel sequences system vocabs.loader fry continuations ;
+IN: io.paths
+
+TUPLE: directory-iterator path bfs queue ;
+
+<PRIVATE
+
+: qualified-directory ( path -- seq )
+    dup directory-files [ append-path ] with map ;
+
+: push-directory ( path iter -- )
+    [ qualified-directory ] dip [
+        dup queue>> swap bfs>>
+        [ push-front ] [ push-back ] if
+    ] curry each ;
+
+: <directory-iterator> ( path bfs? -- iterator )
+    <dlist> directory-iterator boa
+    dup path>> over push-directory ;
+
+: next-file ( iter -- file/f )
+    dup queue>> deque-empty? [ drop f ] [
+        dup queue>> pop-back dup link-info directory?
+        [ over push-directory next-file ] [ nip ] if
+    ] if ;
+
+: iterate-directory ( iter quot: ( obj -- ? ) -- obj )
+    over next-file [
+        over call
+        [ 2nip ] [ iterate-directory ] if*
+    ] [
+        2drop f
+    ] if* ; inline recursive
+
+PRIVATE>
+
+: find-file ( path bfs? quot: ( obj -- ? ) -- path/f )
+    [ <directory-iterator> ] dip
+    [ keep and ] curry iterate-directory ; inline
+
+: each-file ( path bfs? quot: ( obj -- ? ) -- )
+    [ <directory-iterator> ] dip
+    [ f ] compose iterate-directory drop ; inline
+
+: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths )
+    [ <directory-iterator> ] dip
+    pusher [ [ f ] compose iterate-directory drop ] dip ; inline
+
+: recursive-directory ( path bfs? -- paths )
+    [ ] accumulator [ each-file ] dip ;
+
+: find-in-directories ( directories bfs? quot -- path' )
+    '[ _ _ find-file ] attempt-all ; inline
+
+os windows? [ "io.paths.windows" require ] when
diff --git a/basis/io/paths/windows/authors.txt b/basis/io/paths/windows/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/io/paths/windows/tags.txt b/basis/io/paths/windows/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/io/paths/windows/windows.factor b/basis/io/paths/windows/windows.factor
new file mode 100644 (file)
index 0000000..b4858aa
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays continuations fry io.files io.paths
+kernel windows.shell32 sequences ;
+IN: io.paths.windows
+
+: program-files-directories ( -- array )
+    program-files program-files-x86 2array ; inline
+
+: find-in-program-files ( base-directory bfs? quot -- path )
+    [
+        [ program-files-directories ] dip '[ _ append-path ] map
+    ] 2dip find-in-directories ; inline
index e47ac6a2e3f71ebc752368dd798006696358da84..24dcdcb65a82472141620c1d26e8a66d092267eb 100644 (file)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.ports io.unix.backend math.bitwise
-unix io.files.unique.backend system ;
+unix system io.files.unique ;
 IN: io.unix.files.unique
 
 : open-unique-flags ( -- flags )
     { O_RDWR O_CREAT O_EXCL } flags ;
 
-M: unix (make-unique-file) ( path -- )
+M: unix touch-unique-file ( path -- )
     open-unique-flags file-mode open-file close-file ;
 
 M: unix temporary-path ( -- path ) "/tmp" ;
index b1bf2bdc1c7be50a0dcdc43a50338843b7f6fb07..ab99bf2cac9e5823161a383e87c98ac9b47b6560 100644 (file)
@@ -1,9 +1,9 @@
-USING: kernel system io.files.unique.backend
-windows.kernel32 io.windows io.windows.files io.ports windows
-destructors environment ;
+USING: kernel system windows.kernel32 io.windows
+io.windows.files io.ports windows destructors environment
+io.files.unique ;
 IN: io.windows.files.unique
 
-M: windows (make-unique-file) ( path -- )
+M: windows touch-unique-file ( path -- )
     GENERIC_WRITE CREATE_NEW 0 open-file dispose ;
 
 M: windows temporary-path ( -- path )
index 6aa68d81270c9f84d9b9bfbf21a70a9b3ca46b99..4dc4ef23f057451172917e85cd8ee391251e0f88 100644 (file)
@@ -6,3 +6,6 @@ IN: tools.files.tests
 \ directory. must-infer
 
 [ ] [ "" directory. ] unit-test
+
+[ ]
+[ { device-name free-space used-space total-space percent-used } file-systems. ] unit-test
index 18baedae0a98200ccce9428a85ff006a05b36eff..db49dcbf61c50c1f6b783b5eebd0388444a0752c 100755 (executable)
@@ -65,5 +65,3 @@ percent-used percent-free ;
     { [ os unix? ] [ "tools.files.unix" ] }
     { [ os windows? ] [ "tools.files.windows" ] }
 } cond require
-
-! { device-name free-space used-space total-space percent-used } file-systems.
diff --git a/extra/io/paths/authors.txt b/extra/io/paths/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/io/paths/paths.factor b/extra/io/paths/paths.factor
deleted file mode 100755 (executable)
index 75d08b6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays deques dlists io.files io.paths.private
-kernel sequences system vocabs.loader fry continuations ;
-IN: io.paths
-
-TUPLE: directory-iterator path bfs queue ;
-
-<PRIVATE
-
-: qualified-directory ( path -- seq )
-    dup directory-files [ append-path ] with map ;
-
-: push-directory ( path iter -- )
-    [ qualified-directory ] dip [
-        dup queue>> swap bfs>>
-        [ push-front ] [ push-back ] if
-    ] curry each ;
-
-: <directory-iterator> ( path bfs? -- iterator )
-    <dlist> directory-iterator boa
-    dup path>> over push-directory ;
-
-: next-file ( iter -- file/f )
-    dup queue>> deque-empty? [ drop f ] [
-        dup queue>> pop-back dup link-info directory?
-        [ over push-directory next-file ] [ nip ] if
-    ] if ;
-
-: iterate-directory ( iter quot: ( obj -- ? ) -- obj )
-    over next-file [
-        over call
-        [ 2nip ] [ iterate-directory ] if*
-    ] [
-        2drop f
-    ] if* ; inline recursive
-
-PRIVATE>
-
-: find-file ( path bfs? quot: ( obj -- ? ) -- path/f )
-    [ <directory-iterator> ] dip
-    [ keep and ] curry iterate-directory ; inline
-
-: each-file ( path bfs? quot: ( obj -- ? ) -- )
-    [ <directory-iterator> ] dip
-    [ f ] compose iterate-directory drop ; inline
-
-: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths )
-    [ <directory-iterator> ] dip
-    pusher [ [ f ] compose iterate-directory drop ] dip ; inline
-
-: recursive-directory ( path bfs? -- paths )
-    [ ] accumulator [ each-file ] dip ;
-
-: find-in-directories ( directories bfs? quot -- path' )
-    '[ _ _ find-file ] attempt-all ; inline
-
-os windows? [ "io.paths.windows" require ] when
diff --git a/extra/io/paths/windows/authors.txt b/extra/io/paths/windows/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/io/paths/windows/tags.txt b/extra/io/paths/windows/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/io/paths/windows/windows.factor b/extra/io/paths/windows/windows.factor
deleted file mode 100644 (file)
index b4858aa..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays continuations fry io.files io.paths
-kernel windows.shell32 sequences ;
-IN: io.paths.windows
-
-: program-files-directories ( -- array )
-    program-files program-files-x86 2array ; inline
-
-: find-in-program-files ( base-directory bfs? quot -- path )
-    [
-        [ program-files-directories ] dip '[ _ append-path ] map
-    ] 2dip find-in-directories ; inline