- IN: temporary
+ IN: io.files.tests
-USING: tools.test io.files io threads kernel continuations ;
+USING: tools.test io.files io threads kernel continuations io.encodings.ascii ;
[ "passwd" ] [ "/etc/passwd" file-name ] unit-test
[ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test
! Copying files
HOOK: copy-file io-backend ( from to -- )
- : copy-file-to ( from to -- )
+M: object copy-file
+ dup parent-directory make-directories
+ binary <file-writer> [
+ swap binary <file-reader> [
+ swap stream-copy
+ ] with-disposal
+ ] with-disposal ;
+
+ : copy-file-into ( from to -- )
to-directory copy-file ;
- : copy-files-to ( files to -- )
- [ copy-file-to ] curry each ;
+ : copy-files-into ( files to -- )
+ [ copy-file-into ] curry each ;
- DEFER: copy-tree-to
+ DEFER: copy-tree-into
: copy-tree ( from to -- )
over directory? [
USING: arrays io io.files kernel math parser strings system
-tools.test words namespaces ;
+tools.test words namespaces io.encodings.ascii io.encodings.binary ;
- IN: temporary
+ IN: io.tests
[ f ] [
"resource:/core/io/test/no-trailing-eol.factor" run-file
-USING: tools.test io.files io io.streams.c ;
+USING: tools.test io.files io io.streams.c io.encodings.ascii ;
- IN: temporary
+ IN: io.streams.c.tests
[ "hello world" ] [
- "test.txt" temp-file [
+ "test.txt" temp-file ascii [
"hello world" write
] with-file-writer
: reset-checksums ( -- )
source-files get [
swap ?resource-path dup exists?
- [ utf8 file-lines swap record-checksum ] [ 2drop ] if
+ [
+ over record-modified
- file-lines swap record-checksum
++ utf8 file-lines swap record-checksum
+ ] [ 2drop ] if
] assoc-each ;
M: pathname where pathname-string 1 2array ;
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces sequences io.files kernel assocs words vocabs
definitions parser continuations inspector debugger io io.styles
-io.streams.lines hashtables sorting prettyprint source-files
+hashtables sorting prettyprint source-files
arrays combinators strings system math.parser compiler.errors
- splitting ;
+ splitting init ;
IN: vocabs.loader
SYMBOL: vocab-roots
- USING: io.sockets io.server io kernel math threads io.encodings.ascii\r
- debugger tools.time prettyprint concurrency.combinators ;\r
-USING: io.sockets io kernel math threads\r
++USING: io.sockets io kernel math threads io.encodings.ascii\r
+ debugger tools.time prettyprint concurrency.count-downs\r
+ namespaces arrays continuations ;\r
IN: benchmark.sockets\r
\r
+ SYMBOL: counter\r
+ \r
+ : number-of-requests 1 ;\r
+ \r
+ : server-addr "127.0.0.1" 7777 <inet4> ;\r
+ \r
+ : server-loop ( server -- )\r
+ dup accept [\r
+ [\r
+ read1 CHAR: x = [\r
+ "server" get dispose\r
+ ] [\r
+ number-of-requests\r
+ [ read1 write1 flush ] times\r
+ counter get count-down\r
+ ] if\r
+ ] with-stream\r
+ ] curry "Client handler" spawn drop server-loop ;\r
+ \r
: simple-server ( -- )\r
++<<<<<<< HEAD:extra/benchmark/sockets/sockets.factor
+ 7777 local-server "benchmark.sockets" ascii [\r
+ read1 CHAR: x = [\r
+ stop-server\r
+ ] [\r
+ 20 [ read1 write1 flush ] times\r
+ ] if\r
+ ] with-server ;\r
++=======
+ [\r
+ server-addr <server> dup "server" set [\r
+ server-loop\r
+ ] with-disposal\r
+ ] ignore-errors ;\r
++>>>>>>> b80434b2e394480fa317348955b1f7b89e284bde:extra/benchmark/sockets/sockets.factor
\r
: simple-client ( -- )\r
- "localhost" 7777 <inet> <client> [\r
+ server-addr <client> [\r
CHAR: b write1 flush\r
- 20 [ CHAR: a dup write1 flush read1 assert= ] times\r
+ number-of-requests\r
+ [ CHAR: a dup write1 flush read1 assert= ] times\r
+ counter get count-down\r
] with-stream ;\r
\r
: stop-server ( -- )\r
! See http://factorcode.org/license.txt for BSD license.
IN: bootstrap.image.upload
USING: http.client crypto.md5 splitting assocs kernel io.files
-bootstrap.image sequences io namespaces io.launcher math ;
+bootstrap.image sequences io namespaces io.launcher math io.encodings.ascii ;
- : destination "slava@factorcode.org:www/images/latest/" ;
+ SYMBOL: upload-images-destination
+
+ : destination ( -- dest )
+ upload-images-destination get
+ "slava@/var/www/factorcode.org/newsite/images/latest/"
+ or ;
: checksums "checksums.txt" temp-file ;
USING: io io.files io.streams.string http.server.templating kernel tools.test
- sequences ;
+ sequences io.encodings.utf8 ;
- IN: temporary
+ IN: http.server.templating.tests
: test-template ( path -- ? )
"extra/http/server/templating/test/" swap append
templating-vocab use+
! so that reload works properly
dup source-file file set
- dup ?resource-path utf8 file-contents
- ?resource-path file-contents
++ ?resource-path utf8 file-contents
[ eval-template ] [ html-error. drop ] recover
] with-file-vocabs
- ] assert-depth drop ;
+ ] curry assert-depth ;
: run-relative-template-file ( filename -- )
file get source-file-path parent-directory
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: io io.backend io.nonblocking io.streams.duplex
-io.timeouts system kernel namespaces strings hashtables
-sequences assocs combinators vocabs.loader init threads
-continuations math ;
+USING: io io.backend io.timeouts system kernel namespaces
+strings hashtables sequences assocs combinators vocabs.loader
- init threads continuations math io.encodings ;
++init threads continuations math io.encodings io.streams.duplex
++io.nonblocking ;
IN: io.launcher
! Non-blocking process exit notification facility
-USING: io io.mmap io.files kernel tools.test continuations sequences ;
+USING: io io.mmap io.files kernel tools.test continuations
+sequences io.encodings.ascii ;
- IN: temporary
+ IN: io.mmap.tests
[ "mmap-test-file.txt" resource-path delete-file ] ignore-errors
-[ ] [ "mmap-test-file.txt" resource-path [ "12345" write ] with-file-writer ] unit-test
+[ ] [ "mmap-test-file.txt" resource-path ascii [ "12345" write ] with-file-writer ] unit-test
[ ] [ "mmap-test-file.txt" resource-path dup file-length [ CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
[ 5 ] [ "mmap-test-file.txt" resource-path dup file-length [ length ] with-mapped-file ] unit-test
-[ "22345" ] [ "mmap-test-file.txt" resource-path file-contents ] unit-test
+[ "22345" ] [ "mmap-test-file.txt" resource-path ascii file-contents ] unit-test
[ "mmap-test-file.txt" resource-path delete-file ] ignore-errors
- IN: temporary
+ IN: io.server.tests
USING: tools.test io.server io.server.private ;
-{ 1 0 } [ [ ] server-loop ] must-infer-as
+{ 2 0 } [ [ ] server-loop ] must-infer-as
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
++<<<<<<< HEAD:extra/io/unix/launcher/launcher.factor
+USING: io io.backend io.launcher io.unix.backend io.unix.files
+io.nonblocking sequences kernel namespaces math system
+ alien.c-types debugger continuations arrays assocs
+combinators unix.process parser-combinators memoize
+promises strings threads unix io.encodings.latin1 ;
++=======
+ USING: io io.backend io.launcher io.nonblocking io.unix.backend
+ io.unix.files io.nonblocking sequences kernel namespaces math
+ system alien.c-types debugger continuations arrays assocs
+ combinators unix.process strings threads unix
+ io.unix.launcher.parser ;
++>>>>>>> b80434b2e394480fa317348955b1f7b89e284bde:extra/io/unix/launcher/launcher.factor
IN: io.unix.launcher
! Search unix first
USING: io.files io.sockets io kernel threads
namespaces tools.test continuations strings byte-arrays
-sequences prettyprint system ;
+sequences prettyprint system io.encodings.binary io.encodings.ascii ;
- IN: temporary
+ IN: io.unix.tests
! Unix domain stream sockets
: socket-server "unix-domain-socket-test" temp-file ;
- IN: temporary
+ IN: porter-stemmer.tests
USING: arrays io kernel porter-stemmer sequences tools.test
-io.files ;
+io.files io.encodings.utf8 ;
[ 0 ] [ "xa" consonant-seq ] unit-test
[ 0 ] [ "xxaa" consonant-seq ] unit-test