From cf39fd29f8a39c71033bd39887f2f31f1f390cbe Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Sat, 13 Dec 2008 04:41:33 -0600 Subject: [PATCH 01/19] Fix Windows bootstrap --- basis/io/backend/windows/nt/nt.factor | 8 ++++---- basis/io/directories/directories.factor | 1 + basis/io/directories/windows/windows.factor | 12 ++++++++++++ basis/io/files/info/windows/nt/nt.factor | 9 --------- basis/io/files/info/windows/windows.factor | 20 +++++++++++++++++--- basis/io/files/windows/nt/nt.factor | 4 ++-- basis/io/files/windows/windows.factor | 20 +++++++------------- basis/io/launcher/launcher.factor | 3 +-- basis/io/launcher/windows/nt/nt.factor | 2 +- basis/io/launcher/windows/windows.factor | 2 +- basis/io/monitors/windows/nt/nt.factor | 3 ++- basis/tools/deploy/windows/windows.factor | 2 +- basis/tools/disassembler/gdb/gdb.factor | 8 ++++---- 13 files changed, 53 insertions(+), 41 deletions(-) mode change 100644 => 100755 basis/io/backend/windows/nt/nt.factor mode change 100644 => 100755 basis/io/directories/directories.factor mode change 100644 => 100755 basis/io/directories/windows/windows.factor mode change 100644 => 100755 basis/io/files/info/windows/nt/nt.factor mode change 100644 => 100755 basis/io/files/info/windows/windows.factor mode change 100644 => 100755 basis/io/launcher/launcher.factor mode change 100644 => 100755 basis/io/launcher/windows/nt/nt.factor mode change 100644 => 100755 basis/io/launcher/windows/windows.factor mode change 100644 => 100755 basis/tools/disassembler/gdb/gdb.factor diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor old mode 100644 new mode 100755 index d6c74ed098..e41293b6de --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -1,9 +1,9 @@ USING: alien alien.c-types arrays assocs combinators continuations destructors io io.backend io.ports io.timeouts -io.backend.windows io.files.windows io.files io.buffers io.streams.c -libc kernel math namespaces sequences threads windows -windows.errors windows.kernel32 strings splitting qualified -ascii system accessors locals ; +io.backend.windows io.files.windows io.files.windows.nt io.files +io.pathnames io.buffers io.streams.c libc kernel math namespaces +sequences threads windows windows.errors windows.kernel32 +strings splitting qualified ascii system accessors locals ; QUALIFIED: windows.winsock IN: io.backend.windows.nt diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor old mode 100644 new mode 100755 index 0b8fa13791..2630be8ce2 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -83,4 +83,5 @@ M: object copy-file { { [ os unix? ] [ "io.directories.unix" require ] } + { [ os windows? ] [ "io.directories.windows" require ] } } cond \ No newline at end of file diff --git a/basis/io/directories/windows/windows.factor b/basis/io/directories/windows/windows.factor old mode 100644 new mode 100755 index 6520602b7e..c2955d3977 --- a/basis/io/directories/windows/windows.factor +++ b/basis/io/directories/windows/windows.factor @@ -1,7 +1,19 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. +USING: system io.directories io.encodings.utf16n alien.strings +io.pathnames io.backend io.files.windows destructors +kernel accessors calendar windows windows.errors +windows.kernel32 alien.c-types sequences splitting +fry continuations ; IN: io.directories.windows +M: windows touch-file ( path -- ) + [ + normalize-path + maybe-create-file [ &dispose ] dip + [ drop ] [ handle>> f now dup (set-file-times) ] if + ] with-destructors ; + M: windows move-file ( from to -- ) [ normalize-path ] bi@ MoveFile win32-error=0/f ; diff --git a/basis/io/files/info/windows/nt/nt.factor b/basis/io/files/info/windows/nt/nt.factor old mode 100644 new mode 100755 index e1b8062016..19ea0864ed --- a/basis/io/files/info/windows/nt/nt.factor +++ b/basis/io/files/info/windows/nt/nt.factor @@ -2,12 +2,3 @@ ! See http://factorcode.org/license.txt for BSD license. IN: io.files.info.windows.nt -ERROR: not-absolute-path ; - -M: winnt root-directory ( string -- string' ) - unicode-prefix ?head drop - dup { - [ length 2 >= ] - [ second CHAR: : = ] - [ first Letter? ] - } 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ; diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor old mode 100644 new mode 100755 index c3068dbafa..aecf42d9a2 --- a/basis/io/files/info/windows/windows.factor +++ b/basis/io/files/info/windows/windows.factor @@ -1,5 +1,11 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. +USING: byte-arrays math io.backend io.files.info +io.files.windows io.files.windows.nt kernel windows.kernel32 +windows.time windows accessors alien.c-types combinators +generalizations system alien.strings io.encodings.utf16n +sequences splitting windows.errors fry continuations destructors +calendar ascii combinators.short-circuit ; IN: io.files.info.windows TUPLE: windows-file-info < file-info attributes ; @@ -72,10 +78,10 @@ TUPLE: windows-file-info < file-info attributes ; get-file-information BY_HANDLE_FILE_INFORMATION>file-info ] if ; -M: winnt file-info ( path -- info ) +M: windows file-info ( path -- info ) normalize-path get-file-information-stat ; -M: winnt link-info ( path -- info ) +M: windows link-info ( path -- info ) file-info ; : volume-information ( normalized-path -- volume-name volume-serial max-component flags type ) @@ -103,7 +109,15 @@ M: winnt link-info ( path -- info ) TUPLE: win32-file-system-info < file-system-info max-component flags device-serial ; -HOOK: root-directory os ( string -- string' ) +ERROR: not-absolute-path ; + +: root-directory ( string -- string' ) + unicode-prefix ?head drop + dup { + [ length 2 >= ] + [ second CHAR: : = ] + [ first Letter? ] + } 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ; M: winnt file-system-info ( path -- file-system-info ) normalize-path root-directory diff --git a/basis/io/files/windows/nt/nt.factor b/basis/io/files/windows/nt/nt.factor index f3a534388a..37c6e3190a 100755 --- a/basis/io/files/windows/nt/nt.factor +++ b/basis/io/files/windows/nt/nt.factor @@ -1,5 +1,5 @@ USING: continuations destructors io.buffers io.files io.backend -io.timeouts io.ports io.files.private io.backend.windows +io.timeouts io.ports io.pathnames io.files.private io.backend.windows io.files.windows io.backend.windows.nt io.encodings.utf16n windows windows.kernel32 kernel libc math threads system environment alien.c-types alien.arrays alien.strings sequences @@ -48,7 +48,7 @@ M: winnt FileArgs-overlapped ( port -- overlapped ) make-overlapped ; M: winnt open-append - [ dup file-info size>> ] [ drop 0 ] recover + 0 ! [ dup file-info size>> ] [ drop 0 ] recover [ (open-append) ] dip >>ptr ; M: winnt home "USERPROFILE" os-env ; diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor index 30915f8c71..1a1ffe0dc7 100755 --- a/basis/io/files/windows/windows.factor +++ b/basis/io/files/windows/windows.factor @@ -1,11 +1,12 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types io.binary io.backend io.files io.buffers -io.encodings.utf16n io.ports io.backend.windows kernel math splitting -fry alien.strings windows windows.kernel32 windows.time calendar -combinators math.functions sequences namespaces make words -symbols system destructors accessors math.bitwise continuations -windows.errors arrays byte-arrays generalizations ; +USING: alien.c-types io.binary io.backend io.files +io.files.types io.buffers io.encodings.utf16n io.ports +io.backend.windows kernel math splitting fry alien.strings +windows windows.kernel32 windows.time calendar combinators +math.functions sequences namespaces make words symbols system +destructors accessors math.bitwise continuations windows.errors +arrays byte-arrays generalizations ; IN: io.files.windows : open-file ( path access-mode create-mode flags -- handle ) @@ -130,10 +131,3 @@ SYMBOLS: +read-only+ +hidden+ +system+ : (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- ) [ timestamp>FILETIME ] tri@ SetFileTime win32-error=0/f ; - -M: winnt touch-file ( path -- ) - [ - normalize-path - maybe-create-file [ &dispose ] dip - [ drop ] [ handle>> f now dup (set-file-times) ] if - ] with-destructors ; diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor old mode 100644 new mode 100755 index ad2f7e44a9..f5809223fc --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -262,7 +262,6 @@ M: object run-pipeline-element { { [ os unix? ] [ "io.launcher.unix" require ] } - { [ os winnt? ] [ "io.backend.windows.nt.launcher" require ] } - { [ os wince? ] [ "io.launcher.windows" require ] } + { [ os winnt? ] [ "io.launcher.windows.nt" require ] } [ ] } cond diff --git a/basis/io/launcher/windows/nt/nt.factor b/basis/io/launcher/windows/nt/nt.factor old mode 100644 new mode 100755 index d098456486..5ebb38abc2 --- a/basis/io/launcher/windows/nt/nt.factor +++ b/basis/io/launcher/windows/nt/nt.factor @@ -6,7 +6,7 @@ windows.kernel32 windows namespaces make io.launcher kernel sequences windows.errors assocs splitting system strings io.launcher.windows io.files.windows io.backend io.files io.files.private combinators shuffle accessors locals ; -IN: io.backend.windows.nt.launcher +IN: io.launcher.windows.nt : duplicate-handle ( handle -- handle' ) GetCurrentProcess ! source process diff --git a/basis/io/launcher/windows/windows.factor b/basis/io/launcher/windows/windows.factor old mode 100644 new mode 100755 index 1e6d1f1a6d..0497754aa2 --- a/basis/io/launcher/windows/windows.factor +++ b/basis/io/launcher/windows/windows.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays continuations io -io.backend.windows io.pipes.windows.nt libc io.ports +io.backend.windows io.pipes.windows.nt io.pathnames libc io.ports windows.types math windows.kernel32 namespaces make io.launcher kernel sequences windows.errors splitting system threads init strings combinators diff --git a/basis/io/monitors/windows/nt/nt.factor b/basis/io/monitors/windows/nt/nt.factor index 57bd07ef24..d2408a3dd1 100755 --- a/basis/io/monitors/windows/nt/nt.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -6,7 +6,8 @@ hashtables sorting arrays combinators math.bitwise strings system accessors threads splitting io.backend io.backend.windows io.backend.windows.nt io.files.windows.nt io.monitors io.ports io.buffers io.files io.timeouts io.encodings.string -io.encodings.utf16n io windows windows.kernel32 windows.types ; +io.encodings.utf16n io windows windows.kernel32 windows.types +io.pathnames ; IN: io.monitors.windows.nt : open-directory ( path -- handle ) diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 6188e78b0e..7ce635b1ba 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files kernel namespaces sequences system +USING: io io.files io.directories kernel namespaces sequences system tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint combinators windows.shell32 windows.user32 ; diff --git a/basis/tools/disassembler/gdb/gdb.factor b/basis/tools/disassembler/gdb/gdb.factor old mode 100644 new mode 100755 index 65d0e2f43a..e97cc203a2 --- a/basis/tools/disassembler/gdb/gdb.factor +++ b/basis/tools/disassembler/gdb/gdb.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files io words alien kernel math.parser alien.syntax -io.launcher system assocs arrays sequences namespaces make -qualified system math io.encodings.ascii accessors -tools.disassembler ; +USING: io.files io.files.temp io words alien kernel math.parser +alien.syntax io.launcher system assocs arrays sequences +namespaces make qualified system math io.encodings.ascii +accessors tools.disassembler ; IN: tools.disassembler.gdb SINGLETON: gdb-disassembler From cf1a510c1b06aaeb108252a39c4f7ee34bc933ea Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sun, 14 Dec 2008 02:39:48 +0100 Subject: [PATCH 02/19] FUEL: allow editing vocabularies not yet loaded. --- extra/fuel/fuel.factor | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 6c86889040..eee33a13c8 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -5,7 +5,8 @@ USING: accessors arrays classes classes.tuple compiler.units combinators continuations debugger definitions eval help io io.files io.streams.string kernel lexer listener listener.private make math namespaces parser prettyprint prettyprint.config -quotations sequences strings source-files vectors vocabs vocabs.loader ; +quotations sequences strings source-files tools.vocabs +vectors vocabs vocabs.loader ; IN: fuel @@ -156,12 +157,10 @@ M: source-file fuel-pprint path>> fuel-pprint ; ] when* ; : fuel-get-vocab-location ( vocab -- ) - vocab-source-path [ - (normalize-path) 1 2array fuel-eval-set-result - ] when* ; + >vocab-link fuel-get-edit-location ; : fuel-get-vocabs ( -- ) - vocabs fuel-eval-set-result ; inline + all-vocabs-seq [ vocab-name ] map fuel-eval-set-result ; inline : fuel-run-file ( path -- ) run-file ; inline From 04e4ff16f8998707b344b6da4008835b184ed8e6 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sun, 14 Dec 2008 02:44:04 +0100 Subject: [PATCH 03/19] FUEL: Correct indentation for C: parsing word in factor-mode. --- misc/fuel/fuel-syntax.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index a0485f9183..e9de3a64fa 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -101,7 +101,7 @@ fuel-syntax--declaration-words-regex)) (defconst fuel-syntax--single-liner-regex - (format "^%s" (regexp-opt '("DEFER:" "GENERIC:" "IN:" + (format "^%s" (regexp-opt '("C:" "DEFER:" "GENERIC:" "IN:" "PRIVATE>" " Date: Sun, 14 Dec 2008 16:50:34 +0100 Subject: [PATCH 04/19] FUEL: Internal refactorings and cleanups. --- misc/fuel/fuel-connection.el | 72 ++++------------- misc/fuel/fuel-debug.el | 4 +- misc/fuel/fuel-eval.el | 150 ++++++++++++++++++++--------------- misc/fuel/fuel-help.el | 8 +- misc/fuel/fuel-log.el | 72 +++++++++++++++++ misc/fuel/fuel-mode.el | 37 ++++----- misc/fuel/fuel-syntax.el | 3 +- 7 files changed, 201 insertions(+), 145 deletions(-) create mode 100644 misc/fuel/fuel-log.el diff --git a/misc/fuel/fuel-connection.el b/misc/fuel/fuel-connection.el index b72e6843bf..168501171e 100644 --- a/misc/fuel/fuel-connection.el +++ b/misc/fuel/fuel-connection.el @@ -14,6 +14,9 @@ ;;; Code: +(require 'fuel-base) +(require 'fuel-log) + ;;; Default connection: @@ -122,49 +125,6 @@ (add-hook 'comint-redirect-hook 'fuel-con--comint-redirect-hook)) - -;;; Logging: - -(defvar fuel-con--log-size 32000 - "Maximum size of the Factor messages log.") - -(defvar fuel-con--log-verbose-p t - "Log level for Factor messages.") - -(define-derived-mode factor-messages-mode fundamental-mode "Factor Messages" - "Simple mode to log interactions with the factor listener" - (kill-all-local-variables) - (buffer-disable-undo) - (set (make-local-variable 'comint-redirect-subvert-readonly) t) - (add-hook 'after-change-functions - '(lambda (b e len) - (let ((inhibit-read-only t)) - (when (> b fuel-con--log-size) - (delete-region (point-min) b)))) - nil t) - (setq buffer-read-only t)) - -(defun fuel-con--log-buffer () - (or (get-buffer "*factor messages*") - (save-current-buffer - (set-buffer (get-buffer-create "*factor messages*")) - (factor-messages-mode) - (current-buffer)))) - -(defun fuel-con--log-msg (type &rest args) - (with-current-buffer (fuel-con--log-buffer) - (let ((inhibit-read-only t)) - (insert (format "\n%s: %s\n" type (apply 'format args)))))) - -(defsubst fuel-con--log-warn (&rest args) - (apply 'fuel-con--log-msg 'WARNING args)) - -(defsubst fuel-con--log-error (&rest args) - (apply 'fuel-con--log-msg 'ERROR args)) - -(defsubst fuel-con--log-info (&rest args) - (if fuel-con--log-verbose-p (apply 'fuel-con--log-msg 'INFO args) "")) - ;;; Requests handling: @@ -175,11 +135,11 @@ (str (and req (fuel-con--request-string req)))) (when (and buffer req str) (set-buffer buffer) - (when fuel-con--log-verbose-p - (with-current-buffer (fuel-con--log-buffer) + (when fuel-log--verbose-p + (with-current-buffer (fuel-log--buffer) (let ((inhibit-read-only t)) - (fuel-con--log-info "<%s>: %s" (fuel-con--request-id req) str)))) - (comint-redirect-send-command str (fuel-con--log-buffer) nil t))))) + (fuel-log--info "<%s>: %s" (fuel-con--request-id req) str)))) + (comint-redirect-send-command str (fuel-log--buffer) nil t))))) (defun fuel-con--process-completed-request (req) (let ((str (fuel-con--request-output req)) @@ -188,29 +148,29 @@ (rstr (fuel-con--request-string req)) (buffer (fuel-con--request-buffer req))) (if (not cont) - (fuel-con--log-warn "<%s> Droping result for request %S (%s)" + (fuel-log--warn "<%s> Droping result for request %S (%s)" id rstr str) (condition-case cerr (with-current-buffer (or buffer (current-buffer)) (funcall cont str) - (fuel-con--log-info "<%s>: processed\n\t%s" id str)) - (error (fuel-con--log-error "<%s>: continuation failed %S \n\t%s" + (fuel-log--info "<%s>: processed\n\t%s" id str)) + (error (fuel-log--error "<%s>: continuation failed %S \n\t%s" id rstr cerr)))))) (defun fuel-con--comint-redirect-filter (str) (if (not fuel-con--connection) - (fuel-con--log-error "No connection in buffer (%s)" str) + (fuel-log--error "No connection in buffer (%s)" str) (let ((req (fuel-con--connection-current-request fuel-con--connection))) - (if (not req) (fuel-con--log-error "No current request (%s)" str) + (if (not req) (fuel-log--error "No current request (%s)" str) (fuel-con--request-output req str) - (fuel-con--log-info "<%s>: in progress" (fuel-con--request-id req))))) - ".\n") + (fuel-log--info "<%s>: in progress" (fuel-con--request-id req))))) + ".") (defun fuel-con--comint-redirect-hook () (if (not fuel-con--connection) - (fuel-con--log-error "No connection in buffer") + (fuel-log--error "No connection in buffer") (let ((req (fuel-con--connection-current-request fuel-con--connection))) - (if (not req) (fuel-con--log-error "No current request (%s)" str) + (if (not req) (fuel-log--error "No current request (%s)" str) (fuel-con--process-completed-request req) (fuel-con--connection-clean-current-request fuel-con--connection))))) diff --git a/misc/fuel/fuel-debug.el b/misc/fuel/fuel-debug.el index a7c06e4b3e..d34b31903e 100644 --- a/misc/fuel/fuel-debug.el +++ b/misc/fuel/fuel-debug.el @@ -214,7 +214,7 @@ (buffer (if file (find-file-noselect file) (current-buffer)))) (with-current-buffer buffer (fuel-debug--display-retort - (fuel-eval--send/wait (fuel-eval--cmd/string (format ":%s" n))) + (fuel-eval--send/wait `(:fuel ((:factor ,(format ":%s" n))))) (format "Restart %s (%s) successful" n (nth (1- n) rs)))))))) (defun fuel-debug-show--compiler-info (info) @@ -224,7 +224,7 @@ (error "%s information not available" info)) (message "Retrieving %s info ..." info) (unless (fuel-debug--display-retort - (fuel-eval--send/wait (fuel-eval--cmd/string info)) + (fuel-eval--send/wait `(:fuel ((:factor ,info)))) "" (fuel-debug--buffer-file)) (error "Sorry, no %s info available" info)))) diff --git a/misc/fuel/fuel-eval.el b/misc/fuel/fuel-eval.el index 02bcb54d66..07c2ca3445 100644 --- a/misc/fuel/fuel-eval.el +++ b/misc/fuel/fuel-eval.el @@ -17,6 +17,93 @@ (require 'fuel-syntax) (require 'fuel-connection) + +;;; Simple sexp-based representation of factor code + +(defun factor (sexp) + (cond ((null sexp) "f") + ((eq sexp t) "t") + ((or (stringp sexp) (numberp sexp)) (format "%S" sexp)) + ((vectorp sexp) (cons :quotation (append sexp nil))) + ((listp sexp) + (case (car sexp) + (:array (factor--seq 'V{ '} (cdr sexp))) + (:quote (format "\\ %s" (factor `(:factor ,(cadr sexp))))) + (:quotation (factor--seq '\[ '\] (cdr sexp))) + (:factor (format "%s" (mapconcat 'identity (cdr sexp) " "))) + (:fuel (factor--fuel-factor (cons :rs (cdr sexp)))) + (:fuel* (factor--fuel-factor (cons :nrs (cdr sexp)))) + (t (mapconcat 'factor sexp " ")))) + ((keywordp sexp) + (factor (case sexp + (:rs 'fuel-eval-restartable) + (:nrs 'fuel-eval-non-restartable) + (:in (fuel-syntax--current-vocab)) + (:usings `(:array ,@(fuel-syntax--usings-update))) + (:get 'fuel-eval-set-result) + (t `(:factor ,(symbol-name sexp)))))) + ((symbolp sexp) (symbol-name sexp)))) + +(defsubst factor--seq (begin end forms) + (format "%s %s %s" begin (if forms (factor forms) "") end)) + +(defsubst factor--fuel-factor (sexp) + (factor `(,(factor--fuel-restart (nth 0 sexp)) + ,(factor--fuel-lines (nth 1 sexp)) + ,(factor--fuel-in (nth 2 sexp)) + ,(factor--fuel-usings (nth 3 sexp)) + fuel-eval-in-context))) + +(defsubst factor--fuel-restart (rs) + (unless (member rs '(:rs :nrs)) + (error "Invalid restart spec (%s)" rs)) + rs) + +(defsubst factor--fuel-lines (lst) + (cons :array (mapcar 'factor lst))) + +(defsubst factor--fuel-in (in) + (cond ((null in) :in) + ((eq in t) "fuel-scratchpad") + ((stringp in) in) + (t (error "Invalid 'in' (%s)" in)))) + +(defsubst factor--fuel-usings (usings) + (cond ((null usings) :usings) + ((eq usings t) nil) + ((listp usings) `(:array ,@usings)) + (t (error "Invalid 'usings' (%s)" usings)))) + + + +;;; Code sending: + +(defvar fuel-eval--default-proc-function nil) +(defsubst fuel-eval--default-proc () + (and fuel-eval--default-proc-function + (funcall fuel-eval--default-proc-function))) + +(defvar fuel-eval--proc nil) + +(defvar fuel-eval--sync-retort nil) + +(defun fuel-eval--send/wait (code &optional timeout buffer) + (setq fuel-eval--sync-retort nil) + (fuel-con--send-string/wait (or fuel-eval--proc (fuel-eval--default-proc)) + (if (stringp code) code (factor code)) + '(lambda (s) + (setq fuel-eval--sync-retort + (fuel-eval--parse-retort s))) + timeout + buffer) + fuel-eval--sync-retort) + +(defun fuel-eval--send (code cont &optional buffer) + (fuel-con--send-string (or fuel-eval--proc (fuel-eval--default-proc)) + (if (stringp code) code (factor code)) + `(lambda (s) (,cont (fuel-eval--parse-retort s))) + buffer)) + ;;; Retort and retort-error datatypes: @@ -64,69 +151,6 @@ (defsubst fuel-eval--error-line-text (err) (nth 3 (fuel-eval--error-lexer-p err))) - -;;; String sending:: - -(defvar fuel-eval-log-max-length 16000) - -(defvar fuel-eval--default-proc-function nil) -(defsubst fuel-eval--default-proc () - (and fuel-eval--default-proc-function - (funcall fuel-eval--default-proc-function))) - -(defvar fuel-eval--proc nil) - -(defvar fuel-eval--log t) - -(defvar fuel-eval--sync-retort nil) - -(defun fuel-eval--send/wait (str &optional timeout buffer) - (setq fuel-eval--sync-retort nil) - (fuel-con--send-string/wait (or fuel-eval--proc (fuel-eval--default-proc)) - str - '(lambda (s) - (setq fuel-eval--sync-retort - (fuel-eval--parse-retort s))) - timeout - buffer) - fuel-eval--sync-retort) - -(defun fuel-eval--send (str cont &optional buffer) - (fuel-con--send-string (or fuel-eval--proc (fuel-eval--default-proc)) - str - `(lambda (s) (,cont (fuel-eval--parse-retort s))) - buffer)) - - -;;; Evaluation protocol - -(defsubst fuel-eval--factor-array (strs) - (format "V{ %S }" (mapconcat 'identity strs " "))) - -(defun fuel-eval--cmd/lines (strs &optional no-rs in usings) - (unless (and in usings) (fuel-syntax--usings-update)) - (let* ((in (cond ((not in) (or fuel-syntax--current-vocab "f")) - ((eq in t) "fuel-scratchpad") - (in in))) - (usings (cond ((not usings) fuel-syntax--usings) - ((eq usings t) nil) - (usings usings)))) - (format "fuel-eval-%srestartable %s %S %s fuel-eval-in-context" - (if no-rs "non-" "") - (fuel-eval--factor-array strs) - in - (fuel-eval--factor-array usings)))) - -(defsubst fuel-eval--cmd/string (str &optional no-rs in usings) - (fuel-eval--cmd/lines (list str) no-rs in usings)) - -(defun fuel-eval--cmd/region (begin end &optional no-rs in usings) - (let ((lines (split-string (buffer-substring-no-properties begin end) - "[\f\n\r\v]+" t))) - (when (> (length lines) 0) - (fuel-eval--cmd/lines lines no-rs in usings)))) - - (provide 'fuel-eval) ;;; fuel-eval.el ends here diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el index 1d39d1571d..d4bf757cd7 100644 --- a/misc/fuel/fuel-help.el +++ b/misc/fuel/fuel-help.el @@ -75,8 +75,7 @@ (let ((word (or word (fuel-syntax-symbol-at-point))) (fuel-eval--log t)) (when word - (let* ((str (format "\\ %s synopsis fuel-eval-set-result" word)) - (cmd (fuel-eval--cmd/string str t t)) + (let* ((cmd `(:fuel* (((:quote ,word) synopsis :get)) t)) (ret (fuel-eval--send/wait cmd 20))) (when (and ret (not (fuel-eval--retort-error ret))) (if fuel-help-minibuffer-font-lock @@ -151,10 +150,9 @@ displayed in the minibuffer." fuel-help-always-ask)) (def (if ask (read-string prompt nil 'fuel-help--prompt-history def) def)) - (cmd (format "\\ %s %s" def (if see "see" "help")))) + (cmd `(:fuel* ((:quote ,def) ,(if see 'see 'help)) t))) (message "Looking up '%s' ..." def) - (fuel-eval--send (fuel-eval--cmd/string cmd t t) - `(lambda (r) (fuel-help--show-help-cont ,def r))))) + (fuel-eval--send cmd `(lambda (r) (fuel-help--show-help-cont ,def r))))) (defun fuel-help--show-help-cont (def ret) (let ((out (fuel-eval--retort-output ret))) diff --git a/misc/fuel/fuel-log.el b/misc/fuel/fuel-log.el new file mode 100644 index 0000000000..ba048a6157 --- /dev/null +++ b/misc/fuel/fuel-log.el @@ -0,0 +1,72 @@ +;;; fuel-log.el -- logging utilities + +;; Copyright (C) 2008 Jose Antonio Ortega Ruiz +;; See http://factorcode.org/license.txt for BSD license. + +;; Author: Jose Antonio Ortega Ruiz +;; Keywords: languages, fuel, factor +;; Start date: Sun Dec 14, 2008 01:00 + +;;; Comentary: + +;; Some utilities for maintaining a simple log buffer, mainly for +;; debugging purposes. + +;;; Code: + +(require 'fuel-base) + + +;;; Customization: + +(defvar fuel-log--buffer-name "*fuel messages*" + "Name of the log buffer") + +(defvar fuel-log--max-buffer-size 32000 + "Maximum size of the Factor messages log") + +(defvar fuel-log--max-message-size 512 + "Maximum size of individual log messages") + +(defvar fuel-log--verbose-p t + "Log level for Factor messages") + +(define-derived-mode factor-messages-mode fundamental-mode "FUEL Messages" + "Simple mode to log interactions with the factor listener" + (kill-all-local-variables) + (buffer-disable-undo) + (set (make-local-variable 'comint-redirect-subvert-readonly) t) + (add-hook 'after-change-functions + '(lambda (b e len) + (let ((inhibit-read-only t)) + (when (> b fuel-log--max-buffer-size) + (delete-region (point-min) b)))) + nil t) + (setq buffer-read-only t)) + +(defun fuel-log--buffer () + (or (get-buffer fuel-log--buffer-name) + (save-current-buffer + (set-buffer (get-buffer-create fuel-log--buffer-name)) + (factor-messages-mode) + (current-buffer)))) + +(defun fuel-log--msg (type &rest args) + (with-current-buffer (fuel-log--buffer) + (let ((inhibit-read-only t)) + (insert + (fuel--shorten-str (format "\n%s: %s\n" type (apply 'format args)) + fuel-log--max-message-size))))) + +(defsubst fuel-log--warn (&rest args) + (apply 'fuel-log--msg 'WARNING args)) + +(defsubst fuel-log--error (&rest args) + (apply 'fuel-log--msg 'ERROR args)) + +(defsubst fuel-log--info (&rest args) + (if fuel-log--verbose-p (apply 'fuel-log--msg 'INFO args) "")) + + +(provide 'fuel-log) +;;; fuel-log.el ends here diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index fbfe614526..2dc15ce272 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -49,7 +49,7 @@ With prefix argument, ask for the file to run." (when buffer (with-current-buffer buffer (message "Compiling %s ..." file) - (fuel-eval--send (fuel-eval--cmd/string (format "%S fuel-run-file" file)) + (fuel-eval--send `(:fuel (,file fuel-run-file)) `(lambda (r) (fuel--run-file-cont r ,file))))))) (defun fuel--run-file-cont (ret file) @@ -65,15 +65,18 @@ With prefix argument, ask for the file to run." Unless called with a prefix, switchs to the compilation results buffer in case of errors." (interactive "r\nP") - (fuel-debug--display-retort - (fuel-eval--send/wait (fuel-eval--cmd/region begin end) 10000) - (format "%s%s" - (if fuel-syntax--current-vocab - (format "IN: %s " fuel-syntax--current-vocab) - "") - (fuel--shorten-region begin end 70)) - arg - (buffer-file-name))) + (let* ((lines (split-string (buffer-substring-no-properties begin end) + "[\f\n\r\v]+" t)) + (cmd `(:fuel (,(mapcar (lambda (l) `(:factor ,l)) lines))))) + (fuel-debug--display-retort + (fuel-eval--send/wait cmd 10000) + (format "%s%s" + (if fuel-syntax--current-vocab + (format "IN: %s " fuel-syntax--current-vocab) + "") + (fuel--shorten-region begin end 70)) + arg + (buffer-file-name)))) (defun fuel-eval-extended-region (begin end &optional arg) "Sends region extended outwards to nearest definitions, @@ -119,17 +122,16 @@ With prefix, asks for the word to edit." (if word (format " (%s)" word) "")) word) word))) - (let ((str (fuel-eval--cmd/string - (format "\\ %s fuel-get-edit-location" word)))) + (let ((cmd `(:fuel ((:quote ,word) fuel-get-edit-location)))) (condition-case nil - (fuel--try-edit (fuel-eval--send/wait str)) + (fuel--try-edit (fuel-eval--send/wait cmd)) (error (fuel-edit-vocabulary word)))))) (defvar fuel--vocabs-prompt-history nil) (defun fuel--read-vocabulary-name () - (let* ((str (fuel-eval--cmd/string "fuel-get-vocabs" t "fuel" t)) - (vocabs (fuel-eval--retort-result (fuel-eval--send/wait str))) + (let* ((cmd '(:fuel* (fuel-get-vocabs) "fuel" t)) + (vocabs (fuel-eval--retort-result (fuel-eval--send/wait cmd))) (prompt "Vocabulary name: ")) (if vocabs (completing-read prompt vocabs nil t nil fuel--vocabs-prompt-history) @@ -139,9 +141,8 @@ With prefix, asks for the word to edit." "Visits vocabulary file in Emacs. When called interactively, asks for vocabulary with completion." (interactive (list (fuel--read-vocabulary-name))) - (let* ((str (fuel-eval--cmd/string - (format "%S fuel-get-vocab-location" vocab) t "fuel" t))) - (fuel--try-edit (fuel-eval--send/wait str)))) + (let* ((cmd `(:fuel* (,vocab fuel-get-vocab-location) "fuel" t))) + (fuel--try-edit (fuel-eval--send/wait cmd)))) ;;; Minor mode definition: diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index e9de3a64fa..ff8126c507 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -259,7 +259,8 @@ (defun fuel-syntax--usings-update () (save-excursion - (setq fuel-syntax--usings (list (fuel-syntax--current-vocab))) + (let ((in (fuel-syntax--current-vocab))) + (setq fuel-syntax--usings (and in (list in)))) (while (re-search-backward fuel-syntax--using-lines-regex nil t) (dolist (u (split-string (match-string-no-properties 1) nil t)) (push u fuel-syntax--usings))) From 50e214c1529717183b9b8b609b29a6d09ee7d9d4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 14 Dec 2008 20:03:00 -0600 Subject: [PATCH 05/19] io.files split up and general refactoring work in progress --- basis/bootstrap/io/io.factor | 7 +- basis/bootstrap/stage2.factor | 12 +- basis/command-line/command-line.factor | 4 +- basis/debugger/debugger.factor | 8 +- basis/editors/gvim/unix/unix.factor | 3 +- basis/editors/gvim/windows/windows.factor | 4 +- basis/ftp/server/server.factor | 2 +- basis/io/{ => backend}/unix/authors.txt | 0 .../backend => backend/unix/bsd}/authors.txt | 0 basis/io/{ => backend}/unix/bsd/bsd.factor | 6 +- .../backend => backend/unix/bsd}/tags.txt | 0 basis/io/backend/unix/freebsd/freebsd.factor | 3 + .../bsd => backend/unix/freebsd}/tags.txt | 0 .../bsd => backend/unix/linux}/authors.txt | 0 .../io/{ => backend}/unix/linux/linux.factor | 7 +- .../epoll => backend/unix/linux}/tags.txt | 0 .../{ => backend}/unix/macosx/macosx.factor | 6 +- .../bsd => backend/unix/macosx}/tags.txt | 0 .../unix/multiplexers}/epoll/authors.txt | 0 .../unix/multiplexers/epoll/epoll.factor | 6 +- .../unix/multiplexers/epoll}/tags.txt | 0 .../unix/multiplexers/kqueue}/authors.txt | 0 .../unix/multiplexers/kqueue/kqueue.factor | 6 +- .../unix/multiplexers/kqueue}/tags.txt | 0 .../unix/multiplexers/multiplexers.factor | 2 +- .../multiplexers/run-loop/run-loop.factor | 6 +- .../unix/multiplexers/run-loop}/tags.txt | 0 .../unix/multiplexers/select}/authors.txt | 0 .../unix/multiplexers/select/select.factor | 4 +- .../unix/multiplexers/select}/tags.txt | 0 basis/io/backend/unix/netbsd/netbsd.factor | 3 + .../openbsd => backend/unix/netbsd}/tags.txt | 0 basis/io/backend/unix/openbsd/openbsd.factor | 3 + .../files => backend/unix/openbsd}/tags.txt | 0 .../backend => backend/unix}/summary.txt | 0 .../files/unique => backend/unix}/tags.txt | 0 basis/io/{ => backend}/unix/unix-tests.factor | 2 +- .../unix/unix.factor} | 4 +- basis/io/{ => backend}/windows/authors.txt | 0 .../windows/nt}/authors.txt | 0 .../windows/nt/nt.factor} | 4 +- .../windows/nt/privileges/privileges.factor | 6 +- .../windows/nt/privileges}/tags.txt | 0 .../kqueue => backend/windows/nt}/tags.txt | 0 .../windows/privileges/privileges.factor | 6 +- .../windows/privileges}/tags.txt | 0 basis/io/{ => backend}/windows/summary.txt | 0 .../launcher => backend/windows}/tags.txt | 0 basis/io/{ => backend}/windows/windows.factor | 2 +- basis/io/directories/directories-docs.factor | 191 +++++++++ basis/io/directories/directories-tests.factor | 199 ++++++++++ basis/io/directories/directories.factor | 112 ++++++ .../mmap => directories/search}/authors.txt | 0 .../io/directories/search/search-tests.factor | 11 + basis/io/directories/search/search.factor | 58 +++ .../search/windows}/authors.txt | 0 .../search/windows}/tags.txt | 0 .../directories/search/windows/windows.factor | 13 + basis/io/directories/unix/unix.factor | 75 ++++ basis/io/encodings/binary/authors.txt | 1 + basis/io/encodings/binary/binary-docs.factor | 11 + basis/io/encodings/binary/binary.factor | 8 + basis/io/encodings/binary/summary.txt | 1 + basis/io/encodings/binary/tags.txt | 1 + basis/io/files/info/info-docs.factor | 76 ++++ basis/io/files/info/info-tests.factor | 16 + basis/io/files/info/info.factor | 38 ++ .../files => files/info/unix}/bsd/bsd.factor | 7 +- .../linux => files/info/unix/bsd}/tags.txt | 0 .../info/unix}/freebsd/freebsd.factor | 6 +- .../info/unix/freebsd}/tags.txt | 0 .../info/unix}/linux/linux.factor | 6 +- .../macosx => files/info/unix/linux}/tags.txt | 0 .../info/unix}/macosx/macosx.factor | 7 +- .../mmap => files/info/unix/macosx}/tags.txt | 0 .../info/unix}/netbsd/netbsd.factor | 7 +- .../epoll => files/info/unix/netbsd}/tags.txt | 0 .../info/unix}/openbsd/openbsd.factor | 6 +- .../info/unix/openbsd}/tags.txt | 0 .../info/unix/unix.factor} | 139 +------ basis/io/files/links/links-docs.factor | 26 ++ basis/io/files/links/links.factor | 10 + basis/io/files/links/unix/unix.factor | 10 + basis/io/files/unique/unique.factor | 4 +- .../run-loop => files/unique/unix}/tags.txt | 0 .../unique/unix/unix.factor} | 4 +- .../select => files/unique/windows}/tags.txt | 0 .../unique/windows/windows.factor} | 6 +- .../{unix/launcher => files/unix}/authors.txt | 0 .../io/{unix/files => files/unix}/summary.txt | 0 basis/io/{unix/netbsd => files/unix}/tags.txt | 0 .../unix/unix-docs.factor} | 12 +- .../unix/unix-tests.factor} | 4 +- basis/io/files/unix/unix.factor | 40 ++ .../files => files/windows}/files.factor | 4 +- .../nt/files => files/windows/nt}/authors.txt | 0 .../windows/nt}/files-tests.factor | 4 +- .../files => files/windows/nt}/files.factor | 6 +- .../openbsd => files/windows/nt}/tags.txt | 0 .../io/{unix/pipes => files/windows}/tags.txt | 0 basis/io/launcher/launcher.factor | 6 +- .../{unix/linux => launcher/unix}/authors.txt | 0 .../unix}/parser/parser-tests.factor | 4 +- .../unix}/parser/parser.factor | 2 +- .../select => launcher/unix/parser}/tags.txt | 0 .../sockets/secure => launcher/unix}/tags.txt | 0 .../unix/unix-tests.factor} | 2 +- .../unix/unix.factor} | 6 +- .../launcher => launcher/windows}/authors.txt | 0 .../windows/nt}/authors.txt | 0 .../windows/nt/nt-tests.factor} | 2 +- .../windows/nt/nt.factor} | 6 +- .../sockets => launcher/windows/nt}/tags.txt | 0 .../windows/nt}/test/append.factor | 0 .../windows/nt}/test/env.factor | 0 .../windows/nt}/test/stderr.factor | 0 basis/io/{unix => launcher/windows}/tags.txt | 0 .../windows/windows-tests.factor} | 4 +- .../windows/windows.factor} | 4 +- basis/io/mmap/mmap.factor | 4 +- basis/io/{unix/mmap => mmap/unix}/authors.txt | 0 .../io/{windows/files => mmap/unix}/tags.txt | 0 .../mmap.factor => mmap/unix/unix.factor} | 4 +- basis/io/mmap/windows/authors.txt | 1 + .../files/unique => mmap/windows}/tags.txt | 0 .../windows/windows.factor} | 4 +- .../linux/linux-tests.factor} | 2 +- .../linux/linux.factor} | 4 +- .../launcher => monitors/linux}/tags.txt | 0 .../macosx/macosx.factor} | 2 +- .../mmap => monitors/macosx}/tags.txt | 0 basis/io/monitors/monitors.factor | 6 +- basis/io/monitors/windows/nt/authors.txt | 1 + basis/io/monitors/windows/nt/nt-tests.factor | 4 + .../windows/nt/nt.factor} | 6 +- .../backend => monitors/windows/nt}/tags.txt | 0 basis/io/pipes/pipes.factor | 4 +- .../pipes => pipes/unix}/pipes-tests.factor | 4 +- .../{unix/pipes => pipes/unix}/pipes.factor | 4 +- .../{windows/nt/files => pipes/unix}/tags.txt | 0 .../epoll => pipes/windows/nt}/authors.txt | 0 .../pipes => pipes/windows/nt}/pipes.factor | 4 +- .../nt/launcher => pipes/windows/nt}/tags.txt | 0 basis/io/sockets/secure/secure.factor | 2 +- .../secure/unix}/debug/debug.factor | 2 +- .../monitors => sockets/secure/unix}/tags.txt | 0 .../secure/unix/unix-tests.factor} | 4 +- .../secure/unix/unix.factor} | 4 +- basis/io/sockets/sockets.factor | 5 +- .../kqueue => sockets/unix}/authors.txt | 0 .../sockets => sockets/unix}/summary.txt | 0 .../nt/pipes => sockets/unix}/tags.txt | 0 .../unix/unix.factor} | 6 +- .../windows/nt}/authors.txt | 0 .../windows/nt/nt.factor} | 6 +- .../windows/nt}/tags.txt | 0 .../nt/sockets => sockets/windows}/tags.txt | 0 .../windows/windows.factor} | 4 +- basis/io/unix/epoll/epoll.factor | 63 --- basis/io/unix/freebsd/freebsd.factor | 3 - basis/io/unix/kqueue/kqueue.factor | 74 ---- basis/io/unix/multiplexers/select/authors.txt | 1 - basis/io/unix/netbsd/netbsd.factor | 3 - basis/io/unix/openbsd/openbsd.factor | 3 - basis/io/unix/select/authors.txt | 1 - basis/io/unix/select/select.factor | 56 --- basis/io/unix/sockets/authors.txt | 1 - basis/io/unix/summary.txt | 1 - basis/io/unix/unix.factor | 4 - basis/io/windows/nt/authors.txt | 2 - .../windows/nt/monitors/monitors-tests.factor | 4 - basis/io/windows/nt/nt.factor | 7 - basis/io/windows/nt/pipes/authors.txt | 1 - basis/io/windows/nt/summary.txt | 1 - basis/io/windows/nt/tags.txt | 1 - basis/io/windows/privileges/tags.txt | 1 - basis/io/windows/sockets/tags.txt | 1 - basis/io/windows/tags.txt | 1 - basis/prettyprint/backend/backend.factor | 6 +- basis/prettyprint/prettyprint.factor | 2 +- basis/smtp/server/server.factor | 2 +- basis/tools/deploy/macosx/macosx.factor | 2 +- basis/tools/files/unix/unix.factor | 2 +- basis/unix/groups/groups.factor | 2 +- basis/unix/process/process.factor | 2 +- basis/unix/stat/stat.factor | 2 +- basis/unix/unix.factor | 15 +- basis/unix/users/users.factor | 2 +- core/checksums/checksums.factor | 7 +- core/io/files/files-docs.factor | 375 +----------------- core/io/files/files-tests.factor | 320 +++------------ core/io/files/files.factor | 296 +------------- core/io/io-tests.factor | 50 --- core/io/pathnames/pathnames-docs.factor | 78 ++++ core/io/pathnames/pathnames-tests.factor | 65 +++ core/io/pathnames/pathnames.factor | 143 +++++++ core/source-files/source-files.factor | 6 +- core/syntax/syntax-docs.factor | 2 +- core/syntax/syntax.factor | 2 +- core/vocabs/loader/loader.factor | 8 +- 200 files changed, 1441 insertions(+), 1535 deletions(-) rename basis/io/{ => backend}/unix/authors.txt (100%) rename basis/io/{unix/backend => backend/unix/bsd}/authors.txt (100%) mode change 100644 => 100755 rename basis/io/{ => backend}/unix/bsd/bsd.factor (72%) rename basis/io/{unix/backend => backend/unix/bsd}/tags.txt (100%) create mode 100644 basis/io/backend/unix/freebsd/freebsd.factor rename basis/io/{unix/bsd => backend/unix/freebsd}/tags.txt (100%) rename basis/io/{unix/bsd => backend/unix/linux}/authors.txt (100%) rename basis/io/{ => backend}/unix/linux/linux.factor (50%) rename basis/io/{unix/epoll => backend/unix/linux}/tags.txt (100%) rename basis/io/{ => backend}/unix/macosx/macosx.factor (54%) rename basis/io/{unix/files/bsd => backend/unix/macosx}/tags.txt (100%) rename basis/io/{unix => backend/unix/multiplexers}/epoll/authors.txt (100%) rename basis/io/{ => backend}/unix/multiplexers/epoll/epoll.factor (94%) rename basis/io/{unix/files/freebsd => backend/unix/multiplexers/epoll}/tags.txt (100%) rename basis/io/{unix/files => backend/unix/multiplexers/kqueue}/authors.txt (100%) mode change 100644 => 100755 rename basis/io/{ => backend}/unix/multiplexers/kqueue/kqueue.factor (92%) rename basis/io/{unix/files/linux => backend/unix/multiplexers/kqueue}/tags.txt (100%) rename basis/io/{ => backend}/unix/multiplexers/multiplexers.factor (96%) rename basis/io/{ => backend}/unix/multiplexers/run-loop/run-loop.factor (87%) rename basis/io/{unix/files/macosx => backend/unix/multiplexers/run-loop}/tags.txt (100%) rename basis/io/{unix/kqueue => backend/unix/multiplexers/select}/authors.txt (100%) rename basis/io/{ => backend}/unix/multiplexers/select/select.factor (94%) rename basis/io/{unix/files/netbsd => backend/unix/multiplexers/select}/tags.txt (100%) create mode 100644 basis/io/backend/unix/netbsd/netbsd.factor rename basis/io/{unix/files/openbsd => backend/unix/netbsd}/tags.txt (100%) create mode 100644 basis/io/backend/unix/openbsd/openbsd.factor rename basis/io/{unix/files => backend/unix/openbsd}/tags.txt (100%) rename basis/io/{unix/backend => backend/unix}/summary.txt (100%) rename basis/io/{unix/files/unique => backend/unix}/tags.txt (100%) rename basis/io/{ => backend}/unix/unix-tests.factor (99%) rename basis/io/{unix/backend/backend.factor => backend/unix/unix.factor} (98%) rename basis/io/{ => backend}/windows/authors.txt (100%) rename basis/io/{windows/nt/backend => backend/windows/nt}/authors.txt (100%) rename basis/io/{windows/nt/backend/backend.factor => backend/windows/nt/nt.factor} (97%) rename basis/io/{ => backend}/windows/nt/privileges/privileges.factor (88%) rename basis/io/{unix/freebsd => backend/windows/nt/privileges}/tags.txt (100%) rename basis/io/{unix/kqueue => backend/windows/nt}/tags.txt (100%) rename basis/io/{ => backend}/windows/privileges/privileges.factor (61%) rename basis/io/{unix/launcher/parser => backend/windows/privileges}/tags.txt (100%) rename basis/io/{ => backend}/windows/summary.txt (100%) rename basis/io/{unix/launcher => backend/windows}/tags.txt (100%) mode change 100644 => 100755 rename basis/io/{ => backend}/windows/windows.factor (98%) create mode 100644 basis/io/directories/directories-docs.factor create mode 100644 basis/io/directories/directories-tests.factor create mode 100644 basis/io/directories/directories.factor rename basis/io/{windows/mmap => directories/search}/authors.txt (100%) create mode 100644 basis/io/directories/search/search-tests.factor create mode 100755 basis/io/directories/search/search.factor rename basis/io/{windows/nt/monitors => directories/search/windows}/authors.txt (100%) mode change 100755 => 100644 rename basis/io/{unix/linux/monitors => directories/search/windows}/tags.txt (100%) create mode 100644 basis/io/directories/search/windows/windows.factor create mode 100644 basis/io/directories/unix/unix.factor create mode 100644 basis/io/encodings/binary/authors.txt create mode 100644 basis/io/encodings/binary/binary-docs.factor create mode 100644 basis/io/encodings/binary/binary.factor create mode 100644 basis/io/encodings/binary/summary.txt create mode 100644 basis/io/encodings/binary/tags.txt create mode 100644 basis/io/files/info/info-docs.factor create mode 100644 basis/io/files/info/info-tests.factor create mode 100644 basis/io/files/info/info.factor rename basis/io/{unix/files => files/info/unix}/bsd/bsd.factor (76%) rename basis/io/{unix/linux => files/info/unix/bsd}/tags.txt (100%) rename basis/io/{unix/files => files/info/unix}/freebsd/freebsd.factor (93%) rename basis/io/{unix/macosx/monitors => files/info/unix/freebsd}/tags.txt (100%) rename basis/io/{unix/files => files/info/unix}/linux/linux.factor (94%) rename basis/io/{unix/macosx => files/info/unix/linux}/tags.txt (100%) rename basis/io/{unix/files => files/info/unix}/macosx/macosx.factor (91%) rename basis/io/{unix/mmap => files/info/unix/macosx}/tags.txt (100%) rename basis/io/{unix/files => files/info/unix}/netbsd/netbsd.factor (91%) rename basis/io/{unix/multiplexers/epoll => files/info/unix/netbsd}/tags.txt (100%) rename basis/io/{unix/files => files/info/unix}/openbsd/openbsd.factor (93%) rename basis/io/{unix/multiplexers/kqueue => files/info/unix/openbsd}/tags.txt (100%) rename basis/io/{unix/files/files.factor => files/info/unix/unix.factor} (65%) create mode 100644 basis/io/files/links/links-docs.factor create mode 100644 basis/io/files/links/links.factor create mode 100644 basis/io/files/links/unix/unix.factor rename basis/io/{unix/multiplexers/run-loop => files/unique/unix}/tags.txt (100%) rename basis/io/{unix/files/unique/unique.factor => files/unique/unix/unix.factor} (81%) rename basis/io/{unix/multiplexers/select => files/unique/windows}/tags.txt (100%) rename basis/io/{windows/files/unique/unique.factor => files/unique/windows/windows.factor} (54%) rename basis/io/{unix/launcher => files/unix}/authors.txt (100%) mode change 100755 => 100644 rename basis/io/{unix/files => files/unix}/summary.txt (100%) rename basis/io/{unix/netbsd => files/unix}/tags.txt (100%) rename basis/io/{unix/files/files-docs.factor => files/unix/unix-docs.factor} (97%) rename basis/io/{unix/files/files-tests.factor => files/unix/unix-tests.factor} (98%) create mode 100644 basis/io/files/unix/unix.factor rename basis/io/{windows/files => files/windows}/files.factor (99%) rename basis/io/{windows/nt/files => files/windows/nt}/authors.txt (100%) rename basis/io/{windows/nt/files => files/windows/nt}/files-tests.factor (96%) rename basis/io/{windows/nt/files => files/windows/nt}/files.factor (92%) rename basis/io/{unix/openbsd => files/windows/nt}/tags.txt (100%) rename basis/io/{unix/pipes => files/windows}/tags.txt (100%) rename basis/io/{unix/linux => launcher/unix}/authors.txt (100%) rename basis/io/{unix/launcher => launcher/unix}/parser/parser-tests.factor (95%) rename basis/io/{unix/launcher => launcher/unix}/parser/parser.factor (96%) rename basis/io/{unix/select => launcher/unix/parser}/tags.txt (100%) rename basis/io/{unix/sockets/secure => launcher/unix}/tags.txt (100%) rename basis/io/{unix/launcher/launcher-tests.factor => launcher/unix/unix-tests.factor} (99%) rename basis/io/{unix/launcher/launcher.factor => launcher/unix/unix.factor} (97%) rename basis/io/{windows/launcher => launcher/windows}/authors.txt (100%) rename basis/io/{windows/nt/launcher => launcher/windows/nt}/authors.txt (100%) rename basis/io/{windows/nt/launcher/launcher-tests.factor => launcher/windows/nt/nt-tests.factor} (99%) rename basis/io/{windows/nt/launcher/launcher.factor => launcher/windows/nt/nt.factor} (95%) rename basis/io/{unix/sockets => launcher/windows/nt}/tags.txt (100%) rename basis/io/{windows/nt/launcher => launcher/windows/nt}/test/append.factor (100%) rename basis/io/{windows/nt/launcher => launcher/windows/nt}/test/env.factor (100%) rename basis/io/{windows/nt/launcher => launcher/windows/nt}/test/stderr.factor (100%) rename basis/io/{unix => launcher/windows}/tags.txt (100%) rename basis/io/{windows/launcher/launcher-tests.factor => launcher/windows/windows-tests.factor} (79%) rename basis/io/{windows/launcher/launcher.factor => launcher/windows/windows.factor} (98%) rename basis/io/{unix/mmap => mmap/unix}/authors.txt (100%) rename basis/io/{windows/files => mmap/unix}/tags.txt (100%) rename basis/io/{unix/mmap/mmap.factor => mmap/unix/unix.factor} (88%) create mode 100755 basis/io/mmap/windows/authors.txt rename basis/io/{windows/files/unique => mmap/windows}/tags.txt (100%) rename basis/io/{windows/mmap/mmap.factor => mmap/windows/windows.factor} (94%) rename basis/io/{unix/linux/monitors/monitors-tests.factor => monitors/linux/linux-tests.factor} (97%) rename basis/io/{unix/linux/monitors/monitors.factor => monitors/linux/linux.factor} (97%) rename basis/io/{windows/launcher => monitors/linux}/tags.txt (100%) rename basis/io/{unix/macosx/monitors/monitors.factor => monitors/macosx/macosx.factor} (96%) rename basis/io/{windows/mmap => monitors/macosx}/tags.txt (100%) create mode 100755 basis/io/monitors/windows/nt/authors.txt create mode 100644 basis/io/monitors/windows/nt/nt-tests.factor rename basis/io/{windows/nt/monitors/monitors.factor => monitors/windows/nt/nt.factor} (95%) rename basis/io/{windows/nt/backend => monitors/windows/nt}/tags.txt (100%) rename basis/io/{unix/pipes => pipes/unix}/pipes-tests.factor (81%) rename basis/io/{unix/pipes => pipes/unix}/pipes.factor (80%) rename basis/io/{windows/nt/files => pipes/unix}/tags.txt (100%) rename basis/io/{unix/multiplexers/epoll => pipes/windows/nt}/authors.txt (100%) rename basis/io/{windows/nt/pipes => pipes/windows/nt}/pipes.factor (92%) rename basis/io/{windows/nt/launcher => pipes/windows/nt}/tags.txt (100%) rename basis/io/{unix/sockets/secure => sockets/secure/unix}/debug/debug.factor (91%) rename basis/io/{windows/nt/monitors => sockets/secure/unix}/tags.txt (100%) rename basis/io/{unix/sockets/secure/secure-tests.factor => sockets/secure/unix/unix-tests.factor} (97%) rename basis/io/{unix/sockets/secure/secure.factor => sockets/secure/unix/unix.factor} (98%) rename basis/io/{unix/multiplexers/kqueue => sockets/unix}/authors.txt (100%) mode change 100755 => 100644 rename basis/io/{unix/sockets => sockets/unix}/summary.txt (100%) rename basis/io/{windows/nt/pipes => sockets/unix}/tags.txt (100%) rename basis/io/{unix/sockets/sockets.factor => sockets/unix/unix.factor} (96%) rename basis/io/{windows/nt/sockets => sockets/windows/nt}/authors.txt (100%) rename basis/io/{windows/nt/sockets/sockets.factor => sockets/windows/nt/nt.factor} (97%) rename basis/io/{windows/nt/privileges => sockets/windows/nt}/tags.txt (100%) rename basis/io/{windows/nt/sockets => sockets/windows}/tags.txt (100%) rename basis/io/{windows/sockets/sockets.factor => sockets/windows/windows.factor} (92%) delete mode 100644 basis/io/unix/epoll/epoll.factor delete mode 100644 basis/io/unix/freebsd/freebsd.factor delete mode 100644 basis/io/unix/kqueue/kqueue.factor delete mode 100755 basis/io/unix/multiplexers/select/authors.txt delete mode 100644 basis/io/unix/netbsd/netbsd.factor delete mode 100644 basis/io/unix/openbsd/openbsd.factor delete mode 100755 basis/io/unix/select/authors.txt delete mode 100644 basis/io/unix/select/select.factor delete mode 100644 basis/io/unix/sockets/authors.txt delete mode 100644 basis/io/unix/summary.txt delete mode 100644 basis/io/unix/unix.factor delete mode 100644 basis/io/windows/nt/authors.txt delete mode 100644 basis/io/windows/nt/monitors/monitors-tests.factor delete mode 100644 basis/io/windows/nt/nt.factor delete mode 100755 basis/io/windows/nt/pipes/authors.txt delete mode 100644 basis/io/windows/nt/summary.txt delete mode 100644 basis/io/windows/nt/tags.txt delete mode 100644 basis/io/windows/privileges/tags.txt delete mode 100644 basis/io/windows/sockets/tags.txt delete mode 100755 basis/io/windows/tags.txt create mode 100644 core/io/pathnames/pathnames-docs.factor create mode 100644 core/io/pathnames/pathnames-tests.factor create mode 100644 core/io/pathnames/pathnames.factor diff --git a/basis/bootstrap/io/io.factor b/basis/bootstrap/io/io.factor index a38107fbab..b9a49b48b8 100644 --- a/basis/bootstrap/io/io.factor +++ b/basis/bootstrap/io/io.factor @@ -1,12 +1,11 @@ USING: system vocabs vocabs.loader kernel combinators -namespaces sequences io.backend ; +namespaces sequences io.backend accessors ; IN: bootstrap.io "bootstrap.compiler" vocab [ - "io." { + "io.backend." { { [ "io-backend" get ] [ "io-backend" get ] } - { [ os unix? ] [ "unix" ] } + { [ os unix? ] [ "unix." os name>> append ] } { [ os winnt? ] [ "windows.nt" ] } - { [ os wince? ] [ "windows.ce" ] } } cond append require ] when diff --git a/basis/bootstrap/stage2.factor b/basis/bootstrap/stage2.factor index 45a6c354a6..d2b522581d 100644 --- a/basis/bootstrap/stage2.factor +++ b/basis/bootstrap/stage2.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors init namespaces words io -kernel.private math memory continuations kernel io.files -io.backend system parser vocabs sequences -vocabs.loader combinators splitting source-files strings -definitions assocs compiler.errors compiler.units -math.parser generic sets command-line ; +USING: accessors init namespaces words io kernel.private math +memory continuations kernel io.files io.pathnames io.backend +system parser vocabs sequences vocabs.loader combinators +splitting source-files strings definitions assocs +compiler.errors compiler.units math.parser generic sets +command-line ; IN: bootstrap.stage2 SYMBOL: core-bootstrap-time diff --git a/basis/command-line/command-line.factor b/basis/command-line/command-line.factor index 7d5a041951..38d40d8482 100644 --- a/basis/command-line/command-line.factor +++ b/basis/command-line/command-line.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: init continuations hashtables io io.encodings.utf8 -io.files kernel kernel.private namespaces parser sequences -strings system splitting vocabs.loader ; +io.files io.pathnames kernel kernel.private namespaces parser +sequences strings system splitting vocabs.loader ; IN: command-line SYMBOL: script diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 4e0c4e8840..885e2e303c 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: slots arrays definitions generic hashtables summary io kernel math namespaces make prettyprint prettyprint.config -sequences assocs sequences.private strings io.styles io.files -vectors words system splitting math.parser classes.mixin -classes.tuple continuations continuations.private combinators -generic.math classes.builtin classes compiler.units +sequences assocs sequences.private strings io.styles +io.pathnames vectors words system splitting math.parser +classes.mixin classes.tuple continuations continuations.private +combinators generic.math classes.builtin classes compiler.units generic.standard vocabs init kernel.private io.encodings accessors math.order destructors source-files parser classes.tuple.parser effects.parser lexer compiler.errors diff --git a/basis/editors/gvim/unix/unix.factor b/basis/editors/gvim/unix/unix.factor index 82b6bf199d..3e2a42e6e5 100644 --- a/basis/editors/gvim/unix/unix.factor +++ b/basis/editors/gvim/unix/unix.factor @@ -1,5 +1,4 @@ -USING: io.unix.backend kernel namespaces editors.gvim -system ; +USING: kernel namespaces editors.gvim system ; IN: editors.gvim.unix M: unix gvim-path diff --git a/basis/editors/gvim/windows/windows.factor b/basis/editors/gvim/windows/windows.factor index 2f733f3c2f..1a6f8e902c 100644 --- a/basis/editors/gvim/windows/windows.factor +++ b/basis/editors/gvim/windows/windows.factor @@ -1,5 +1,5 @@ -USING: editors.gvim io.files io.windows kernel namespaces -sequences windows.shell32 io.paths.windows system ; +USING: editors.gvim io.files kernel namespaces sequences +windows.shell32 io.paths.windows system ; IN: editors.gvim.windows M: windows gvim-path diff --git a/basis/ftp/server/server.factor b/basis/ftp/server/server.factor index b0ec340202..ca27cbb784 100644 --- a/basis/ftp/server/server.factor +++ b/basis/ftp/server/server.factor @@ -3,7 +3,7 @@ USING: combinators.short-circuit accessors combinators io io.encodings.8-bit io.encodings io.encodings.binary io.encodings.utf8 io.files io.sockets kernel math.parser -namespaces make sequences ftp io.unix.launcher.parser +namespaces make sequences ftp io.launcher.unix.parser unicode.case splitting assocs classes io.servers.connection destructors calendar io.timeouts io.streams.duplex threads continuations math concurrency.promises byte-arrays diff --git a/basis/io/unix/authors.txt b/basis/io/backend/unix/authors.txt similarity index 100% rename from basis/io/unix/authors.txt rename to basis/io/backend/unix/authors.txt diff --git a/basis/io/unix/backend/authors.txt b/basis/io/backend/unix/bsd/authors.txt old mode 100644 new mode 100755 similarity index 100% rename from basis/io/unix/backend/authors.txt rename to basis/io/backend/unix/bsd/authors.txt diff --git a/basis/io/unix/bsd/bsd.factor b/basis/io/backend/unix/bsd/bsd.factor similarity index 72% rename from basis/io/unix/bsd/bsd.factor rename to basis/io/backend/unix/bsd/bsd.factor index 83f063d713..e0a675a8fc 100644 --- a/basis/io/unix/bsd/bsd.factor +++ b/basis/io/backend/unix/bsd/bsd.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces system kernel accessors assocs continuations -unix io.backend io.unix.backend io.unix.multiplexers -io.unix.multiplexers.kqueue ; -IN: io.unix.bsd +unix io.backend io.backend.unix io.backend.unix.multiplexers +io.backend.unix.multiplexers.kqueue io.files.unix ; +IN: io.backend.unix.bsd M: bsd init-io ( -- ) mx set-global ; diff --git a/basis/io/unix/backend/tags.txt b/basis/io/backend/unix/bsd/tags.txt similarity index 100% rename from basis/io/unix/backend/tags.txt rename to basis/io/backend/unix/bsd/tags.txt diff --git a/basis/io/backend/unix/freebsd/freebsd.factor b/basis/io/backend/unix/freebsd/freebsd.factor new file mode 100644 index 0000000000..1c0471b330 --- /dev/null +++ b/basis/io/backend/unix/freebsd/freebsd.factor @@ -0,0 +1,3 @@ +USING: io.backend.unix.bsd io.backend system ; + +freebsd set-io-backend diff --git a/basis/io/unix/bsd/tags.txt b/basis/io/backend/unix/freebsd/tags.txt similarity index 100% rename from basis/io/unix/bsd/tags.txt rename to basis/io/backend/unix/freebsd/tags.txt diff --git a/basis/io/unix/bsd/authors.txt b/basis/io/backend/unix/linux/authors.txt similarity index 100% rename from basis/io/unix/bsd/authors.txt rename to basis/io/backend/unix/linux/authors.txt diff --git a/basis/io/unix/linux/linux.factor b/basis/io/backend/unix/linux/linux.factor similarity index 50% rename from basis/io/unix/linux/linux.factor rename to basis/io/backend/unix/linux/linux.factor index fd24e0ac02..54b20d1b44 100644 --- a/basis/io/unix/linux/linux.factor +++ b/basis/io/backend/unix/linux/linux.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel system namespaces io.backend io.unix.backend -io.unix.multiplexers io.unix.multiplexers.epoll ; -IN: io.unix.linux +USING: kernel system namespaces io.files.unix io.backend +io.backend.unix io.backend.unix.multiplexers +io.backend.unix.multiplexers.epoll ; +IN: io.backend.unix.linux M: linux init-io ( -- ) mx set-global ; diff --git a/basis/io/unix/epoll/tags.txt b/basis/io/backend/unix/linux/tags.txt similarity index 100% rename from basis/io/unix/epoll/tags.txt rename to basis/io/backend/unix/linux/tags.txt diff --git a/basis/io/unix/macosx/macosx.factor b/basis/io/backend/unix/macosx/macosx.factor similarity index 54% rename from basis/io/unix/macosx/macosx.factor rename to basis/io/backend/unix/macosx/macosx.factor index 75f42b7394..e669875448 100644 --- a/basis/io/unix/macosx/macosx.factor +++ b/basis/io/backend/unix/macosx/macosx.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.backend system namespaces io.unix.multiplexers -io.unix.multiplexers.run-loop ; -IN: io.unix.macosx +USING: io.backend system namespaces io.backend.unix.bsd +io.backend.unix.multiplexers io.backend.unix.multiplexers.run-loop ; +IN: io.backend.macosx M: macosx init-io ( -- ) mx set-global ; diff --git a/basis/io/unix/files/bsd/tags.txt b/basis/io/backend/unix/macosx/tags.txt similarity index 100% rename from basis/io/unix/files/bsd/tags.txt rename to basis/io/backend/unix/macosx/tags.txt diff --git a/basis/io/unix/epoll/authors.txt b/basis/io/backend/unix/multiplexers/epoll/authors.txt similarity index 100% rename from basis/io/unix/epoll/authors.txt rename to basis/io/backend/unix/multiplexers/epoll/authors.txt diff --git a/basis/io/unix/multiplexers/epoll/epoll.factor b/basis/io/backend/unix/multiplexers/epoll/epoll.factor similarity index 94% rename from basis/io/unix/multiplexers/epoll/epoll.factor rename to basis/io/backend/unix/multiplexers/epoll/epoll.factor index 08e20d4b95..a91f62f1df 100644 --- a/basis/io/unix/multiplexers/epoll/epoll.factor +++ b/basis/io/backend/unix/multiplexers/epoll/epoll.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types kernel destructors bit-arrays sequences assocs struct-arrays math namespaces locals fry unix -unix.linux.epoll unix.time io.ports io.unix.backend -io.unix.multiplexers ; -IN: io.unix.multiplexers.epoll +unix.linux.epoll unix.time io.ports io.backend.unix +io.backend.unix.multiplexers ; +IN: io.backend.unix.multiplexers.epoll TUPLE: epoll-mx < mx events ; diff --git a/basis/io/unix/files/freebsd/tags.txt b/basis/io/backend/unix/multiplexers/epoll/tags.txt similarity index 100% rename from basis/io/unix/files/freebsd/tags.txt rename to basis/io/backend/unix/multiplexers/epoll/tags.txt diff --git a/basis/io/unix/files/authors.txt b/basis/io/backend/unix/multiplexers/kqueue/authors.txt old mode 100644 new mode 100755 similarity index 100% rename from basis/io/unix/files/authors.txt rename to basis/io/backend/unix/multiplexers/kqueue/authors.txt diff --git a/basis/io/unix/multiplexers/kqueue/kqueue.factor b/basis/io/backend/unix/multiplexers/kqueue/kqueue.factor similarity index 92% rename from basis/io/unix/multiplexers/kqueue/kqueue.factor rename to basis/io/backend/unix/multiplexers/kqueue/kqueue.factor index a66e86a6a7..2a6648981b 100644 --- a/basis/io/unix/multiplexers/kqueue/kqueue.factor +++ b/basis/io/backend/unix/multiplexers/kqueue/kqueue.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types combinators destructors -io.unix.backend kernel math.bitwise sequences struct-arrays unix -unix.kqueue unix.time assocs io.unix.multiplexers ; -IN: io.unix.multiplexers.kqueue +io.backend.unix kernel math.bitwise sequences struct-arrays unix +unix.kqueue unix.time assocs io.backend.unix.multiplexers ; +IN: io.backend.unix.multiplexers.kqueue TUPLE: kqueue-mx < mx events ; diff --git a/basis/io/unix/files/linux/tags.txt b/basis/io/backend/unix/multiplexers/kqueue/tags.txt similarity index 100% rename from basis/io/unix/files/linux/tags.txt rename to basis/io/backend/unix/multiplexers/kqueue/tags.txt diff --git a/basis/io/unix/multiplexers/multiplexers.factor b/basis/io/backend/unix/multiplexers/multiplexers.factor similarity index 96% rename from basis/io/unix/multiplexers/multiplexers.factor rename to basis/io/backend/unix/multiplexers/multiplexers.factor index 1c9fb134e7..844670d635 100644 --- a/basis/io/unix/multiplexers/multiplexers.factor +++ b/basis/io/backend/unix/multiplexers/multiplexers.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors assocs sequences threads ; -IN: io.unix.multiplexers +IN: io.backend.unix.multiplexers TUPLE: mx fd reads writes ; diff --git a/basis/io/unix/multiplexers/run-loop/run-loop.factor b/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor similarity index 87% rename from basis/io/unix/multiplexers/run-loop/run-loop.factor rename to basis/io/backend/unix/multiplexers/run-loop/run-loop.factor index 4b2486d19f..84a609643a 100644 --- a/basis/io/unix/multiplexers/run-loop/run-loop.factor +++ b/basis/io/backend/unix/multiplexers/run-loop/run-loop.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel arrays namespaces math accessors alien locals -destructors system threads io.unix.multiplexers -io.unix.multiplexers.kqueue core-foundation +destructors system threads io.backend.unix.multiplexers +io.backend.unix.multiplexers.kqueue core-foundation core-foundation.run-loop ; -IN: io.unix.multiplexers.run-loop +IN: io.backend.unix.multiplexers.run-loop TUPLE: run-loop-mx kqueue-mx ; diff --git a/basis/io/unix/files/macosx/tags.txt b/basis/io/backend/unix/multiplexers/run-loop/tags.txt similarity index 100% rename from basis/io/unix/files/macosx/tags.txt rename to basis/io/backend/unix/multiplexers/run-loop/tags.txt diff --git a/basis/io/unix/kqueue/authors.txt b/basis/io/backend/unix/multiplexers/select/authors.txt similarity index 100% rename from basis/io/unix/kqueue/authors.txt rename to basis/io/backend/unix/multiplexers/select/authors.txt diff --git a/basis/io/unix/multiplexers/select/select.factor b/basis/io/backend/unix/multiplexers/select/select.factor similarity index 94% rename from basis/io/unix/multiplexers/select/select.factor rename to basis/io/backend/unix/multiplexers/select/select.factor index 915daac2d3..c62101e478 100644 --- a/basis/io/unix/multiplexers/select/select.factor +++ b/basis/io/backend/unix/multiplexers/select/select.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types kernel bit-arrays sequences assocs unix math namespaces accessors math.order locals unix.time fry -io.ports io.unix.backend io.unix.multiplexers ; -IN: io.unix.multiplexers.select +io.ports io.backend.unix io.backend.unix.multiplexers ; +IN: io.backend.unix.multiplexers.select TUPLE: select-mx < mx read-fdset write-fdset ; diff --git a/basis/io/unix/files/netbsd/tags.txt b/basis/io/backend/unix/multiplexers/select/tags.txt similarity index 100% rename from basis/io/unix/files/netbsd/tags.txt rename to basis/io/backend/unix/multiplexers/select/tags.txt diff --git a/basis/io/backend/unix/netbsd/netbsd.factor b/basis/io/backend/unix/netbsd/netbsd.factor new file mode 100644 index 0000000000..a47be300f8 --- /dev/null +++ b/basis/io/backend/unix/netbsd/netbsd.factor @@ -0,0 +1,3 @@ +USING: io.backend.unix.bsd io.backend system ; + +netbsd set-io-backend diff --git a/basis/io/unix/files/openbsd/tags.txt b/basis/io/backend/unix/netbsd/tags.txt similarity index 100% rename from basis/io/unix/files/openbsd/tags.txt rename to basis/io/backend/unix/netbsd/tags.txt diff --git a/basis/io/backend/unix/openbsd/openbsd.factor b/basis/io/backend/unix/openbsd/openbsd.factor new file mode 100644 index 0000000000..a9e25134de --- /dev/null +++ b/basis/io/backend/unix/openbsd/openbsd.factor @@ -0,0 +1,3 @@ +USING: io.backend.unix.bsd io.backend system ; + +openbsd set-io-backend diff --git a/basis/io/unix/files/tags.txt b/basis/io/backend/unix/openbsd/tags.txt similarity index 100% rename from basis/io/unix/files/tags.txt rename to basis/io/backend/unix/openbsd/tags.txt diff --git a/basis/io/unix/backend/summary.txt b/basis/io/backend/unix/summary.txt similarity index 100% rename from basis/io/unix/backend/summary.txt rename to basis/io/backend/unix/summary.txt diff --git a/basis/io/unix/files/unique/tags.txt b/basis/io/backend/unix/tags.txt similarity index 100% rename from basis/io/unix/files/unique/tags.txt rename to basis/io/backend/unix/tags.txt diff --git a/basis/io/unix/unix-tests.factor b/basis/io/backend/unix/unix-tests.factor similarity index 99% rename from basis/io/unix/unix-tests.factor rename to basis/io/backend/unix/unix-tests.factor index df61420c77..5add7933a7 100644 --- a/basis/io/unix/unix-tests.factor +++ b/basis/io/backend/unix/unix-tests.factor @@ -2,7 +2,7 @@ USING: io.files io.sockets io kernel threads namespaces tools.test continuations strings byte-arrays sequences prettyprint system io.encodings.binary io.encodings.ascii io.streams.duplex destructors make ; -IN: io.unix.tests +IN: io.backend.unix.tests ! Unix domain stream sockets : socket-server "unix-domain-socket-test" temp-file ; diff --git a/basis/io/unix/backend/backend.factor b/basis/io/backend/unix/unix.factor similarity index 98% rename from basis/io/unix/backend/backend.factor rename to basis/io/backend/unix/unix.factor index 41bd03a58b..e8ace90d73 100644 --- a/basis/io/unix/backend/backend.factor +++ b/basis/io/backend/unix/unix.factor @@ -5,9 +5,9 @@ kernel.private math io.ports sequences strings sbufs threads unix vectors io.buffers io.backend io.encodings math.parser continuations system libc qualified namespaces make io.timeouts io.encodings.utf8 destructors accessors summary combinators -locals unix.time fry io.unix.multiplexers ; +locals unix.time fry io.backend.unix.multiplexers ; QUALIFIED: io -IN: io.unix.backend +IN: io.backend.unix GENERIC: handle-fd ( handle -- fd ) diff --git a/basis/io/windows/authors.txt b/basis/io/backend/windows/authors.txt similarity index 100% rename from basis/io/windows/authors.txt rename to basis/io/backend/windows/authors.txt diff --git a/basis/io/windows/nt/backend/authors.txt b/basis/io/backend/windows/nt/authors.txt similarity index 100% rename from basis/io/windows/nt/backend/authors.txt rename to basis/io/backend/windows/nt/authors.txt diff --git a/basis/io/windows/nt/backend/backend.factor b/basis/io/backend/windows/nt/nt.factor similarity index 97% rename from basis/io/windows/nt/backend/backend.factor rename to basis/io/backend/windows/nt/nt.factor index 8035bd66e9..d6c74ed098 100644 --- a/basis/io/windows/nt/backend/backend.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -1,11 +1,11 @@ USING: alien alien.c-types arrays assocs combinators continuations destructors io io.backend io.ports io.timeouts -io.windows io.windows.files io.files io.buffers io.streams.c +io.backend.windows io.files.windows io.files io.buffers io.streams.c libc kernel math namespaces sequences threads windows windows.errors windows.kernel32 strings splitting qualified ascii system accessors locals ; QUALIFIED: windows.winsock -IN: io.windows.nt.backend +IN: io.backend.windows.nt ! Global variable with assoc mapping overlapped to threads SYMBOL: pending-overlapped diff --git a/basis/io/windows/nt/privileges/privileges.factor b/basis/io/backend/windows/nt/privileges/privileges.factor similarity index 88% rename from basis/io/windows/nt/privileges/privileges.factor rename to basis/io/backend/windows/nt/privileges/privileges.factor index 264f337eaf..64218f75b0 100755 --- a/basis/io/windows/nt/privileges/privileges.factor +++ b/basis/io/backend/windows/nt/privileges/privileges.factor @@ -1,9 +1,9 @@ USING: alien alien.c-types alien.syntax arrays continuations -destructors generic io.mmap io.ports io.windows io.windows.files +destructors generic io.mmap io.ports io.backend.windows io.files.windows kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system accessors -io.windows.privileges ; -IN: io.windows.nt.privileges +io.backend.windows.privileges ; +IN: io.backend.windows.nt.privileges TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES diff --git a/basis/io/unix/freebsd/tags.txt b/basis/io/backend/windows/nt/privileges/tags.txt similarity index 100% rename from basis/io/unix/freebsd/tags.txt rename to basis/io/backend/windows/nt/privileges/tags.txt diff --git a/basis/io/unix/kqueue/tags.txt b/basis/io/backend/windows/nt/tags.txt similarity index 100% rename from basis/io/unix/kqueue/tags.txt rename to basis/io/backend/windows/nt/tags.txt diff --git a/basis/io/windows/privileges/privileges.factor b/basis/io/backend/windows/privileges/privileges.factor similarity index 61% rename from basis/io/windows/privileges/privileges.factor rename to basis/io/backend/windows/privileges/privileges.factor index e169bdf12f..8661ba99d9 100644 --- a/basis/io/windows/privileges/privileges.factor +++ b/basis/io/backend/windows/privileges/privileges.factor @@ -1,6 +1,6 @@ USING: io.backend kernel continuations sequences system vocabs.loader combinators ; -IN: io.windows.privileges +IN: io.backend.windows.privileges HOOK: set-privilege io-backend ( name ? -- ) inline @@ -9,6 +9,6 @@ HOOK: set-privilege io-backend ( name ? -- ) inline swap [ [ f set-privilege ] each ] curry [ ] cleanup ; inline { - { [ os winnt? ] [ "io.windows.nt.privileges" require ] } - { [ os wince? ] [ "io.windows.ce.privileges" require ] } + { [ os winnt? ] [ "io.backend.windows.nt.privileges" require ] } + { [ os wince? ] [ "io.backend.windows.ce.privileges" require ] } } cond diff --git a/basis/io/unix/launcher/parser/tags.txt b/basis/io/backend/windows/privileges/tags.txt similarity index 100% rename from basis/io/unix/launcher/parser/tags.txt rename to basis/io/backend/windows/privileges/tags.txt diff --git a/basis/io/windows/summary.txt b/basis/io/backend/windows/summary.txt similarity index 100% rename from basis/io/windows/summary.txt rename to basis/io/backend/windows/summary.txt diff --git a/basis/io/unix/launcher/tags.txt b/basis/io/backend/windows/tags.txt old mode 100644 new mode 100755 similarity index 100% rename from basis/io/unix/launcher/tags.txt rename to basis/io/backend/windows/tags.txt diff --git a/basis/io/windows/windows.factor b/basis/io/backend/windows/windows.factor similarity index 98% rename from basis/io/windows/windows.factor rename to basis/io/backend/windows/windows.factor index 94304edc05..e7c72edfd0 100755 --- a/basis/io/windows/windows.factor +++ b/basis/io/backend/windows/windows.factor @@ -5,7 +5,7 @@ io.buffers io.files io.ports io.binary io.timeouts windows.errors strings kernel math namespaces sequences windows windows.kernel32 windows.shell32 windows.types windows.winsock splitting continuations math.bitwise system accessors ; -IN: io.windows +IN: io.backend.windows : set-inherit ( handle ? -- ) [ HANDLE_FLAG_INHERIT ] dip diff --git a/basis/io/directories/directories-docs.factor b/basis/io/directories/directories-docs.factor new file mode 100644 index 0000000000..1638958e02 --- /dev/null +++ b/basis/io/directories/directories-docs.factor @@ -0,0 +1,191 @@ +IN: io.directories + +HELP: cwd +{ $values { "path" "a pathname string" } } +{ $description "Outputs the current working directory of the Factor process." } +{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } +{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ; + +HELP: cd +{ $values { "path" "a pathname string" } } +{ $description "Changes the current working directory of the Factor process." } +{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } +{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ; + +{ cd cwd current-directory set-current-directory with-directory } related-words + +HELP: current-directory +{ $description "A variable holding the current directory as an absolute path. Words that use the filesystem do so in relation to this variable." +$nl +"This variable should never be set directly; instead, use " { $link set-current-directory } " or " { $link with-directory } ". This preserves the invariant that the value of this variable is an absolute path." } ; + +HELP: set-current-directory +{ $values { "path" "a pathname string" } } +{ $description "Changes the " { $link current-directory } " variable." +$nl +"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ; + +HELP: with-directory +{ $values { "path" "a pathname string" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope with the " { $link current-directory } " variable rebound." +$nl +"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ; + +HELP: (directory-entries) +{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $snippet "{ name dir? }" } " pairs" } } +{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } +{ $notes "This is a low-level word, and user code should call one of the related words instead." } ; + +HELP: directory-entries +{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $link directory-entry } " objects" } } +{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ; + +HELP: directory-files +{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } +{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ; + +HELP: with-directory-files +{ $values { "path" "a pathname string" } { "quot" quotation } } +{ $description "Calls the quotation with the directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ; + +HELP: delete-file +{ $values { "path" "a pathname string" } } +{ $description "Deletes a file." } +{ $errors "Throws an error if the file could not be deleted." } ; + +HELP: make-directory +{ $values { "path" "a pathname string" } } +{ $description "Creates a directory." } +{ $errors "Throws an error if the directory could not be created." } ; + +HELP: make-directories +{ $values { "path" "a pathname string" } } +{ $description "Creates a directory and any parent directories which do not yet exist." } +{ $errors "Throws an error if the directories could not be created." } ; + +HELP: delete-directory +{ $values { "path" "a pathname string" } } +{ $description "Deletes a directory. The directory must be empty." } +{ $errors "Throws an error if the directory could not be deleted." } ; + +HELP: touch-file +{ $values { "path" "a pathname string" } } +{ $description "Updates the modification time of a file or directory. If the file does not exist, creates a new, empty file." } +{ $errors "Throws an error if the file could not be touched." } ; + +HELP: delete-tree +{ $values { "path" "a pathname string" } } +{ $description "Deletes a file or directory, recursing into subdirectories." } +{ $errors "Throws an error if the deletion fails." } +{ $warning "Misuse of this word can lead to catastrophic data loss." } ; + +HELP: move-file +{ $values { "from" "a pathname string" } { "to" "a pathname string" } } +{ $description "Moves or renames a file." } +{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; + +HELP: move-file-into +{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } +{ $description "Moves a file to another directory without renaming it." } +{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; + +HELP: move-files-into +{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } +{ $description "Moves a set of files to another directory." } +{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; + +HELP: copy-file +{ $values { "from" "a pathname string" } { "to" "a pathname string" } } +{ $description "Copies a file." } +{ $notes "This operation attempts to preserve the original file's attributes, however not all attributes may be preserved." } +{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; + +HELP: copy-file-into +{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } +{ $description "Copies a file to another directory." } +{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; + +HELP: copy-files-into +{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } +{ $description "Copies a set of files to another directory." } +{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; + +HELP: copy-tree +{ $values { "from" "a pathname string" } { "to" "a pathname string" } } +{ $description "Copies a directory tree recursively." } +{ $notes "This operation attempts to preserve original file attributes, however not all attributes may be preserved." } +{ $errors "Throws an error if the copy operation fails." } ; + +HELP: copy-tree-into +{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } +{ $description "Copies a directory tree to another directory, recursively." } +{ $errors "Throws an error if the copy operation fails." } ; + +HELP: copy-trees-into +{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } +{ $description "Copies a set of directory trees to another directory, recursively." } +{ $errors "Throws an error if the copy operation fails." } ; + +ARTICLE: "current-directory" "Current working directory" +"File system I/O operations use the value of a variable to resolve relative pathnames:" +{ $subsection current-directory } +"This variable can be changed with a pair of words:" +{ $subsection set-current-directory } +{ $subsection with-directory } +"This variable is independent of the operating system notion of ``current working directory''. While all Factor I/O operations use the variable and not the operating system's value, care must be taken when making FFI calls which expect a pathname. The first option is to resolve relative paths:" +{ $subsection (normalize-path) } +"The second is to change the working directory of the current process:" +{ $subsection cd } +{ $subsection cwd } ; + +ARTICLE: "io.directories.listing" "Directory listing" +"Directory listing:" +{ $subsection directory-entries } +{ $subsection directory-files } +{ $subsection with-directory-files } ; + +ARTICLE: "io.directories.create" "Creating directories" +{ $subsection make-directory } +{ $subsection make-directories } ; + +ARTICLE: "delete-move-copy" "Deleting, moving, and copying files" +"Operations for deleting and copying files come in two forms:" +{ $list + { "Words named " { $snippet { $emphasis "operation" } "-file" } " which work on regular files only." } + { "Words named " { $snippet { $emphasis "operation" } "-tree" } " works on directory trees recursively, and also accepts regular files." } +} +"The operations for moving and copying files come in three flavors:" +{ $list + { "A word named " { $snippet { $emphasis "operation" } } " which takes a source and destination path." } + { "A word named " { $snippet { $emphasis "operation" } "-into" } " which takes a source path and destination directory. The destination file will be stored in the destination directory and will have the same file name as the source path." } + { "A word named " { $snippet { $emphasis "operation" } "s-into" } " which takes a sequence of source paths and destination directory." } +} +"Since both of the above lists apply to copying files, that this means that there are a total of six variations on copying a file." +$nl +"Deleting files:" +{ $subsection delete-file } +{ $subsection delete-directory } +{ $subsection delete-tree } +"Moving files:" +{ $subsection move-file } +{ $subsection move-file-into } +{ $subsection move-files-into } +"Copying files:" +{ $subsection copy-file } +{ $subsection copy-file-into } +{ $subsection copy-files-into } +"Copying directory trees recursively:" +{ $subsection copy-tree } +{ $subsection copy-tree-into } +{ $subsection copy-trees-into } +"On most operating systems, files can only be moved within the same file system. To move files between file systems, use " { $link copy-file } " followed by " { $link delete-file } " on the old name." ; + +ARTICLE: "io.directories" "Directory manipulation" +"The " { $vocab-link "io.directories" } " vocabulary defines words for inspecting and manipulating directory trees." +{ $subsection home } +{ $subsection "current-directory" } +{ $subsection "io.directories.listing" } +{ $subsection "io.directories.create" } +{ $subsection "delete-move-copy" } ; + +ABOUT: "io.directories" diff --git a/basis/io/directories/directories-tests.factor b/basis/io/directories/directories-tests.factor new file mode 100644 index 0000000000..266760f925 --- /dev/null +++ b/basis/io/directories/directories-tests.factor @@ -0,0 +1,199 @@ +IN: io.directories.tests + +[ { "kernel" } ] [ + "core" resource-path [ + "." directory-files [ "kernel" = ] filter + ] with-directory +] unit-test + +[ { "kernel" } ] [ + "resource:core" [ + "." directory-files [ "kernel" = ] filter + ] with-directory +] unit-test + +[ { "kernel" } ] [ + "resource:core" [ + [ "kernel" = ] filter + ] with-directory-files +] unit-test + +[ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test +[ ] [ "blahblah" temp-file make-directory ] unit-test +[ t ] [ "blahblah" temp-file file-info directory? ] unit-test + +[ t ] [ + [ temp-directory "loldir" append-path delete-directory ] ignore-errors + temp-directory [ + "loldir" make-directory + ] with-directory + temp-directory "loldir" append-path exists? +] unit-test + +[ ] [ + [ temp-directory "loldir" append-path delete-directory ] ignore-errors + temp-directory [ + "loldir" make-directory + "loldir" delete-directory + ] with-directory +] unit-test + +[ "file1 contents" ] [ + [ temp-directory "loldir" append-path delete-directory ] ignore-errors + temp-directory [ + "file1 contents" "file1" utf8 set-file-contents + "file1" "file2" copy-file + "file2" utf8 file-contents + ] with-directory + "file1" temp-file delete-file + "file2" temp-file delete-file +] unit-test + +[ "file3 contents" ] [ + temp-directory [ + "file3 contents" "file3" utf8 set-file-contents + "file3" "file4" move-file + "file4" utf8 file-contents + ] with-directory + "file4" temp-file delete-file +] unit-test + +[ "file5" temp-file delete-file ] ignore-errors + +[ ] [ + temp-directory [ + "file5" touch-file + "file5" delete-file + ] with-directory +] unit-test + +[ "file6" temp-file delete-file ] ignore-errors + +[ ] [ + temp-directory [ + "file6" touch-file + "file6" link-info drop + ] with-directory +] unit-test + +[ ] [ + { "Hello world." } + "test-foo.txt" temp-file ascii set-file-lines +] unit-test + +[ ] [ + "test-foo.txt" temp-file ascii [ + "Hello appender." print + ] with-file-appender +] unit-test + +[ ] [ + "test-bar.txt" temp-file ascii [ + "Hello appender." print + ] with-file-appender +] unit-test + +[ "Hello world.\nHello appender.\n" ] [ + "test-foo.txt" temp-file ascii file-contents +] unit-test + +[ "Hello appender.\n" ] [ + "test-bar.txt" temp-file ascii file-contents +] unit-test + +[ ] [ "test-foo.txt" temp-file delete-file ] unit-test + +[ ] [ "test-bar.txt" temp-file delete-file ] unit-test + +[ f ] [ "test-foo.txt" temp-file exists? ] unit-test + +[ f ] [ "test-bar.txt" temp-file exists? ] unit-test + +[ "test-blah" temp-file delete-tree ] ignore-errors + +[ ] [ "test-blah" temp-file make-directory ] unit-test + +[ ] [ + "test-blah/fooz" temp-file ascii dispose +] unit-test + +[ t ] [ + "test-blah/fooz" temp-file exists? +] unit-test + +[ ] [ "test-blah/fooz" temp-file delete-file ] unit-test + +[ ] [ "test-blah" temp-file delete-directory ] unit-test + +[ f ] [ "test-blah" temp-file exists? ] unit-test + +USE: debugger.threads + +[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test + +[ ] [ "test-quux.txt" temp-file delete-file ] unit-test + +[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test + +[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test + +[ t ] [ "quux-test.txt" temp-file exists? ] unit-test + +[ ] [ "quux-test.txt" temp-file delete-file ] unit-test + +[ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test + +[ ] [ + { "Hi" } + "delete-tree-test/a/b/c/d" temp-file ascii set-file-lines +] unit-test + +[ ] [ + "delete-tree-test" temp-file delete-tree +] unit-test + +[ ] [ + "copy-tree-test/a/b/c" temp-file make-directories +] unit-test + +[ ] [ + "Foobar" + "copy-tree-test/a/b/c/d" temp-file + ascii set-file-contents +] unit-test + +[ ] [ + "copy-tree-test" temp-file + "copy-destination" temp-file copy-tree +] unit-test + +[ "Foobar" ] [ + "copy-destination/a/b/c/d" temp-file ascii file-contents +] unit-test + +[ ] [ + "copy-destination" temp-file delete-tree +] unit-test + +[ ] [ + "copy-tree-test" temp-file + "copy-destination" temp-file copy-tree-into +] unit-test + +[ "Foobar" ] [ + "copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents +] unit-test + +[ ] [ + "copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into +] unit-test + +[ "Foobar" ] [ + "d" temp-file ascii file-contents +] unit-test + +[ ] [ "d" temp-file delete-file ] unit-test + +[ ] [ "copy-destination" temp-file delete-tree ] unit-test + +[ ] [ "copy-tree-test" temp-file delete-tree ] unit-test diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor new file mode 100644 index 0000000000..8d7a276959 --- /dev/null +++ b/basis/io/directories/directories.factor @@ -0,0 +1,112 @@ +! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: vocabs.loader combinators ; +IN: io.directories + +: set-current-directory ( path -- ) + (normalize-path) current-directory set ; + +: with-directory ( path quot -- ) + [ (normalize-path) current-directory ] dip with-variable ; inline + +! Creating directories +HOOK: make-directory io-backend ( path -- ) + +: make-directories ( path -- ) + normalize-path trim-right-separators { + { [ dup "." = ] [ ] } + { [ dup root-directory? ] [ ] } + { [ dup empty? ] [ ] } + { [ dup exists? ] [ ] } + [ + dup parent-directory make-directories + dup make-directory + ] + } cond drop ; + +! Listing directories +TUPLE: directory-entry name type ; + +HOOK: >directory-entry os ( byte-array -- directory-entry ) + +HOOK: (directory-entries) os ( path -- seq ) + +: directory-entries ( path -- seq ) + normalize-path + (directory-entries) + [ name>> { "." ".." } member? not ] filter ; + +: directory-files ( path -- seq ) + directory-entries [ name>> ] map ; + +: with-directory-files ( path quot -- ) + [ "" directory-files ] prepose with-directory ; inline + +! Touching files +HOOK: touch-file io-backend ( path -- ) + +! Deleting files +HOOK: delete-file io-backend ( path -- ) + +HOOK: delete-directory io-backend ( path -- ) + +: delete-tree ( path -- ) + dup link-info type>> +directory+ = [ + [ [ [ delete-tree ] each ] with-directory-files ] + [ delete-directory ] + bi + ] [ delete-file ] if ; + +: to-directory ( from to -- from to' ) + over file-name append-path ; + +! Moving and renaming files +HOOK: move-file io-backend ( from to -- ) + +: move-file-into ( from to -- ) + to-directory move-file ; + +: move-files-into ( files to -- ) + [ move-file-into ] curry each ; + +! Copying files +HOOK: copy-file io-backend ( from to -- ) + +M: object copy-file + dup parent-directory make-directories + binary [ + swap binary [ + swap stream-copy + ] with-disposal + ] with-disposal ; + +: copy-file-into ( from to -- ) + to-directory copy-file ; + +: copy-files-into ( files to -- ) + [ copy-file-into ] curry each ; + +DEFER: copy-tree-into + +: copy-tree ( from to -- ) + normalize-path + over link-info type>> + { + { +symbolic-link+ [ copy-link ] } + { +directory+ [ + swap [ + [ swap copy-tree-into ] with each + ] with-directory-files + ] } + [ drop copy-file ] + } case ; + +: copy-tree-into ( from to -- ) + to-directory copy-tree ; + +: copy-trees-into ( files to -- ) + [ copy-tree-into ] curry each ; + +{ + { [ os unix? ] [ "io.directories.unix" require ] } +} cond \ No newline at end of file diff --git a/basis/io/windows/mmap/authors.txt b/basis/io/directories/search/authors.txt similarity index 100% rename from basis/io/windows/mmap/authors.txt rename to basis/io/directories/search/authors.txt diff --git a/basis/io/directories/search/search-tests.factor b/basis/io/directories/search/search-tests.factor new file mode 100644 index 0000000000..01763ce5c0 --- /dev/null +++ b/basis/io/directories/search/search-tests.factor @@ -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/directories/search/search.factor b/basis/io/directories/search/search.factor new file mode 100755 index 0000000000..34f06f08f2 --- /dev/null +++ b/basis/io/directories/search/search.factor @@ -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.directories.search + +TUPLE: directory-iterator path bfs queue ; + +> swap bfs>> + [ push-front ] [ push-back ] if + ] curry each ; + +: ( path bfs? -- iterator ) + 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 ) + [ ] dip + [ keep and ] curry iterate-directory ; inline + +: each-file ( path bfs? quot: ( obj -- ? ) -- ) + [ ] dip + [ f ] compose iterate-directory drop ; inline + +: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths ) + [ ] 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/windows/nt/monitors/authors.txt b/basis/io/directories/search/windows/authors.txt old mode 100755 new mode 100644 similarity index 100% rename from basis/io/windows/nt/monitors/authors.txt rename to basis/io/directories/search/windows/authors.txt diff --git a/basis/io/unix/linux/monitors/tags.txt b/basis/io/directories/search/windows/tags.txt similarity index 100% rename from basis/io/unix/linux/monitors/tags.txt rename to basis/io/directories/search/windows/tags.txt diff --git a/basis/io/directories/search/windows/windows.factor b/basis/io/directories/search/windows/windows.factor new file mode 100644 index 0000000000..b4858aaef8 --- /dev/null +++ b/basis/io/directories/search/windows/windows.factor @@ -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 diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor new file mode 100644 index 0000000000..11712d8545 --- /dev/null +++ b/basis/io/directories/unix/unix.factor @@ -0,0 +1,75 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: math.bitwise io.backend kernel io.files unix +io.backend.unix io.encodings.binary io.directories io destructors +accessors io.files.info alien.c-types io.encodings.utf8 fry +sequences system continuations alien.strings ; +IN: io.directories.unix + +: touch-mode ( -- n ) + { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable + +M: unix touch-file ( path -- ) + normalize-path + dup exists? [ touch ] [ + touch-mode file-mode open-file close-file + ] if ; + +M: unix move-file ( from to -- ) + [ normalize-path ] bi@ rename io-error ; + +M: unix delete-file ( path -- ) normalize-path unlink-file ; + +M: unix make-directory ( path -- ) + normalize-path OCT: 777 mkdir io-error ; + +M: unix delete-directory ( path -- ) + normalize-path rmdir io-error ; + +: (copy-file) ( from to -- ) + dup parent-directory make-directories + binary [ + swap binary [ + swap stream-copy + ] with-disposal + ] with-disposal ; + +M: unix copy-file ( from to -- ) + [ normalize-path ] bi@ + [ (copy-file) ] + [ swap file-info permissions>> chmod io-error ] + 2bi ; + +: with-unix-directory ( path quot -- ) + [ opendir dup [ (io-error) ] unless ] dip + dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline + +: find-next-file ( DIR* -- byte-array ) + "dirent" + f + [ readdir_r 0 = [ (io-error) ] unless ] 2keep + *void* [ drop f ] unless ; + +: dirent-type>file-type ( ch -- type ) + { + { DT_BLK [ +block-device+ ] } + { DT_CHR [ +character-device+ ] } + { DT_DIR [ +directory+ ] } + { DT_LNK [ +symbolic-link+ ] } + { DT_SOCK [ +socket+ ] } + { DT_FIFO [ +fifo+ ] } + { DT_REG [ +regular-file+ ] } + { DT_WHT [ +whiteout+ ] } + [ drop +unknown+ ] + } case ; + +M: unix >directory-entry ( byte-array -- directory-entry ) + [ dirent-d_name utf8 alien>string ] + [ dirent-d_type dirent-type>file-type ] bi directory-entry boa ; + +M: unix (directory-entries) ( path -- seq ) + [ + '[ _ find-next-file dup ] + [ >directory-entry ] + [ drop ] produce + ] with-unix-directory ; diff --git a/basis/io/encodings/binary/authors.txt b/basis/io/encodings/binary/authors.txt new file mode 100644 index 0000000000..f990dd0ed2 --- /dev/null +++ b/basis/io/encodings/binary/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/basis/io/encodings/binary/binary-docs.factor b/basis/io/encodings/binary/binary-docs.factor new file mode 100644 index 0000000000..4da1e0811f --- /dev/null +++ b/basis/io/encodings/binary/binary-docs.factor @@ -0,0 +1,11 @@ +USING: help.syntax help.markup ; +IN: io.encodings.binary + +HELP: binary +{ $class-description "Encoding descriptor for binary I/O." } ; + +ARTICLE: "io.encodings.binary" "Binary encoding" +"Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings." +{ $subsection binary } ; + +ABOUT: "io.encodings.binary" diff --git a/basis/io/encodings/binary/binary.factor b/basis/io/encodings/binary/binary.factor new file mode 100644 index 0000000000..e54163f632 --- /dev/null +++ b/basis/io/encodings/binary/binary.factor @@ -0,0 +1,8 @@ +! Copyright (C) 2008 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: io.encodings kernel ; +IN: io.encodings.binary + +SINGLETON: binary +M: binary drop ; +M: binary drop ; diff --git a/basis/io/encodings/binary/summary.txt b/basis/io/encodings/binary/summary.txt new file mode 100644 index 0000000000..a1eb4bc664 --- /dev/null +++ b/basis/io/encodings/binary/summary.txt @@ -0,0 +1 @@ +Dummy encoding for binary I/O diff --git a/basis/io/encodings/binary/tags.txt b/basis/io/encodings/binary/tags.txt new file mode 100644 index 0000000000..8e27be7d61 --- /dev/null +++ b/basis/io/encodings/binary/tags.txt @@ -0,0 +1 @@ +text diff --git a/basis/io/files/info/info-docs.factor b/basis/io/files/info/info-docs.factor new file mode 100644 index 0000000000..8bb79851ec --- /dev/null +++ b/basis/io/files/info/info-docs.factor @@ -0,0 +1,76 @@ +IN: io.files.info + +HELP: file-info +{ $values { "path" "a pathname string" } { "info" file-info } } +{ $description "Queries the file system for metadata. If " { $snippet "path" } " refers to a symbolic link, it is followed. See the article " { $link "file-types" } " for a list of metadata symbols." } +{ $errors "Throws an error if the file does not exist." } ; + +HELP: link-info +{ $values { "path" "a pathname string" } { "info" "a file-info tuple" } } +{ $description "Queries the file system for metadata. If path refers to a symbolic link, information about the symbolic link itself is returned. If the file does not exist, an exception is thrown." } ; + +{ file-info link-info } related-words + +HELP: +regular-file+ +{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ; + +HELP: +directory+ +{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ; + +HELP: +symbolic-link+ +{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ; + +HELP: +character-device+ +{ $description "A Unix character device file. This type exists on Unix platforms only." } ; + +HELP: +block-device+ +{ $description "A Unix block device file. This type exists on Unix platforms only." } ; + +HELP: +fifo+ +{ $description "A Unix fifo file. This type exists on Unix platforms only." } ; + +HELP: +socket+ +{ $description "A Unix socket file. This type exists on Unix platforms only." } ; + +HELP: +unknown+ +{ $description "A unknown file type." } ; + +HELP: directory? +{ $values { "file-info" file-info } { "?" "a boolean" } } +{ $description "Tests if " { $snippet "file-info" } " is a directory." } ; + +HELP: file-systems +{ $values { "array" array } } +{ $description "Returns an array of " { $link file-system-info } " objects returned by iterating the mount points and calling " { $link file-system-info } " on each." } ; + +HELP: file-system-info +{ $values +{ "path" "a pathname string" } +{ "file-system-info" file-system-info } } +{ $description "Returns a platform-specific object describing the file-system that contains the path. The cross-platform slot is " { $slot "free-space" } "." } ; + +ARTICLE: "file-types" "File types" +"Platform-independent types:" +{ $subsection +regular-file+ } +{ $subsection +directory+ } +"Platform-specific types:" +{ $subsection +character-device+ } +{ $subsection +block-device+ } +{ $subsection +fifo+ } +{ $subsection +symbolic-link+ } +{ $subsection +socket+ } +{ $subsection +unknown+ } ; + +ARTICLE: "io.files.info" "File system meta-data" +"File meta-data:" +{ $subsection file-info } +{ $subsection link-info } +{ $subsection exists? } +{ $subsection directory? } +"File types:" +{ $subsection "file-types" } +"File system meta-data:" +{ $subsection file-system-info } +{ $subsection file-systems } ; + +ABOUT: "io.files.info" diff --git a/basis/io/files/info/info-tests.factor b/basis/io/files/info/info-tests.factor new file mode 100644 index 0000000000..9d6eca13ca --- /dev/null +++ b/basis/io/files/info/info-tests.factor @@ -0,0 +1,16 @@ +IN: io.files.info.tests + +\ file-info must-infer +\ link-info must-infer + +[ t ] [ + temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory + temp-directory "test41" append-path utf8 file-contents "hi41" = +] unit-test + +[ t ] [ + temp-directory [ "test41" file-info size>> ] with-directory 4 = +] unit-test + +[ t ] [ "/" file-system-info file-system-info? ] unit-test +[ t ] [ file-systems [ file-system-info? ] all? ] unit-test diff --git a/basis/io/files/info/info.factor b/basis/io/files/info/info.factor new file mode 100644 index 0000000000..ae8d806417 --- /dev/null +++ b/basis/io/files/info/info.factor @@ -0,0 +1,38 @@ +! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel system sequences combinators +vocabs.loader ; +IN: io.files.info + +! File info +TUPLE: file-info type size permissions created modified +accessed ; + +HOOK: file-info os ( path -- info ) + +HOOK: link-info os ( path -- info ) + +SYMBOL: +regular-file+ +SYMBOL: +directory+ +SYMBOL: +symbolic-link+ +SYMBOL: +character-device+ +SYMBOL: +block-device+ +SYMBOL: +fifo+ +SYMBOL: +socket+ +SYMBOL: +whiteout+ +SYMBOL: +unknown+ + +: directory? ( file-info -- ? ) type>> +directory+ = ; + +! File systems +HOOK: file-systems os ( -- array ) + +TUPLE: file-system-info device-name mount-point type +available-space free-space used-space total-space ; + +HOOK: file-system-info os ( path -- file-system-info ) + +{ + { [ os unix? ] [ "io.files.info.unix." os name>> append ] } + { [ os windows? ] [ "io.files.info.windows" ] } +} cond require \ No newline at end of file diff --git a/basis/io/unix/files/bsd/bsd.factor b/basis/io/files/info/unix/bsd/bsd.factor similarity index 76% rename from basis/io/unix/files/bsd/bsd.factor rename to basis/io/files/info/unix/bsd/bsd.factor index 3c94baa39a..6d0f3e7161 100644 --- a/basis/io/unix/files/bsd/bsd.factor +++ b/basis/io/files/info/unix/bsd/bsd.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel alien.syntax math io.unix.files system -unix.stat accessors combinators calendar.unix ; -IN: io.unix.files.bsd +USING: kernel alien.syntax math io.files.unix system +unix.stat accessors combinators calendar.unix +io.files.info.unix ; +IN: io.files.info.unix.bsd TUPLE: bsd-file-info < unix-file-info birth-time flags gen ; diff --git a/basis/io/unix/linux/tags.txt b/basis/io/files/info/unix/bsd/tags.txt similarity index 100% rename from basis/io/unix/linux/tags.txt rename to basis/io/files/info/unix/bsd/tags.txt diff --git a/basis/io/unix/files/freebsd/freebsd.factor b/basis/io/files/info/unix/freebsd/freebsd.factor similarity index 93% rename from basis/io/unix/files/freebsd/freebsd.factor rename to basis/io/files/info/unix/freebsd/freebsd.factor index eaf217af62..c36a750997 100644 --- a/basis/io/unix/files/freebsd/freebsd.factor +++ b/basis/io/files/info/unix/freebsd/freebsd.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators -io.backend io.files io.unix.files kernel math system unix +io.backend io.files io.files.unix kernel math system unix unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd sequences grouping alien.strings io.encodings.utf8 -specialized-arrays.direct.uint arrays ; -IN: io.unix.files.freebsd +specialized-arrays.direct.uint arrays io.files.info.unix ; +IN: io.files.info.unix.freebsd TUPLE: freebsd-file-system-info < unix-file-system-info version io-size owner syncreads syncwrites asyncreads asyncwrites ; diff --git a/basis/io/unix/macosx/monitors/tags.txt b/basis/io/files/info/unix/freebsd/tags.txt similarity index 100% rename from basis/io/unix/macosx/monitors/tags.txt rename to basis/io/files/info/unix/freebsd/tags.txt diff --git a/basis/io/unix/files/linux/linux.factor b/basis/io/files/info/unix/linux/linux.factor similarity index 94% rename from basis/io/unix/files/linux/linux.factor rename to basis/io/files/info/unix/linux/linux.factor index c30855c3ee..9d611bdc5c 100644 --- a/basis/io/unix/files/linux/linux.factor +++ b/basis/io/files/info/unix/linux/linux.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators csv io.backend io.encodings.utf8 io.files io.streams.string -io.unix.files kernel math.order namespaces sequences sorting +io.files.unix kernel math.order namespaces sequences sorting system unix unix.statfs.linux unix.statvfs.linux -specialized-arrays.direct.uint arrays ; -IN: io.unix.files.linux +specialized-arrays.direct.uint arrays io.files.info.unix ; +IN: io.files.info.unix.linux TUPLE: linux-file-system-info < unix-file-system-info namelen ; diff --git a/basis/io/unix/macosx/tags.txt b/basis/io/files/info/unix/linux/tags.txt similarity index 100% rename from basis/io/unix/macosx/tags.txt rename to basis/io/files/info/unix/linux/tags.txt diff --git a/basis/io/unix/files/macosx/macosx.factor b/basis/io/files/info/unix/macosx/macosx.factor similarity index 91% rename from basis/io/unix/files/macosx/macosx.factor rename to basis/io/files/info/unix/macosx/macosx.factor index 397145c9ae..53992bcb95 100644 --- a/basis/io/unix/files/macosx/macosx.factor +++ b/basis/io/files/info/unix/macosx/macosx.factor @@ -2,9 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.strings combinators grouping io.encodings.utf8 io.files kernel math sequences -system unix io.unix.files specialized-arrays.direct.uint arrays -unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx ; -IN: io.unix.files.macosx +system unix io.files.unix specialized-arrays.direct.uint arrays +unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx +io.files.info.unix io.files.info ; +IN: io.files.info.unix.macosx TUPLE: macosx-file-system-info < unix-file-system-info io-size owner type-id filesystem-subtype ; diff --git a/basis/io/unix/mmap/tags.txt b/basis/io/files/info/unix/macosx/tags.txt similarity index 100% rename from basis/io/unix/mmap/tags.txt rename to basis/io/files/info/unix/macosx/tags.txt diff --git a/basis/io/unix/files/netbsd/netbsd.factor b/basis/io/files/info/unix/netbsd/netbsd.factor similarity index 91% rename from basis/io/unix/files/netbsd/netbsd.factor rename to basis/io/files/info/unix/netbsd/netbsd.factor index 82ac3dc70d..0c26a2a2c9 100644 --- a/basis/io/unix/files/netbsd/netbsd.factor +++ b/basis/io/files/info/unix/netbsd/netbsd.factor @@ -2,10 +2,11 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax kernel unix.stat math unix combinators system io.backend accessors alien.c-types -io.encodings.utf8 alien.strings unix.types io.unix.files +io.encodings.utf8 alien.strings unix.types io.files.unix io.files unix.statvfs.netbsd unix.getfsstat.netbsd arrays -grouping sequences io.encodings.utf8 specialized-arrays.direct.uint ; -IN: io.unix.files.netbsd +grouping sequences io.encodings.utf8 +specialized-arrays.direct.uint io.files.info.unix ; +IN: io.files.info.unix.netbsd TUPLE: netbsd-file-system-info < unix-file-system-info blocks-reserved files-reserved diff --git a/basis/io/unix/multiplexers/epoll/tags.txt b/basis/io/files/info/unix/netbsd/tags.txt similarity index 100% rename from basis/io/unix/multiplexers/epoll/tags.txt rename to basis/io/files/info/unix/netbsd/tags.txt diff --git a/basis/io/unix/files/openbsd/openbsd.factor b/basis/io/files/info/unix/openbsd/openbsd.factor similarity index 93% rename from basis/io/unix/files/openbsd/openbsd.factor rename to basis/io/files/info/unix/openbsd/openbsd.factor index e5e18b29ea..7057e2e8c7 100644 --- a/basis/io/unix/files/openbsd/openbsd.factor +++ b/basis/io/files/info/unix/openbsd/openbsd.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.strings alien.syntax -combinators io.backend io.files io.unix.files kernel math +combinators io.backend io.files io.files.unix kernel math sequences system unix unix.getfsstat.openbsd grouping unix.statfs.openbsd unix.statvfs.openbsd unix.types -specialized-arrays.direct.uint arrays ; -IN: io.unix.files.openbsd +specialized-arrays.direct.uint arrays io.files.info.unix ; +IN: io.files.unix.openbsd TUPLE: freebsd-file-system-info < unix-file-system-info io-size sync-writes sync-reads async-writes async-reads diff --git a/basis/io/unix/multiplexers/kqueue/tags.txt b/basis/io/files/info/unix/openbsd/tags.txt similarity index 100% rename from basis/io/unix/multiplexers/kqueue/tags.txt rename to basis/io/files/info/unix/openbsd/tags.txt diff --git a/basis/io/unix/files/files.factor b/basis/io/files/info/unix/unix.factor similarity index 65% rename from basis/io/unix/files/files.factor rename to basis/io/files/info/unix/unix.factor index 1fc5fe9226..3d08534b71 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/files/info/unix/unix.factor @@ -1,80 +1,10 @@ -! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman. +! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: io.backend io.ports io.unix.backend io.files io -unix unix.stat unix.time kernel math continuations -math.bitwise byte-arrays alien combinators calendar -io.encodings.binary accessors sequences strings system -io.files.private destructors vocabs.loader calendar.unix -unix.stat alien.c-types arrays unix.users unix.groups -environment fry io.encodings.utf8 alien.strings -combinators.short-circuit ; -IN: io.unix.files - -M: unix cwd ( -- path ) - MAXPATHLEN [ ] keep getcwd - [ (io-error) ] unless* ; - -M: unix cd ( path -- ) [ chdir ] unix-system-call drop ; - -: read-flags O_RDONLY ; inline - -: open-read ( path -- fd ) O_RDONLY file-mode open-file ; - -M: unix (file-reader) ( path -- stream ) - open-read init-fd ; - -: write-flags { O_WRONLY O_CREAT O_TRUNC } flags ; inline - -: open-write ( path -- fd ) - write-flags file-mode open-file ; - -M: unix (file-writer) ( path -- stream ) - open-write init-fd ; - -: append-flags { O_WRONLY O_APPEND O_CREAT } flags ; inline - -: open-append ( path -- fd ) - [ - append-flags file-mode open-file |dispose - dup 0 SEEK_END lseek io-error - ] with-destructors ; - -M: unix (file-appender) ( path -- stream ) - open-append init-fd ; - -: touch-mode ( -- n ) - { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable - -M: unix touch-file ( path -- ) - normalize-path - dup exists? [ touch ] [ - touch-mode file-mode open-file close-file - ] if ; - -M: unix move-file ( from to -- ) - [ normalize-path ] bi@ rename io-error ; - -M: unix delete-file ( path -- ) normalize-path unlink-file ; - -M: unix make-directory ( path -- ) - normalize-path OCT: 777 mkdir io-error ; - -M: unix delete-directory ( path -- ) - normalize-path rmdir io-error ; - -: (copy-file) ( from to -- ) - dup parent-directory make-directories - binary [ - swap binary [ - swap stream-copy - ] with-disposal - ] with-disposal ; - -M: unix copy-file ( from to -- ) - [ normalize-path ] bi@ - [ (copy-file) ] - [ swap file-info permissions>> chmod io-error ] - 2bi ; +USING: accessors kernel system math math.bitwise strings arrays +sequences combinators combinators.short-circuit alien.c-types +vocabs.loader calendar calendar.unix io.files.info io.backend +unix unix.stat unix.time unix.users unix.groups ; +IN: io.files.info.unix TUPLE: unix-file-system-info < file-system-info block-size preferred-block-size @@ -103,13 +33,10 @@ HOOK: statvfs>file-system-info os ( file-system-info statvfs -- file-system-info M: unix statvfs>file-system-info drop ; : file-system-calculations ( file-system-info -- file-system-info' ) - { - [ dup [ blocks-available>> ] [ block-size>> ] bi * >>available-space drop ] - [ dup [ blocks-free>> ] [ block-size>> ] bi * >>free-space drop ] - [ dup [ blocks>> ] [ block-size>> ] bi * >>total-space drop ] - [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ] - [ ] - } cleave ; + dup [ blocks-available>> ] [ block-size>> ] bi * >>available-space + dup [ blocks-free>> ] [ block-size>> ] bi * >>free-space + dup [ blocks>> ] [ block-size>> ] bi * >>total-space + dup [ total-space>> ] [ free-space>> ] bi - >>used-space ; M: unix file-system-info normalize-path @@ -118,14 +45,6 @@ M: unix file-system-info [ file-system-statvfs statvfs>file-system-info ] bi file-system-calculations ; -os { - { linux [ "io.unix.files.linux" require ] } - { macosx [ "io.unix.files.macosx" require ] } - { freebsd [ "io.unix.files.freebsd" require ] } - { netbsd [ "io.unix.files.netbsd" require ] } - { openbsd [ "io.unix.files.openbsd" require ] } -} case - TUPLE: unix-file-info < file-info uid gid dev ino nlink rdev blocks blocksize ; @@ -141,12 +60,6 @@ M: unix file-info ( path -- info ) M: unix link-info ( path -- info ) normalize-path link-status stat>file-info ; -M: unix make-link ( path1 path2 -- ) - normalize-path symlink io-error ; - -M: unix read-link ( path -- path' ) - normalize-path read-symbolic-link ; - M: unix new-file-info ( -- class ) unix-file-info new ; M: unix stat>file-info ( stat -- file-info ) @@ -183,36 +96,6 @@ M: unix stat>file-info ( stat -- file-info ) M: unix stat>type ( stat -- type ) stat-st_mode n>file-type ; -! Linux has no extra fields in its stat struct -os { - { macosx [ "io.unix.files.bsd" require ] } - { netbsd [ "io.unix.files.bsd" require ] } - { openbsd [ "io.unix.files.bsd" require ] } - { freebsd [ "io.unix.files.bsd" require ] } - { linux [ ] } -} case - -: with-unix-directory ( path quot -- ) - [ opendir dup [ (io-error) ] unless ] dip - dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline - -: find-next-file ( DIR* -- byte-array ) - "dirent" - f - [ readdir_r 0 = [ (io-error) ] unless ] 2keep - *void* [ drop f ] unless ; - -M: unix >directory-entry ( byte-array -- directory-entry ) - [ dirent-d_name utf8 alien>string ] - [ dirent-d_type dirent-type>file-type ] bi directory-entry boa ; - -M: unix (directory-entries) ( path -- seq ) - [ - '[ _ find-next-file dup ] - [ >directory-entry ] - [ drop ] produce - ] with-unix-directory ; - '[ _ with-directory ] [ delete-tree ] bi ; inline { - { [ os unix? ] [ "io.unix.files.unique" ] } - { [ os windows? ] [ "io.windows.files.unique" ] } + { [ os unix? ] [ "io.files.unique.unix" ] } + { [ os windows? ] [ "io.files.unique.windows" ] } } cond require diff --git a/basis/io/unix/multiplexers/run-loop/tags.txt b/basis/io/files/unique/unix/tags.txt similarity index 100% rename from basis/io/unix/multiplexers/run-loop/tags.txt rename to basis/io/files/unique/unix/tags.txt diff --git a/basis/io/unix/files/unique/unique.factor b/basis/io/files/unique/unix/unix.factor similarity index 81% rename from basis/io/unix/files/unique/unique.factor rename to basis/io/files/unique/unix/unix.factor index 24dcdcb65a..ed4e120b79 100644 --- a/basis/io/unix/files/unique/unique.factor +++ b/basis/io/files/unique/unix/unix.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel io.ports io.unix.backend math.bitwise +USING: kernel io.ports io.backend.unix math.bitwise unix system io.files.unique ; -IN: io.unix.files.unique +IN: io.files.unique.unix : open-unique-flags ( -- flags ) { O_RDWR O_CREAT O_EXCL } flags ; diff --git a/basis/io/unix/multiplexers/select/tags.txt b/basis/io/files/unique/windows/tags.txt similarity index 100% rename from basis/io/unix/multiplexers/select/tags.txt rename to basis/io/files/unique/windows/tags.txt diff --git a/basis/io/windows/files/unique/unique.factor b/basis/io/files/unique/windows/windows.factor similarity index 54% rename from basis/io/windows/files/unique/unique.factor rename to basis/io/files/unique/windows/windows.factor index ab99bf2cac..47f30999c3 100644 --- a/basis/io/windows/files/unique/unique.factor +++ b/basis/io/files/unique/windows/windows.factor @@ -1,7 +1,7 @@ -USING: kernel system windows.kernel32 io.windows -io.windows.files io.ports windows destructors environment +USING: kernel system windows.kernel32 io.backend.windows +io.files.windows io.ports windows destructors environment io.files.unique ; -IN: io.windows.files.unique +IN: io.files.unique.windows M: windows touch-unique-file ( path -- ) GENERIC_WRITE CREATE_NEW 0 open-file dispose ; diff --git a/basis/io/unix/launcher/authors.txt b/basis/io/files/unix/authors.txt old mode 100755 new mode 100644 similarity index 100% rename from basis/io/unix/launcher/authors.txt rename to basis/io/files/unix/authors.txt diff --git a/basis/io/unix/files/summary.txt b/basis/io/files/unix/summary.txt similarity index 100% rename from basis/io/unix/files/summary.txt rename to basis/io/files/unix/summary.txt diff --git a/basis/io/unix/netbsd/tags.txt b/basis/io/files/unix/tags.txt similarity index 100% rename from basis/io/unix/netbsd/tags.txt rename to basis/io/files/unix/tags.txt diff --git a/basis/io/unix/files/files-docs.factor b/basis/io/files/unix/unix-docs.factor similarity index 97% rename from basis/io/unix/files/files-docs.factor rename to basis/io/files/unix/unix-docs.factor index 3798380e0f..eeac3cea0f 100644 --- a/basis/io/unix/files/files-docs.factor +++ b/basis/io/files/unix/unix-docs.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: classes help.markup help.syntax io.streams.string strings math calendar io.files ; -IN: io.unix.files +IN: io.files.unix HELP: file-group-id { $values @@ -90,12 +90,12 @@ HELP: set-file-permissions { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } } { $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." } { $examples "Using the tradidional octal value:" - { $unchecked-example "USING: io.unix.files kernel ;" + { $unchecked-example "USING: io.files.unix kernel ;" "\"resource:license.txt\" OCT: 755 set-file-permissions" "" } "Higher-level, setting named bits:" - { $unchecked-example "USING: io.unix.files kernel math.bitwise ;" + { $unchecked-example "USING: io.files.unix kernel math.bitwise ;" "\"resource:license.txt\"" "{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }" "flags set-file-permissions" @@ -268,10 +268,10 @@ ARTICLE: "unix-file-ids" "Unix file user and group ids" { $subsection set-file-group } ; -ARTICLE: "io.unix.files" "Unix file attributes" -"The " { $vocab-link "io.unix.files" } " vocabulary implements the Unix backend for opening files and provides a high-level way to set permissions, timestamps, and user and group ids for files." +ARTICLE: "io.files.unix" "Unix file attributes" +"The " { $vocab-link "io.files.unix" } " vocabulary implements the Unix backend for opening files and provides a high-level way to set permissions, timestamps, and user and group ids for files." { $subsection "unix-file-permissions" } { $subsection "unix-file-timestamps" } { $subsection "unix-file-ids" } ; -ABOUT: "io.unix.files" +ABOUT: "io.files.unix" diff --git a/basis/io/unix/files/files-tests.factor b/basis/io/files/unix/unix-tests.factor similarity index 98% rename from basis/io/unix/files/files-tests.factor rename to basis/io/files/unix/unix-tests.factor index 78a80ad969..a112da2876 100644 --- a/basis/io/unix/files/files-tests.factor +++ b/basis/io/files/unix/unix-tests.factor @@ -1,7 +1,7 @@ -USING: tools.test io.files continuations kernel io.unix.files +USING: tools.test io.files continuations kernel io.files.unix math.bitwise calendar accessors math.functions math unix.users unix.groups arrays sequences ; -IN: io.unix.files.tests +IN: io.files.unix.tests [ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test [ "/etc/" ] [ "/etc/passwd" parent-directory ] unit-test diff --git a/basis/io/files/unix/unix.factor b/basis/io/files/unix/unix.factor new file mode 100644 index 0000000000..ac78cdff0c --- /dev/null +++ b/basis/io/files/unix/unix.factor @@ -0,0 +1,40 @@ +! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: unix byte-arrays kernel io.backend.unix math.bitwise +io.ports io.files io.files.private io.pathnames environment +destructors system ; +IN: io.files.unix + +M: unix cwd ( -- path ) + MAXPATHLEN [ ] keep getcwd + [ (io-error) ] unless* ; + +M: unix cd ( path -- ) [ chdir ] unix-system-call drop ; + +: read-flags O_RDONLY ; inline + +: open-read ( path -- fd ) O_RDONLY file-mode open-file ; + +M: unix (file-reader) ( path -- stream ) + open-read init-fd ; + +: write-flags { O_WRONLY O_CREAT O_TRUNC } flags ; inline + +: open-write ( path -- fd ) + write-flags file-mode open-file ; + +M: unix (file-writer) ( path -- stream ) + open-write init-fd ; + +: append-flags { O_WRONLY O_APPEND O_CREAT } flags ; inline + +: open-append ( path -- fd ) + [ + append-flags file-mode open-file |dispose + dup 0 SEEK_END lseek io-error + ] with-destructors ; + +M: unix (file-appender) ( path -- stream ) + open-append init-fd ; + +M: unix home "HOME" os-env ; diff --git a/basis/io/windows/files/files.factor b/basis/io/files/windows/files.factor similarity index 99% rename from basis/io/windows/files/files.factor rename to basis/io/files/windows/files.factor index 664727dbdb..76105c5fe6 100755 --- a/basis/io/windows/files/files.factor +++ b/basis/io/files/windows/files.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types io.binary io.backend io.files io.buffers -io.encodings.utf16n io.ports io.windows kernel math splitting +io.encodings.utf16n io.ports io.backend.windows kernel math splitting fry alien.strings windows windows.kernel32 windows.time calendar combinators math.functions sequences namespaces make words symbols system destructors accessors math.bitwise continuations windows.errors arrays byte-arrays generalizations ; -IN: io.windows.files +IN: io.files.windows : open-file ( path access-mode create-mode flags -- handle ) [ diff --git a/basis/io/windows/nt/files/authors.txt b/basis/io/files/windows/nt/authors.txt similarity index 100% rename from basis/io/windows/nt/files/authors.txt rename to basis/io/files/windows/nt/authors.txt diff --git a/basis/io/windows/nt/files/files-tests.factor b/basis/io/files/windows/nt/files-tests.factor similarity index 96% rename from basis/io/windows/nt/files/files-tests.factor rename to basis/io/files/windows/nt/files-tests.factor index 6620dd691e..727f72c808 100644 --- a/basis/io/windows/nt/files/files-tests.factor +++ b/basis/io/files/windows/nt/files-tests.factor @@ -1,6 +1,6 @@ USING: io.files kernel tools.test io.backend -io.windows.nt.files splitting sequences ; -IN: io.windows.nt.files.tests +io.files.windows.nt splitting sequences ; +IN: io.files.windows.nt.tests [ f ] [ "\\foo" absolute-path? ] unit-test [ t ] [ "\\\\?\\c:\\foo" absolute-path? ] unit-test diff --git a/basis/io/windows/nt/files/files.factor b/basis/io/files/windows/nt/files.factor similarity index 92% rename from basis/io/windows/nt/files/files.factor rename to basis/io/files/windows/nt/files.factor index 892a5c4d31..b50b4cfa3d 100755 --- a/basis/io/windows/nt/files/files.factor +++ b/basis/io/files/windows/nt/files.factor @@ -1,11 +1,11 @@ USING: continuations destructors io.buffers io.files io.backend -io.timeouts io.ports io.files.private io.windows -io.windows.files io.windows.nt.backend io.encodings.utf16n +io.timeouts io.ports io.files.private io.backend.windows +io.files.windows io.backend.windows.nt io.encodings.utf16n windows windows.kernel32 kernel libc math threads system environment alien.c-types alien.arrays alien.strings sequences combinators combinators.short-circuit ascii splitting alien strings assocs namespaces make accessors tr ; -IN: io.windows.nt.files +IN: io.files.windows.nt M: winnt cwd MAX_UNICODE_PATH dup "ushort" diff --git a/basis/io/unix/openbsd/tags.txt b/basis/io/files/windows/nt/tags.txt similarity index 100% rename from basis/io/unix/openbsd/tags.txt rename to basis/io/files/windows/nt/tags.txt diff --git a/basis/io/unix/pipes/tags.txt b/basis/io/files/windows/tags.txt similarity index 100% rename from basis/io/unix/pipes/tags.txt rename to basis/io/files/windows/tags.txt diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor index 7bafb95376..ad2f7e44a9 100644 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -261,8 +261,8 @@ M: object run-pipeline-element drop ; { - { [ os unix? ] [ "io.unix.launcher" require ] } - { [ os winnt? ] [ "io.windows.nt.launcher" require ] } - { [ os wince? ] [ "io.windows.launcher" require ] } + { [ os unix? ] [ "io.launcher.unix" require ] } + { [ os winnt? ] [ "io.backend.windows.nt.launcher" require ] } + { [ os wince? ] [ "io.launcher.windows" require ] } [ ] } cond diff --git a/basis/io/unix/linux/authors.txt b/basis/io/launcher/unix/authors.txt similarity index 100% rename from basis/io/unix/linux/authors.txt rename to basis/io/launcher/unix/authors.txt diff --git a/basis/io/unix/launcher/parser/parser-tests.factor b/basis/io/launcher/unix/parser/parser-tests.factor similarity index 95% rename from basis/io/unix/launcher/parser/parser-tests.factor rename to basis/io/launcher/unix/parser/parser-tests.factor index 63aadcabbe..07502e87a4 100644 --- a/basis/io/unix/launcher/parser/parser-tests.factor +++ b/basis/io/launcher/unix/parser/parser-tests.factor @@ -1,5 +1,5 @@ -IN: io.unix.launcher.parser.tests -USING: io.unix.launcher.parser tools.test ; +IN: io.launcher.unix.parser.tests +USING: io.launcher.unix.parser tools.test ; [ "" tokenize-command ] must-fail [ " " tokenize-command ] must-fail diff --git a/basis/io/unix/launcher/parser/parser.factor b/basis/io/launcher/unix/parser/parser.factor similarity index 96% rename from basis/io/unix/launcher/parser/parser.factor rename to basis/io/launcher/unix/parser/parser.factor index 276ed45f27..97e6dee95f 100644 --- a/basis/io/unix/launcher/parser/parser.factor +++ b/basis/io/launcher/unix/parser/parser.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: peg peg.parsers kernel sequences strings words ; -IN: io.unix.launcher.parser +IN: io.launcher.unix.parser ! Our command line parser. Supported syntax: ! foo bar baz -- simple tokens diff --git a/basis/io/unix/select/tags.txt b/basis/io/launcher/unix/parser/tags.txt similarity index 100% rename from basis/io/unix/select/tags.txt rename to basis/io/launcher/unix/parser/tags.txt diff --git a/basis/io/unix/sockets/secure/tags.txt b/basis/io/launcher/unix/tags.txt similarity index 100% rename from basis/io/unix/sockets/secure/tags.txt rename to basis/io/launcher/unix/tags.txt diff --git a/basis/io/unix/launcher/launcher-tests.factor b/basis/io/launcher/unix/unix-tests.factor similarity index 99% rename from basis/io/unix/launcher/launcher-tests.factor rename to basis/io/launcher/unix/unix-tests.factor index 68ca821ed4..f741507011 100644 --- a/basis/io/unix/launcher/launcher-tests.factor +++ b/basis/io/launcher/unix/unix-tests.factor @@ -1,4 +1,4 @@ -IN: io.unix.launcher.tests +IN: io.launcher.unix.tests USING: io.files tools.test io.launcher arrays io namespaces continuations math io.encodings.binary io.encodings.ascii accessors kernel sequences io.encodings.utf8 destructors diff --git a/basis/io/unix/launcher/launcher.factor b/basis/io/launcher/unix/unix.factor similarity index 97% rename from basis/io/unix/launcher/launcher.factor rename to basis/io/launcher/unix/unix.factor index 729c1545d8..eabb0130af 100644 --- a/basis/io/unix/launcher/launcher.factor +++ b/basis/io/launcher/unix/unix.factor @@ -4,10 +4,10 @@ USING: kernel namespaces math system sequences continuations arrays assocs combinators alien.c-types strings threads accessors environment io io.backend io.launcher io.ports io.files -io.files.private io.unix.files io.unix.backend -io.unix.launcher.parser +io.files.private io.files.unix io.backend.unix +io.launcher.unix.parser unix unix.process ; -IN: io.unix.launcher +IN: io.launcher.unix ! Search unix first USE: unix diff --git a/basis/io/windows/launcher/authors.txt b/basis/io/launcher/windows/authors.txt similarity index 100% rename from basis/io/windows/launcher/authors.txt rename to basis/io/launcher/windows/authors.txt diff --git a/basis/io/windows/nt/launcher/authors.txt b/basis/io/launcher/windows/nt/authors.txt similarity index 100% rename from basis/io/windows/nt/launcher/authors.txt rename to basis/io/launcher/windows/nt/authors.txt diff --git a/basis/io/windows/nt/launcher/launcher-tests.factor b/basis/io/launcher/windows/nt/nt-tests.factor similarity index 99% rename from basis/io/windows/nt/launcher/launcher-tests.factor rename to basis/io/launcher/windows/nt/nt-tests.factor index cbae2f5eca..2cdb7d5f89 100644 --- a/basis/io/windows/nt/launcher/launcher-tests.factor +++ b/basis/io/launcher/windows/nt/nt-tests.factor @@ -1,7 +1,7 @@ USING: io.launcher tools.test calendar accessors environment namespaces kernel system arrays io io.files io.encodings.ascii sequences parser assocs hashtables math continuations eval ; -IN: io.windows.launcher.nt.tests +IN: io.launcher.windows.nt.tests [ ] [ diff --git a/basis/io/windows/nt/launcher/launcher.factor b/basis/io/launcher/windows/nt/nt.factor similarity index 95% rename from basis/io/windows/nt/launcher/launcher.factor rename to basis/io/launcher/windows/nt/nt.factor index de4fb99c64..d098456486 100644 --- a/basis/io/windows/nt/launcher/launcher.factor +++ b/basis/io/launcher/windows/nt/nt.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays continuations destructors io -io.windows libc io.ports io.pipes windows.types math +io.backend.windows libc io.ports io.pipes windows.types math windows.kernel32 windows namespaces make io.launcher kernel sequences windows.errors assocs splitting system strings -io.windows.launcher io.windows.files io.backend io.files +io.launcher.windows io.files.windows io.backend io.files io.files.private combinators shuffle accessors locals ; -IN: io.windows.nt.launcher +IN: io.backend.windows.nt.launcher : duplicate-handle ( handle -- handle' ) GetCurrentProcess ! source process diff --git a/basis/io/unix/sockets/tags.txt b/basis/io/launcher/windows/nt/tags.txt similarity index 100% rename from basis/io/unix/sockets/tags.txt rename to basis/io/launcher/windows/nt/tags.txt diff --git a/basis/io/windows/nt/launcher/test/append.factor b/basis/io/launcher/windows/nt/test/append.factor similarity index 100% rename from basis/io/windows/nt/launcher/test/append.factor rename to basis/io/launcher/windows/nt/test/append.factor diff --git a/basis/io/windows/nt/launcher/test/env.factor b/basis/io/launcher/windows/nt/test/env.factor similarity index 100% rename from basis/io/windows/nt/launcher/test/env.factor rename to basis/io/launcher/windows/nt/test/env.factor diff --git a/basis/io/windows/nt/launcher/test/stderr.factor b/basis/io/launcher/windows/nt/test/stderr.factor similarity index 100% rename from basis/io/windows/nt/launcher/test/stderr.factor rename to basis/io/launcher/windows/nt/test/stderr.factor diff --git a/basis/io/unix/tags.txt b/basis/io/launcher/windows/tags.txt similarity index 100% rename from basis/io/unix/tags.txt rename to basis/io/launcher/windows/tags.txt diff --git a/basis/io/windows/launcher/launcher-tests.factor b/basis/io/launcher/windows/windows-tests.factor similarity index 79% rename from basis/io/windows/launcher/launcher-tests.factor rename to basis/io/launcher/windows/windows-tests.factor index 1dba8bd0ec..1a3fe823a5 100644 --- a/basis/io/windows/launcher/launcher-tests.factor +++ b/basis/io/launcher/windows/windows-tests.factor @@ -1,5 +1,5 @@ -IN: io.windows.launcher.tests -USING: tools.test io.windows.launcher ; +IN: io.launcher.windows.tests +USING: tools.test io.launcher.windows ; [ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test diff --git a/basis/io/windows/launcher/launcher.factor b/basis/io/launcher/windows/windows.factor similarity index 98% rename from basis/io/windows/launcher/launcher.factor rename to basis/io/launcher/windows/windows.factor index fd31ca999f..1e6d1f1a6d 100644 --- a/basis/io/windows/launcher/launcher.factor +++ b/basis/io/launcher/windows/windows.factor @@ -1,14 +1,14 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays continuations io -io.windows io.windows.nt.pipes libc io.ports +io.backend.windows io.pipes.windows.nt libc io.ports windows.types math windows.kernel32 namespaces make io.launcher kernel sequences windows.errors splitting system threads init strings combinators io.backend accessors concurrency.flags io.files assocs io.files.private windows destructors specialized-arrays.ushort specialized-arrays.alien ; -IN: io.windows.launcher +IN: io.launcher.windows TUPLE: CreateProcess-args lpApplicationName diff --git a/basis/io/mmap/mmap.factor b/basis/io/mmap/mmap.factor index 3cf451bd03..5c867d9a45 100644 --- a/basis/io/mmap/mmap.factor +++ b/basis/io/mmap/mmap.factor @@ -21,6 +21,6 @@ M: mapped-file dispose* ( mmap -- ) close-mapped-file ; [ ] dip with-disposal ; inline { - { [ os unix? ] [ "io.unix.mmap" require ] } - { [ os winnt? ] [ "io.windows.mmap" require ] } + { [ os unix? ] [ "io.mmap.unix" require ] } + { [ os winnt? ] [ "io.mmap.windows" require ] } } cond diff --git a/basis/io/unix/mmap/authors.txt b/basis/io/mmap/unix/authors.txt similarity index 100% rename from basis/io/unix/mmap/authors.txt rename to basis/io/mmap/unix/authors.txt diff --git a/basis/io/windows/files/tags.txt b/basis/io/mmap/unix/tags.txt similarity index 100% rename from basis/io/windows/files/tags.txt rename to basis/io/mmap/unix/tags.txt diff --git a/basis/io/unix/mmap/mmap.factor b/basis/io/mmap/unix/unix.factor similarity index 88% rename from basis/io/unix/mmap/mmap.factor rename to basis/io/mmap/unix/unix.factor index d5dcda9436..9325dcd632 100644 --- a/basis/io/unix/mmap/mmap.factor +++ b/basis/io/mmap/unix/unix.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien io io.files kernel math math.bitwise system unix -io.unix.backend io.ports io.mmap destructors locals accessors ; -IN: io.unix.mmap +io.backend.unix io.ports io.mmap destructors locals accessors ; +IN: io.mmap.unix : open-r/w ( path -- fd ) O_RDWR file-mode open-file ; diff --git a/basis/io/mmap/windows/authors.txt b/basis/io/mmap/windows/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/io/mmap/windows/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/io/windows/files/unique/tags.txt b/basis/io/mmap/windows/tags.txt similarity index 100% rename from basis/io/windows/files/unique/tags.txt rename to basis/io/mmap/windows/tags.txt diff --git a/basis/io/windows/mmap/mmap.factor b/basis/io/mmap/windows/windows.factor similarity index 94% rename from basis/io/windows/mmap/mmap.factor rename to basis/io/mmap/windows/windows.factor index e5b0d10f2f..fcdf416511 100644 --- a/basis/io/windows/mmap/mmap.factor +++ b/basis/io/mmap/windows/windows.factor @@ -1,9 +1,9 @@ USING: alien alien.c-types arrays destructors generic io.mmap -io.ports io.windows io.windows.files io.windows.privileges +io.ports io.backend.windows io.files.windows io.backend.windows.privileges kernel libc math math.bitwise namespaces quotations sequences windows windows.advapi32 windows.kernel32 io.backend system accessors locals ; -IN: io.windows.mmap +IN: io.mmap.windows : create-file-mapping ( hFile lpAttributes flProtect dwMaximumSizeHigh dwMaximumSizeLow lpName -- HANDLE ) CreateFileMapping [ win32-error=0/f ] keep ; diff --git a/basis/io/unix/linux/monitors/monitors-tests.factor b/basis/io/monitors/linux/linux-tests.factor similarity index 97% rename from basis/io/unix/linux/monitors/monitors-tests.factor rename to basis/io/monitors/linux/linux-tests.factor index 42c5009ccb..8e2cebc3a4 100644 --- a/basis/io/unix/linux/monitors/monitors-tests.factor +++ b/basis/io/monitors/linux/linux-tests.factor @@ -1,4 +1,4 @@ -IN: io.unix.linux.monitors.tests +IN: io.monitors.linux.tests USING: io.monitors tools.test io.files system sequences continuations namespaces concurrency.count-downs kernel io threads calendar prettyprint destructors io.timeouts ; diff --git a/basis/io/unix/linux/monitors/monitors.factor b/basis/io/monitors/linux/linux.factor similarity index 97% rename from basis/io/unix/linux/monitors/monitors.factor rename to basis/io/monitors/linux/linux.factor index 3964a25a04..12efd8112d 100644 --- a/basis/io/unix/linux/monitors/monitors.factor +++ b/basis/io/monitors/linux/linux.factor @@ -2,11 +2,11 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel io.backend io.monitors io.monitors.recursive io.files io.buffers io.monitors io.ports io.timeouts -io.unix.backend io.encodings.utf8 unix.linux.inotify assocs +io.backend.unix io.encodings.utf8 unix.linux.inotify assocs namespaces make threads continuations init math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors system hashtables destructors unix ; -IN: io.unix.linux.monitors +IN: io.monitors.linux SYMBOL: watches diff --git a/basis/io/windows/launcher/tags.txt b/basis/io/monitors/linux/tags.txt similarity index 100% rename from basis/io/windows/launcher/tags.txt rename to basis/io/monitors/linux/tags.txt diff --git a/basis/io/unix/macosx/monitors/monitors.factor b/basis/io/monitors/macosx/macosx.factor similarity index 96% rename from basis/io/unix/macosx/monitors/monitors.factor rename to basis/io/monitors/macosx/macosx.factor index cde1d6339a..be1dcc64b6 100644 --- a/basis/io/unix/macosx/monitors/monitors.factor +++ b/basis/io/monitors/macosx/macosx.factor @@ -3,7 +3,7 @@ USING: io.backend io.monitors core-foundation.fsevents continuations kernel sequences namespaces arrays system locals accessors destructors fry ; -IN: io.unix.macosx.monitors +IN: io.monitors.macosx TUPLE: macosx-monitor < monitor handle ; diff --git a/basis/io/windows/mmap/tags.txt b/basis/io/monitors/macosx/tags.txt similarity index 100% rename from basis/io/windows/mmap/tags.txt rename to basis/io/monitors/macosx/tags.txt diff --git a/basis/io/monitors/monitors.factor b/basis/io/monitors/monitors.factor index 72f2bc80c5..e225e45430 100644 --- a/basis/io/monitors/monitors.factor +++ b/basis/io/monitors/monitors.factor @@ -56,8 +56,8 @@ SYMBOL: +rename-file+ [ ] dip with-disposal ; inline { - { [ os macosx? ] [ "io.unix.macosx.monitors" require ] } - { [ os linux? ] [ "io.unix.linux.monitors" require ] } - { [ os winnt? ] [ "io.windows.nt.monitors" require ] } + { [ os macosx? ] [ "io.monitors.macosx" require ] } + { [ os linux? ] [ "io.monitors.linux" require ] } + { [ os winnt? ] [ "io.monitors.windows.nt" require ] } [ ] } cond diff --git a/basis/io/monitors/windows/nt/authors.txt b/basis/io/monitors/windows/nt/authors.txt new file mode 100755 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/io/monitors/windows/nt/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/io/monitors/windows/nt/nt-tests.factor b/basis/io/monitors/windows/nt/nt-tests.factor new file mode 100644 index 0000000000..79cd7e9e9f --- /dev/null +++ b/basis/io/monitors/windows/nt/nt-tests.factor @@ -0,0 +1,4 @@ +IN: io.monitors.windows.nt.tests +USING: io.monitors.windows.nt tools.test ; + +\ fill-queue-thread must-infer diff --git a/basis/io/windows/nt/monitors/monitors.factor b/basis/io/monitors/windows/nt/nt.factor similarity index 95% rename from basis/io/windows/nt/monitors/monitors.factor rename to basis/io/monitors/windows/nt/nt.factor index a2b7c4fa2d..57bd07ef24 100755 --- a/basis/io/windows/nt/monitors/monitors.factor +++ b/basis/io/monitors/windows/nt/nt.factor @@ -3,11 +3,11 @@ USING: alien alien.c-types alien.strings libc destructors locals kernel math assocs namespaces make continuations sequences hashtables sorting arrays combinators math.bitwise strings -system accessors threads splitting io.backend io.windows -io.windows.nt.backend io.windows.nt.files io.monitors io.ports +system accessors threads splitting io.backend io.backend.windows +io.backend.windows.nt io.files.windows.nt io.monitors io.ports io.buffers io.files io.timeouts io.encodings.string io.encodings.utf16n io windows windows.kernel32 windows.types ; -IN: io.windows.nt.monitors +IN: io.monitors.windows.nt : open-directory ( path -- handle ) normalize-path diff --git a/basis/io/windows/nt/backend/tags.txt b/basis/io/monitors/windows/nt/tags.txt similarity index 100% rename from basis/io/windows/nt/backend/tags.txt rename to basis/io/monitors/windows/nt/tags.txt diff --git a/basis/io/pipes/pipes.factor b/basis/io/pipes/pipes.factor index 3a7fa5a2e0..9cadb3f6cc 100644 --- a/basis/io/pipes/pipes.factor +++ b/basis/io/pipes/pipes.factor @@ -53,7 +53,7 @@ PRIVATE> ] 2parallel-map ; { - { [ os unix? ] [ "io.unix.pipes" require ] } - { [ os winnt? ] [ "io.windows.nt.pipes" require ] } + { [ os unix? ] [ "io.pipes.unix" require ] } + { [ os winnt? ] [ "io.pipes.windows.nt" require ] } [ ] } cond diff --git a/basis/io/unix/pipes/pipes-tests.factor b/basis/io/pipes/unix/pipes-tests.factor similarity index 81% rename from basis/io/unix/pipes/pipes-tests.factor rename to basis/io/pipes/unix/pipes-tests.factor index 6ea74043ca..ce3f1551b1 100644 --- a/basis/io/unix/pipes/pipes-tests.factor +++ b/basis/io/pipes/unix/pipes-tests.factor @@ -1,6 +1,6 @@ -USING: tools.test io.pipes io.unix.pipes io.encodings.utf8 +USING: tools.test io.pipes io.pipes.unix io.encodings.utf8 io.encodings io namespaces sequences ; -IN: io.unix.pipes.tests +IN: io.pipes.unix.tests [ { 0 0 } ] [ { "ls" "grep ." } run-pipeline ] unit-test diff --git a/basis/io/unix/pipes/pipes.factor b/basis/io/pipes/unix/pipes.factor similarity index 80% rename from basis/io/unix/pipes/pipes.factor rename to basis/io/pipes/unix/pipes.factor index a28738e147..acf8b787ed 100644 --- a/basis/io/unix/pipes/pipes.factor +++ b/basis/io/pipes/unix/pipes.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: system kernel unix math sequences qualified -io.unix.backend io.ports specialized-arrays.int accessors ; -IN: io.unix.pipes +io.backend.unix io.ports specialized-arrays.int accessors ; +IN: io.pipes.unix QUALIFIED: io.pipes M: unix io.pipes:(pipe) ( -- pair ) diff --git a/basis/io/windows/nt/files/tags.txt b/basis/io/pipes/unix/tags.txt similarity index 100% rename from basis/io/windows/nt/files/tags.txt rename to basis/io/pipes/unix/tags.txt diff --git a/basis/io/unix/multiplexers/epoll/authors.txt b/basis/io/pipes/windows/nt/authors.txt similarity index 100% rename from basis/io/unix/multiplexers/epoll/authors.txt rename to basis/io/pipes/windows/nt/authors.txt diff --git a/basis/io/windows/nt/pipes/pipes.factor b/basis/io/pipes/windows/nt/pipes.factor similarity index 92% rename from basis/io/windows/nt/pipes/pipes.factor rename to basis/io/pipes/windows/nt/pipes.factor index d498875c87..cec03cf6d3 100644 --- a/basis/io/windows/nt/pipes/pipes.factor +++ b/basis/io/pipes/windows/nt/pipes.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types arrays destructors io io.windows libc +USING: alien alien.c-types arrays destructors io io.backend.windows libc windows.types math.bitwise windows.kernel32 windows namespaces make kernel sequences windows.errors assocs math.parser system random combinators accessors io.pipes io.ports ; -IN: io.windows.nt.pipes +IN: io.pipes.windows.nt ! This code is based on ! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py diff --git a/basis/io/windows/nt/launcher/tags.txt b/basis/io/pipes/windows/nt/tags.txt similarity index 100% rename from basis/io/windows/nt/launcher/tags.txt rename to basis/io/pipes/windows/nt/tags.txt diff --git a/basis/io/sockets/secure/secure.factor b/basis/io/sockets/secure/secure.factor index e752e7c328..c0d70fc047 100644 --- a/basis/io/sockets/secure/secure.factor +++ b/basis/io/sockets/secure/secure.factor @@ -97,6 +97,6 @@ HOOK: send-secure-handshake secure-socket-backend ( -- ) HOOK: accept-secure-handshake secure-socket-backend ( -- ) { - { [ os unix? ] [ "io.unix.sockets.secure" require ] } + { [ os unix? ] [ "io.sockets.secure.unix" require ] } { [ os windows? ] [ "openssl" require ] } } cond diff --git a/basis/io/unix/sockets/secure/debug/debug.factor b/basis/io/sockets/secure/unix/debug/debug.factor similarity index 91% rename from basis/io/unix/sockets/secure/debug/debug.factor rename to basis/io/sockets/secure/unix/debug/debug.factor index cd5353ea7b..d32cdee2ed 100644 --- a/basis/io/unix/sockets/secure/debug/debug.factor +++ b/basis/io/sockets/secure/unix/debug/debug.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors io.sockets.secure kernel ; -IN: io.unix.sockets.secure.debug +IN: io.sockets.secure.unix.debug : with-test-context ( quot -- ) diff --git a/basis/io/windows/nt/monitors/tags.txt b/basis/io/sockets/secure/unix/tags.txt similarity index 100% rename from basis/io/windows/nt/monitors/tags.txt rename to basis/io/sockets/secure/unix/tags.txt diff --git a/basis/io/unix/sockets/secure/secure-tests.factor b/basis/io/sockets/secure/unix/unix-tests.factor similarity index 97% rename from basis/io/unix/sockets/secure/secure-tests.factor rename to basis/io/sockets/secure/unix/unix-tests.factor index 0816dd270b..a3bfacc8a8 100644 --- a/basis/io/unix/sockets/secure/secure-tests.factor +++ b/basis/io/sockets/secure/unix/unix-tests.factor @@ -1,9 +1,9 @@ IN: io.sockets.secure.tests USING: accessors kernel namespaces io io.sockets io.sockets.secure io.encodings.ascii io.streams.duplex -io.unix.backend classes words destructors threads tools.test +io.backend.unix classes words destructors threads tools.test concurrency.promises byte-arrays locals calendar io.timeouts -io.unix.sockets.secure.debug ; +io.sockets.secure.unix.debug ; \ must-infer { 1 0 } [ [ ] with-secure-context ] must-infer-as diff --git a/basis/io/unix/sockets/secure/secure.factor b/basis/io/sockets/secure/unix/unix.factor similarity index 98% rename from basis/io/unix/sockets/secure/secure.factor rename to basis/io/sockets/secure/unix/unix.factor index 106b6569ed..8419246eb6 100644 --- a/basis/io/unix/sockets/secure/secure.factor +++ b/basis/io/sockets/secure/unix/unix.factor @@ -4,10 +4,10 @@ USING: accessors unix byte-arrays kernel sequences namespaces math math.order combinators init alien alien.c-types alien.strings libc continuations destructors openssl openssl.libcrypto openssl.libssl io io.files io.ports -io.unix.backend io.unix.sockets io.encodings.ascii io.buffers +io.backend.unix io.sockets.unix io.encodings.ascii io.buffers io.sockets io.sockets.secure io.sockets.secure.openssl io.timeouts system summary fry ; -IN: io.unix.sockets.secure +IN: io.sockets.secure.unix M: ssl-handle handle-fd file>> handle-fd ; diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor index 597aa61138..8268030ace 100644 --- a/basis/io/sockets/sockets.factor +++ b/basis/io/sockets/sockets.factor @@ -318,7 +318,6 @@ M: inet (server) invalid-inet-server ; { - { [ os unix? ] [ "io.unix.sockets" require ] } - { [ os winnt? ] [ "io.windows.nt.sockets" require ] } - { [ os wince? ] [ "io.windows.ce.sockets" require ] } + { [ os unix? ] [ "io.sockets.unix" require ] } + { [ os winnt? ] [ "io.sockets.windows.nt" require ] } } cond diff --git a/basis/io/unix/multiplexers/kqueue/authors.txt b/basis/io/sockets/unix/authors.txt old mode 100755 new mode 100644 similarity index 100% rename from basis/io/unix/multiplexers/kqueue/authors.txt rename to basis/io/sockets/unix/authors.txt diff --git a/basis/io/unix/sockets/summary.txt b/basis/io/sockets/unix/summary.txt similarity index 100% rename from basis/io/unix/sockets/summary.txt rename to basis/io/sockets/unix/summary.txt diff --git a/basis/io/windows/nt/pipes/tags.txt b/basis/io/sockets/unix/tags.txt similarity index 100% rename from basis/io/windows/nt/pipes/tags.txt rename to basis/io/sockets/unix/tags.txt diff --git a/basis/io/unix/sockets/sockets.factor b/basis/io/sockets/unix/unix.factor similarity index 96% rename from basis/io/unix/sockets/sockets.factor rename to basis/io/sockets/unix/unix.factor index 5fba7badb0..90d034a338 100644 --- a/basis/io/unix/sockets/sockets.factor +++ b/basis/io/sockets/unix/unix.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings generic kernel math namespaces threads sequences byte-arrays io.ports -io.binary io.unix.backend io.streams.duplex +io.binary io.backend.unix io.streams.duplex io.backend io.ports io.files io.files.private io.encodings.utf8 math.parser continuations libc combinators system accessors qualified destructors unix locals init ; @@ -10,7 +10,7 @@ system accessors qualified destructors unix locals init ; EXCLUDE: io => read write close ; EXCLUDE: io.sockets => accept ; -IN: io.unix.sockets +IN: io.sockets.unix : socket-fd ( domain type -- fd ) 0 socket dup io-error init-fd |dispose ; @@ -96,7 +96,7 @@ SYMBOL: receive-buffer : packet-size 65536 ; inline -[ packet-size malloc receive-buffer set-global ] "io.unix.sockets" add-init-hook +[ packet-size malloc receive-buffer set-global ] "io.sockets.unix" add-init-hook :: do-receive ( port -- packet sockaddr ) port addr>> empty-sockaddr/size [| sockaddr len | diff --git a/basis/io/windows/nt/sockets/authors.txt b/basis/io/sockets/windows/nt/authors.txt similarity index 100% rename from basis/io/windows/nt/sockets/authors.txt rename to basis/io/sockets/windows/nt/authors.txt diff --git a/basis/io/windows/nt/sockets/sockets.factor b/basis/io/sockets/windows/nt/nt.factor similarity index 97% rename from basis/io/windows/nt/sockets/sockets.factor rename to basis/io/sockets/windows/nt/nt.factor index ecd9ea9d9b..f6a1bcfcb0 100644 --- a/basis/io/windows/nt/sockets/sockets.factor +++ b/basis/io/sockets/windows/nt/nt.factor @@ -1,9 +1,9 @@ USING: alien alien.accessors alien.c-types byte-arrays continuations destructors io.ports io.timeouts io.sockets -io.sockets io namespaces io.streams.duplex io.windows -io.windows.sockets io.windows.nt.backend windows.winsock kernel +io.sockets io namespaces io.streams.duplex io.backend.windows +io.sockets.windows io.backend.windows.nt windows.winsock kernel libc math sequences threads system combinators accessors ; -IN: io.windows.nt.sockets +IN: io.sockets.windows.nt : malloc-int ( object -- object ) "int" heap-size malloc tuck 0 set-alien-signed-4 ; inline diff --git a/basis/io/windows/nt/privileges/tags.txt b/basis/io/sockets/windows/nt/tags.txt similarity index 100% rename from basis/io/windows/nt/privileges/tags.txt rename to basis/io/sockets/windows/nt/tags.txt diff --git a/basis/io/windows/nt/sockets/tags.txt b/basis/io/sockets/windows/tags.txt similarity index 100% rename from basis/io/windows/nt/sockets/tags.txt rename to basis/io/sockets/windows/tags.txt diff --git a/basis/io/windows/sockets/sockets.factor b/basis/io/sockets/windows/windows.factor similarity index 92% rename from basis/io/windows/sockets/sockets.factor rename to basis/io/sockets/windows/windows.factor index 809af605e0..29009403fc 100644 --- a/basis/io/windows/sockets/sockets.factor +++ b/basis/io/sockets/windows/windows.factor @@ -1,6 +1,6 @@ -USING: kernel accessors io.sockets io.windows io.backend +USING: kernel accessors io.sockets io.backend.windows io.backend windows.winsock system destructors alien.c-types ; -IN: io.windows.sockets +IN: io.sockets.windows HOOK: WSASocket-flags io-backend ( -- DWORD ) diff --git a/basis/io/unix/epoll/epoll.factor b/basis/io/unix/epoll/epoll.factor deleted file mode 100644 index 93d0b4aa99..0000000000 --- a/basis/io/unix/epoll/epoll.factor +++ /dev/null @@ -1,63 +0,0 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types kernel io.ports io.unix.backend -bit-arrays sequences assocs struct-arrays math namespaces locals -fry unix unix.linux.epoll unix.time ; -IN: io.unix.epoll - -TUPLE: epoll-mx < mx events ; - -: max-events ( -- n ) - #! We read up to 256 events at a time. This is an arbitrary - #! constant... - 256 ; inline - -: ( -- mx ) - epoll-mx new-mx - max-events epoll_create dup io-error >>fd - max-events "epoll-event" >>events ; - -: make-event ( fd events -- event ) - "epoll-event" - [ set-epoll-event-events ] keep - [ set-epoll-event-fd ] keep ; - -:: do-epoll-ctl ( fd mx what events -- ) - mx fd>> what fd fd events make-event epoll_ctl io-error ; - -: do-epoll-add ( fd mx events -- ) - EPOLL_CTL_ADD swap EPOLLONESHOT bitor do-epoll-ctl ; - -: do-epoll-del ( fd mx events -- ) - EPOLL_CTL_DEL swap do-epoll-ctl ; - -M: epoll-mx add-input-callback ( thread fd mx -- ) - [ EPOLLIN do-epoll-add ] [ call-next-method ] 2bi ; - -M: epoll-mx add-output-callback ( thread fd mx -- ) - [ EPOLLOUT do-epoll-add ] [ call-next-method ] 2bi ; - -M: epoll-mx remove-input-callbacks ( fd mx -- seq ) - 2dup reads>> key? [ - [ call-next-method ] [ EPOLLIN do-epoll-del ] 2bi - ] [ 2drop f ] if ; - -M: epoll-mx remove-output-callbacks ( fd mx -- seq ) - 2dup writes>> key? [ - [ EPOLLOUT do-epoll-del ] [ call-next-method ] 2bi - ] [ 2drop f ] if ; - -: wait-event ( mx us -- n ) - [ [ fd>> ] [ events>> ] bi [ underlying>> ] [ length ] bi ] [ 1000 /i ] bi* - epoll_wait multiplexer-error ; - -: handle-event ( event mx -- ) - [ epoll-event-fd ] dip - [ EPOLLIN EPOLLOUT bitor do-epoll-del ] - [ input-available ] [ output-available ] 2tri ; - -: handle-events ( mx n -- ) - [ dup events>> ] dip head-slice swap '[ _ handle-event ] each ; - -M: epoll-mx wait-for-events ( us mx -- ) - swap 60000000 or dupd wait-event handle-events ; diff --git a/basis/io/unix/freebsd/freebsd.factor b/basis/io/unix/freebsd/freebsd.factor deleted file mode 100644 index 49fbc9af7e..0000000000 --- a/basis/io/unix/freebsd/freebsd.factor +++ /dev/null @@ -1,3 +0,0 @@ -USING: io.unix.bsd io.backend system ; - -freebsd set-io-backend diff --git a/basis/io/unix/kqueue/kqueue.factor b/basis/io/unix/kqueue/kqueue.factor deleted file mode 100644 index be99d17572..0000000000 --- a/basis/io/unix/kqueue/kqueue.factor +++ /dev/null @@ -1,74 +0,0 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types combinators io.unix.backend -kernel math.bitwise sequences struct-arrays unix unix.kqueue -unix.time assocs ; -IN: io.unix.kqueue - -TUPLE: kqueue-mx < mx events ; - -: max-events ( -- n ) - #! We read up to 256 events at a time. This is an arbitrary - #! constant... - 256 ; inline - -: ( -- mx ) - kqueue-mx new-mx - kqueue dup io-error >>fd - max-events "kevent" >>events ; - -: make-kevent ( fd filter flags -- event ) - "kevent" - [ set-kevent-flags ] keep - [ set-kevent-filter ] keep - [ set-kevent-ident ] keep ; - -: register-kevent ( kevent mx -- ) - fd>> swap 1 f 0 f kevent io-error ; - -M: kqueue-mx add-input-callback ( thread fd mx -- ) - [ call-next-method ] [ - [ EVFILT_READ { EV_ADD EV_ONESHOT } flags make-kevent ] dip - register-kevent - ] 2bi ; - -M: kqueue-mx add-output-callback ( thread fd mx -- ) - [ call-next-method ] [ - [ EVFILT_WRITE { EV_ADD EV_ONESHOT } flags make-kevent ] dip - register-kevent - ] 2bi ; - -M: kqueue-mx remove-input-callbacks ( fd mx -- seq ) - 2dup reads>> key? [ - [ call-next-method ] [ - [ EVFILT_READ EV_DELETE make-kevent ] dip - register-kevent - ] 2bi - ] [ 2drop f ] if ; - -M: kqueue-mx remove-output-callbacks ( fd mx -- seq ) - 2dup writes>> key? [ - [ - [ EVFILT_WRITE EV_DELETE make-kevent ] dip - register-kevent - ] [ call-next-method ] 2bi - ] [ 2drop f ] if ; - -: wait-kevent ( mx timespec -- n ) - [ - [ fd>> f 0 ] - [ events>> [ underlying>> ] [ length ] bi ] bi - ] dip kevent multiplexer-error ; - -: handle-kevent ( mx kevent -- ) - [ kevent-ident swap ] [ kevent-filter ] bi { - { EVFILT_READ [ input-available ] } - { EVFILT_WRITE [ output-available ] } - } case ; - -: handle-kevents ( mx n -- ) - [ dup events>> ] dip head-slice [ handle-kevent ] with each ; - -M: kqueue-mx wait-for-events ( us mx -- ) - swap dup [ make-timespec ] when - dupd wait-kevent handle-kevents ; diff --git a/basis/io/unix/multiplexers/select/authors.txt b/basis/io/unix/multiplexers/select/authors.txt deleted file mode 100755 index 1901f27a24..0000000000 --- a/basis/io/unix/multiplexers/select/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/io/unix/netbsd/netbsd.factor b/basis/io/unix/netbsd/netbsd.factor deleted file mode 100644 index ed134788b6..0000000000 --- a/basis/io/unix/netbsd/netbsd.factor +++ /dev/null @@ -1,3 +0,0 @@ -USING: io.unix.bsd io.backend system ; - -netbsd set-io-backend diff --git a/basis/io/unix/openbsd/openbsd.factor b/basis/io/unix/openbsd/openbsd.factor deleted file mode 100644 index dfc466f94b..0000000000 --- a/basis/io/unix/openbsd/openbsd.factor +++ /dev/null @@ -1,3 +0,0 @@ -USING: io.unix.bsd io.backend system ; - -openbsd set-io-backend diff --git a/basis/io/unix/select/authors.txt b/basis/io/unix/select/authors.txt deleted file mode 100755 index 1901f27a24..0000000000 --- a/basis/io/unix/select/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/io/unix/select/select.factor b/basis/io/unix/select/select.factor deleted file mode 100644 index a6b61001a6..0000000000 --- a/basis/io/unix/select/select.factor +++ /dev/null @@ -1,56 +0,0 @@ -! Copyright (C) 2004, 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types kernel io.ports io.unix.backend -bit-arrays sequences assocs unix math namespaces -accessors math.order locals unix.time fry ; -IN: io.unix.select - -TUPLE: select-mx < mx read-fdset write-fdset ; - -! Factor's bit-arrays are an array of bytes, OS X expects -! FD_SET to be an array of cells, so we have to account for -! byte order differences on big endian platforms -: munge ( i -- i' ) - little-endian? [ BIN: 11000 bitxor ] unless ; inline - -: ( -- mx ) - select-mx new-mx - FD_SETSIZE 8 * >>read-fdset - FD_SETSIZE 8 * >>write-fdset ; - -: clear-nth ( n seq -- ? ) - [ nth ] [ [ f ] 2dip set-nth ] 2bi ; - -:: check-fd ( fd fdset mx quot -- ) - fd munge fdset clear-nth [ fd mx quot call ] when ; inline - -: check-fdset ( fds fdset mx quot -- ) - [ check-fd ] 3curry each ; inline - -: init-fdset ( fds fdset -- ) - '[ t swap munge _ set-nth ] each ; - -: read-fdset/tasks ( mx -- seq fdset ) - [ reads>> keys ] [ read-fdset>> ] bi ; - -: write-fdset/tasks ( mx -- seq fdset ) - [ writes>> keys ] [ write-fdset>> ] bi ; - -: max-fd ( assoc -- n ) - dup assoc-empty? [ drop 0 ] [ keys supremum ] if ; - -: num-fds ( mx -- n ) - [ reads>> max-fd ] [ writes>> max-fd ] bi max 1+ ; - -: init-fdsets ( mx -- nfds read write except ) - [ num-fds ] - [ read-fdset/tasks [ init-fdset ] [ underlying>> ] bi ] - [ write-fdset/tasks [ init-fdset ] [ underlying>> ] bi ] tri - f ; - -M:: select-mx wait-for-events ( us mx -- ) - mx - [ init-fdsets us dup [ make-timeval ] when select multiplexer-error drop ] - [ [ read-fdset/tasks ] keep [ input-available ] check-fdset ] - [ [ write-fdset/tasks ] keep [ output-available ] check-fdset ] - tri ; diff --git a/basis/io/unix/sockets/authors.txt b/basis/io/unix/sockets/authors.txt deleted file mode 100644 index 1901f27a24..0000000000 --- a/basis/io/unix/sockets/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/io/unix/summary.txt b/basis/io/unix/summary.txt deleted file mode 100644 index 8f66d889cc..0000000000 --- a/basis/io/unix/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Non-blocking I/O and sockets on Unix-like systems diff --git a/basis/io/unix/unix.factor b/basis/io/unix/unix.factor deleted file mode 100644 index 93b5fa620e..0000000000 --- a/basis/io/unix/unix.factor +++ /dev/null @@ -1,4 +0,0 @@ -USING: accessors system words sequences vocabs.loader -io.unix.backend io.unix.files ; - -"io.unix." os name>> append require diff --git a/basis/io/windows/nt/authors.txt b/basis/io/windows/nt/authors.txt deleted file mode 100644 index 781acc2b62..0000000000 --- a/basis/io/windows/nt/authors.txt +++ /dev/null @@ -1,2 +0,0 @@ -Doug Coleman -Mackenzie Straight diff --git a/basis/io/windows/nt/monitors/monitors-tests.factor b/basis/io/windows/nt/monitors/monitors-tests.factor deleted file mode 100644 index ef36baedc5..0000000000 --- a/basis/io/windows/nt/monitors/monitors-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -IN: io.windows.nt.monitors.tests -USING: io.windows.nt.monitors tools.test ; - -\ fill-queue-thread must-infer diff --git a/basis/io/windows/nt/nt.factor b/basis/io/windows/nt/nt.factor deleted file mode 100644 index efde4f4035..0000000000 --- a/basis/io/windows/nt/nt.factor +++ /dev/null @@ -1,7 +0,0 @@ -! Copyright (C) 2004, 2008 Mackenzie Straight, Doug Coleman, -! Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: vocabs.loader io.windows io.windows.nt.backend -io.windows.nt.files io.windows.files io.backend system ; - -winnt set-io-backend diff --git a/basis/io/windows/nt/pipes/authors.txt b/basis/io/windows/nt/pipes/authors.txt deleted file mode 100755 index 1901f27a24..0000000000 --- a/basis/io/windows/nt/pipes/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/io/windows/nt/summary.txt b/basis/io/windows/nt/summary.txt deleted file mode 100644 index 0e1b3e244f..0000000000 --- a/basis/io/windows/nt/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Microsoft Windows XP/Vista native I/O implementation diff --git a/basis/io/windows/nt/tags.txt b/basis/io/windows/nt/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/windows/nt/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/windows/privileges/tags.txt b/basis/io/windows/privileges/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/windows/privileges/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/windows/sockets/tags.txt b/basis/io/windows/sockets/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/windows/sockets/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/windows/tags.txt b/basis/io/windows/tags.txt deleted file mode 100755 index 6bf68304bb..0000000000 --- a/basis/io/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 92d039a15d..bcd91a4d94 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays byte-arrays generic hashtables io assocs -kernel math namespaces make sequences strings sbufs io.styles -vectors words prettyprint.config prettyprint.custom -prettyprint.sections quotations io io.files math.parser effects +kernel math namespaces make sequences strings sbufs vectors +words prettyprint.config prettyprint.custom prettyprint.sections +quotations io io.pathnames io.styles math.parser effects classes.tuple math.order classes.tuple.private classes combinators colors ; IN: prettyprint.backend diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 9d5af9e6a5..6b49c4a35a 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -5,7 +5,7 @@ namespaces make sequences strings io.styles io.streams.string vectors words prettyprint.backend prettyprint.custom prettyprint.sections prettyprint.config sorting splitting grouping math.parser vocabs definitions effects classes.builtin -classes.tuple io.files classes continuations hashtables +classes.tuple io.pathnames classes continuations hashtables classes.mixin classes.union classes.intersection classes.predicate classes.singleton combinators quotations sets accessors colors parser summary ; diff --git a/basis/smtp/server/server.factor b/basis/smtp/server/server.factor index 7de22e9af9..f986404404 100644 --- a/basis/smtp/server/server.factor +++ b/basis/smtp/server/server.factor @@ -4,7 +4,7 @@ USING: combinators kernel prettyprint io io.timeouts sequences namespaces io.sockets io.sockets.secure continuations calendar io.encodings.ascii io.streams.duplex destructors locals concurrency.promises threads accessors smtp.private -io.unix.sockets.secure.debug ; +io.sockets.secure.unix.debug ; IN: smtp.server ! Mock SMTP server for testing purposes. diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 1f0e482441..94cab2bb9d 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -3,7 +3,7 @@ USING: io io.files kernel namespaces make sequences system tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint -io.unix.backend cocoa io.encodings.utf8 io.backend +io.backend.unix cocoa io.encodings.utf8 io.backend cocoa.application cocoa.classes cocoa.plists qualified combinators ; IN: tools.deploy.macosx diff --git a/basis/tools/files/unix/unix.factor b/basis/tools/files/unix/unix.factor index 184f371b1c..3449968f70 100755 --- a/basis/tools/files/unix/unix.factor +++ b/basis/tools/files/unix/unix.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators kernel system unicode.case -io.unix.files tools.files generalizations strings +io.files.unix tools.files generalizations strings arrays sequences io.files math.parser unix.groups unix.users tools.files.private unix.stat math ; IN: tools.files.unix diff --git a/basis/unix/groups/groups.factor b/basis/unix/groups/groups.factor index 177949aec9..f6aa7fa3e9 100644 --- a/basis/unix/groups/groups.factor +++ b/basis/unix/groups/groups.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings io.encodings.utf8 -io.unix.backend kernel math sequences splitting unix strings +io.backend.unix kernel math sequences splitting unix strings combinators.short-circuit byte-arrays combinators qualified accessors math.parser fry assocs namespaces continuations unix.users unix.utilities ; diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor index 7d5f9eb330..04ba4d3438 100644 --- a/basis/unix/process/process.factor +++ b/basis/unix/process/process.factor @@ -1,6 +1,6 @@ USING: kernel alien.c-types alien.strings sequences math alien.syntax unix vectors kernel namespaces continuations threads assocs vectors -io.unix.backend io.encodings.utf8 unix.utilities ; +io.backend.unix io.encodings.utf8 unix.utilities ; IN: unix.process ! Low-level Unix process launching utilities. These are used diff --git a/basis/unix/stat/stat.factor b/basis/unix/stat/stat.factor index a3b0ed11b7..a3f8a5ce82 100644 --- a/basis/unix/stat/stat.factor +++ b/basis/unix/stat/stat.factor @@ -1,5 +1,5 @@ USING: kernel system combinators alien.syntax alien.c-types -math io.unix.backend vocabs.loader unix ; +math io.backend.unix vocabs.loader unix ; IN: unix.stat ! File Types diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index 555f8e2c7d..2652a95d3e 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -4,7 +4,7 @@ USING: alien alien.c-types alien.syntax kernel libc sequences continuations byte-arrays strings math namespaces system combinators vocabs.loader qualified accessors stack-checker macros locals generalizations unix.types -io io.files vocabs vocabs.loader ; +io vocabs vocabs.loader ; IN: unix : PROT_NONE 0 ; inline @@ -30,19 +30,6 @@ IN: unix : DT_SOCK 12 ; inline : DT_WHT 14 ; inline -: dirent-type>file-type ( ch -- type ) - { - { DT_BLK [ +block-device+ ] } - { DT_CHR [ +character-device+ ] } - { DT_DIR [ +directory+ ] } - { DT_LNK [ +symbolic-link+ ] } - { DT_SOCK [ +socket+ ] } - { DT_FIFO [ +fifo+ ] } - { DT_REG [ +regular-file+ ] } - { DT_WHT [ +whiteout+ ] } - [ drop +unknown+ ] - } case ; - C-STRUCT: group { "char*" "gr_name" } { "char*" "gr_passwd" } diff --git a/basis/unix/users/users.factor b/basis/unix/users/users.factor index 8487d5adf2..78417c66bf 100644 --- a/basis/unix/users/users.factor +++ b/basis/unix/users/users.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings io.encodings.utf8 -io.unix.backend kernel math sequences splitting unix strings +io.backend.unix kernel math sequences splitting unix strings combinators.short-circuit grouping byte-arrays combinators accessors math.parser fry assocs namespaces continuations vocabs.loader system ; diff --git a/core/checksums/checksums.factor b/core/checksums/checksums.factor index 699d93b8b4..a3662fcaa6 100644 --- a/core/checksums/checksums.factor +++ b/core/checksums/checksums.factor @@ -1,6 +1,6 @@ ! Copyright (c) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: sequences math.parser io io.encodings.binary io.files +USING: sequences math.parser io io.backend io.files kernel ; IN: checksums @@ -19,7 +19,10 @@ M: checksum checksum-lines [ B{ CHAR: \n } join ] dip checksum-bytes ; : checksum-file ( path checksum -- value ) - [ binary ] dip checksum-stream ; + #! normalize-path (file-reader) is equivalen to + #! binary . We use the lower-level form + #! so that we can move io.encodings.binary to basis/. + [ normalize-path (file-reader) ] dip checksum-stream ; : hex-string ( seq -- str ) [ >hex 2 CHAR: 0 pad-left ] { } map-as concat ; diff --git a/core/io/files/files-docs.factor b/core/io/files/files-docs.factor index 80b515b13f..7948a2e912 100644 --- a/core/io/files/files-docs.factor +++ b/core/io/files/files-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax io strings arrays io.backend io.files.private quotations ; IN: io.files -ARTICLE: "file-streams" "Reading and writing files" +ARTICLE: "io.files" "Reading and writing files" "File streams:" { $subsection } { $subsection } @@ -17,182 +17,10 @@ ARTICLE: "file-streams" "Reading and writing files" { $subsection with-file-writer } { $subsection with-file-appender } ; -ARTICLE: "pathnames" "Pathname manipulation" -"Pathname manipulation:" -{ $subsection parent-directory } -{ $subsection file-name } -{ $subsection last-path-separator } -{ $subsection append-path } -"Pathnames relative to Factor's temporary files directory:" -{ $subsection temp-directory } -{ $subsection temp-file } -"Pathname presentations:" -{ $subsection pathname } -{ $subsection } ; - -ARTICLE: "symbolic-links" "Symbolic links" -"Reading and creating links:" -{ $subsection read-link } -{ $subsection make-link } -"Copying links:" -{ $subsection copy-link } -"Not all operating systems support symbolic links." -{ $see-also link-info } ; - -ARTICLE: "current-directory" "Current working directory" -"File system I/O operations use the value of a variable to resolve relative pathnames:" -{ $subsection current-directory } -"This variable can be changed with a pair of words:" -{ $subsection set-current-directory } -{ $subsection with-directory } -"This variable is independent of the operating system notion of ``current working directory''. While all Factor I/O operations use the variable and not the operating system's value, care must be taken when making FFI calls which expect a pathname. The first option is to resolve relative paths:" -{ $subsection (normalize-path) } -"The second is to change the working directory of the current process:" -{ $subsection cd } -{ $subsection cwd } ; - -ARTICLE: "directories" "Directories" -"Home directory:" -{ $subsection home } -"Directory listing:" -{ $subsection directory-entries } -{ $subsection directory-files } -{ $subsection with-directory-files } -"Creating directories:" -{ $subsection make-directory } -{ $subsection make-directories } -{ $subsection "current-directory" } ; - -ARTICLE: "file-types" "File Types" -"Platform-independent types:" -{ $subsection +regular-file+ } -{ $subsection +directory+ } -"Platform-specific types:" -{ $subsection +character-device+ } -{ $subsection +block-device+ } -{ $subsection +fifo+ } -{ $subsection +symbolic-link+ } -{ $subsection +socket+ } -{ $subsection +unknown+ } ; - -ARTICLE: "fs-meta" "File metadata" -"Querying file-system metadata:" -{ $subsection file-info } -{ $subsection link-info } -{ $subsection exists? } -{ $subsection directory? } - -"File types:" -{ $subsection "file-types" } ; - -ARTICLE: "delete-move-copy" "Deleting, moving, copying files" -"Operations for deleting and copying files come in two forms:" -{ $list - { "Words named " { $snippet { $emphasis "operation" } "-file" } " which work on regular files only." } - { "Words named " { $snippet { $emphasis "operation" } "-tree" } " works on directory trees recursively, and also accepts regular files." } -} -"The operations for moving and copying files come in three flavors:" -{ $list - { "A word named " { $snippet { $emphasis "operation" } } " which takes a source and destination path." } - { "A word named " { $snippet { $emphasis "operation" } "-into" } " which takes a source path and destination directory. The destination file will be stored in the destination directory and will have the same file name as the source path." } - { "A word named " { $snippet { $emphasis "operation" } "s-into" } " which takes a sequence of source paths and destination directory." } -} -"Since both of the above lists apply to copying files, that this means that there are a total of six variations on copying a file." -$nl -"Deleting files:" -{ $subsection delete-file } -{ $subsection delete-directory } -{ $subsection delete-tree } -"Moving files:" -{ $subsection move-file } -{ $subsection move-file-into } -{ $subsection move-files-into } -"Copying files:" -{ $subsection copy-file } -{ $subsection copy-file-into } -{ $subsection copy-files-into } -"Copying directory trees recursively:" -{ $subsection copy-tree } -{ $subsection copy-tree-into } -{ $subsection copy-trees-into } -"On most operating systems, files can only be moved within the same file system. To move files between file systems, use " { $link copy-file } " followed by " { $link delete-file } " on the old name." ; - -ARTICLE: "io.files" "Basic file operations" -"The " { $vocab-link "io.files" } " vocabulary provides basic support for working with files." -{ $subsection "pathnames" } -{ $subsection "file-streams" } -{ $subsection "fs-meta" } -{ $subsection "directories" } -{ $subsection "delete-move-copy" } -{ $subsection "symbolic-links" } ; - ABOUT: "io.files" -HELP: path-separator? -{ $values { "ch" "a code point" } { "?" "a boolean" } } -{ $description "Tests if the code point is a platform-specific path separator." } -{ $examples - "On Unix:" - { $example "USING: io.files prettyprint ;" "CHAR: / path-separator? ." "t" } -} ; - -HELP: parent-directory -{ $values { "path" "a pathname string" } { "parent" "a pathname string" } } -{ $description "Strips the last component off a pathname." } -{ $examples { $example "USING: io io.files ;" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; - -HELP: file-name -{ $values { "path" "a pathname string" } { "string" string } } -{ $description "Outputs the last component of a pathname string." } -{ $examples - { $example "USING: io.files prettyprint ;" "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } - { $example "USING: io.files prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } -} ; - -! need a $class-description file-info - -HELP: file-info -{ $values { "path" "a pathname string" } { "info" file-info } } -{ $description "Queries the file system for metadata. If " { $snippet "path" } " refers to a symbolic link, it is followed. See the article " { $link "file-types" } " for a list of metadata symbols." } -{ $errors "Throws an error if the file does not exist." } ; - -HELP: link-info -{ $values { "path" "a pathname string" } { "info" "a file-info tuple" } } -{ $description "Queries the file system for metadata. If path refers to a symbolic link, information about the symbolic link itself is returned. If the file does not exist, an exception is thrown." } ; - -{ file-info link-info } related-words - -HELP: +regular-file+ -{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ; - -HELP: +directory+ -{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ; - -HELP: +symbolic-link+ -{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ; - -HELP: +character-device+ -{ $description "A Unix character device file. This type exists on Unix platforms only." } ; - -HELP: +block-device+ -{ $description "A Unix block device file. This type exists on Unix platforms only." } ; - -HELP: +fifo+ -{ $description "A Unix fifo file. This type exists on Unix platforms only." } ; - -HELP: +socket+ -{ $description "A Unix socket file. This type exists on Unix platforms only." } ; - -HELP: +unknown+ -{ $description "A unknown file type." } ; - HELP: -{ - $values - { "path" "a pathname string" } - { "encoding" "an encoding descriptor" } - { "stream" "an input stream" } -} +{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "stream" "an input stream" } } { $description "Outputs an input stream for reading from the specified pathname using the given encoding." } { $errors "Throws an error if the file is unreadable." } ; @@ -243,205 +71,6 @@ HELP: file-contents { set-file-lines file-lines set-file-contents file-contents } related-words -HELP: cwd -{ $values { "path" "a pathname string" } } -{ $description "Outputs the current working directory of the Factor process." } -{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } -{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ; - -HELP: cd -{ $values { "path" "a pathname string" } } -{ $description "Changes the current working directory of the Factor process." } -{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." } -{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ; - -{ cd cwd current-directory set-current-directory with-directory } related-words - -HELP: current-directory -{ $description "A variable holding the current directory as an absolute path. Words that use the filesystem do so in relation to this variable." -$nl -"This variable should never be set directly; instead, use " { $link set-current-directory } " or " { $link with-directory } ". This preserves the invariant that the value of this variable is an absolute path." } ; - -HELP: set-current-directory -{ $values { "path" "a pathname string" } } -{ $description "Changes the " { $link current-directory } " variable." -$nl -"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ; - -HELP: with-directory -{ $values { "path" "a pathname string" } { "quot" quotation } } -{ $description "Calls the quotation in a new dynamic scope with the " { $link current-directory } " variable rebound." -$nl -"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ; - -HELP: append-path -{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } -{ $description "Appends " { $snippet "str1" } " and " { $snippet "str2" } " to form a pathname." } ; - -HELP: prepend-path -{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } -{ $description "Appends " { $snippet "str2" } " and " { $snippet "str1" } " to form a pathname." } ; - -{ append-path prepend-path } related-words - -HELP: absolute-path? -{ $values { "path" "a pathname string" } { "?" "a boolean" } } -{ $description "Tests if a pathname is absolute. Examples of absolute pathnames are " { $snippet "/foo/bar" } " on Unix and " { $snippet "c:\\foo\\bar" } " on Windows." } ; - -HELP: windows-absolute-path? -{ $values { "path" "a pathname string" } { "?" "a boolean" } } -{ $description "Tests if a pathname is absolute on Windows. Examples of absolute pathnames on Windows are " { $snippet "c:\\foo\\bar" } " and " { $snippet "\\\\?\\c:\\foo\\bar" } " for absolute Unicode pathnames." } ; - -HELP: root-directory? -{ $values { "path" "a pathname string" } { "?" "a boolean" } } -{ $description "Tests if a pathname is a root directory. Examples of root directory pathnames are " { $snippet "/" } " on Unix and " { $snippet "c:\\" } " on Windows." } ; - -{ absolute-path? windows-absolute-path? root-directory? } related-words - HELP: exists? { $values { "path" "a pathname string" } { "?" "a boolean" } } { $description "Tests if the file named by " { $snippet "path" } " exists." } ; - -HELP: directory? -{ $values { "file-info" file-info } { "?" "a boolean" } } -{ $description "Tests if " { $snippet "file-info" } " is a directory." } ; - -HELP: (directory-entries) -{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $snippet "{ name dir? }" } " pairs" } } -{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } -{ $notes "This is a low-level word, and user code should call one of the related words instead." } ; - -HELP: directory-entries -{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $link directory-entry } " objects" } } -{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ; - -HELP: directory-files -{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } } -{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ; - -HELP: with-directory-files -{ $values { "path" "a pathname string" } { "quot" quotation } } -{ $description "Calls the quotation with the directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ; - -HELP: file-systems -{ $values { "array" array } } -{ $description "Returns an array of " { $link file-system-info } " objects returned by iterating the mount points and calling " { $link file-system-info } " on each." } ; - -HELP: file-system-info -{ $values -{ "path" "a pathname string" } -{ "file-system-info" file-system-info } } -{ $description "Returns a platform-specific object describing the file-system that contains the path. The cross-platform slot is " { $slot "free-space" } "." } ; - -HELP: resource-path -{ $values { "path" "a pathname string" } { "newpath" "a pathname string" } } -{ $description "Resolve a path relative to the Factor source code location." } ; - -HELP: pathname -{ $class-description "Class of path name objects. Path name objects can be created by calling " { $link } "." } ; - -HELP: normalize-path -{ $values { "str" "a pathname string" } { "newstr" "a new pathname string" } } -{ $description "Called by words such as " { $link } " and " { $link } " to prepare a pathname before passing it to underlying code." } ; - -HELP: ( str -- pathname ) -{ $values { "str" "a pathname string" } { "pathname" pathname } } -{ $description "Creates a new " { $link pathname } "." } ; - -HELP: make-link -{ $values { "target" "a path to the symbolic link's target" } { "symlink" "a path to new symbolic link" } } -{ $description "Creates a symbolic link." } ; - -HELP: read-link -{ $values { "symlink" "a path to an existing symbolic link" } { "path" "the path pointed to by the symbolic link" } } -{ $description "Reads the symbolic link and returns its target path." } ; - -HELP: copy-link -{ $values { "target" "a path to an existing symlink" } { "symlink" "a path to a new symbolic link" } } -{ $description "Copies a symbolic link without following the link." } ; - -{ make-link read-link copy-link } related-words - -HELP: home -{ $values { "dir" string } } -{ $description "Outputs the user's home directory." } ; - -HELP: delete-file -{ $values { "path" "a pathname string" } } -{ $description "Deletes a file." } -{ $errors "Throws an error if the file could not be deleted." } ; - -HELP: make-directory -{ $values { "path" "a pathname string" } } -{ $description "Creates a directory." } -{ $errors "Throws an error if the directory could not be created." } ; - -HELP: make-directories -{ $values { "path" "a pathname string" } } -{ $description "Creates a directory and any parent directories which do not yet exist." } -{ $errors "Throws an error if the directories could not be created." } ; - -HELP: delete-directory -{ $values { "path" "a pathname string" } } -{ $description "Deletes a directory. The directory must be empty." } -{ $errors "Throws an error if the directory could not be deleted." } ; - -HELP: touch-file -{ $values { "path" "a pathname string" } } -{ $description "Updates the modification time of a file or directory. If the file does not exist, creates a new, empty file." } -{ $errors "Throws an error if the file could not be touched." } ; - -HELP: delete-tree -{ $values { "path" "a pathname string" } } -{ $description "Deletes a file or directory, recursing into subdirectories." } -{ $errors "Throws an error if the deletion fails." } -{ $warning "Misuse of this word can lead to catastrophic data loss." } ; - -HELP: move-file -{ $values { "from" "a pathname string" } { "to" "a pathname string" } } -{ $description "Moves or renames a file." } -{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; - -HELP: move-file-into -{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } -{ $description "Moves a file to another directory without renaming it." } -{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; - -HELP: move-files-into -{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } -{ $description "Moves a set of files to another directory." } -{ $errors "Throws an error if the file does not exist or if the move operation fails." } ; - -HELP: copy-file -{ $values { "from" "a pathname string" } { "to" "a pathname string" } } -{ $description "Copies a file." } -{ $notes "This operation attempts to preserve the original file's attributes, however not all attributes may be preserved." } -{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; - -HELP: copy-file-into -{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } -{ $description "Copies a file to another directory." } -{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; - -HELP: copy-files-into -{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } -{ $description "Copies a set of files to another directory." } -{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ; - -HELP: copy-tree -{ $values { "from" "a pathname string" } { "to" "a pathname string" } } -{ $description "Copies a directory tree recursively." } -{ $notes "This operation attempts to preserve original file attributes, however not all attributes may be preserved." } -{ $errors "Throws an error if the copy operation fails." } ; - -HELP: copy-tree-into -{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } -{ $description "Copies a directory tree to another directory, recursively." } -{ $errors "Throws an error if the copy operation fails." } ; - -HELP: copy-trees-into -{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } -{ $description "Copies a set of directory trees to another directory, recursively." } -{ $errors "Throws an error if the copy operation fails." } ; - - diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 4299634642..d3ce7f4909 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -6,283 +6,57 @@ namespaces ; \ exists? must-infer \ (exists?) must-infer -\ file-info must-infer -\ link-info must-infer - -[ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test -[ ] [ "blahblah" temp-file make-directory ] unit-test -[ t ] [ "blahblah" temp-file file-info directory? ] unit-test - -[ t ] [ - [ temp-directory "loldir" append-path delete-directory ] ignore-errors - temp-directory [ - "loldir" make-directory - ] with-directory - temp-directory "loldir" append-path exists? -] unit-test - -[ ] [ - [ temp-directory "loldir" append-path delete-directory ] ignore-errors - temp-directory [ - "loldir" make-directory - "loldir" delete-directory - ] with-directory -] unit-test - -[ "file1 contents" ] [ - [ temp-directory "loldir" append-path delete-directory ] ignore-errors - temp-directory [ - "file1 contents" "file1" utf8 set-file-contents - "file1" "file2" copy-file - "file2" utf8 file-contents - ] with-directory - "file1" temp-file delete-file - "file2" temp-file delete-file -] unit-test - -[ "file3 contents" ] [ - temp-directory [ - "file3 contents" "file3" utf8 set-file-contents - "file3" "file4" move-file - "file4" utf8 file-contents - ] with-directory - "file4" temp-file delete-file -] unit-test - -[ "file5" temp-file delete-file ] ignore-errors - -[ ] [ - temp-directory [ - "file5" touch-file - "file5" delete-file - ] with-directory -] unit-test - -[ "file6" temp-file delete-file ] ignore-errors - -[ ] [ - temp-directory [ - "file6" touch-file - "file6" link-info drop - ] with-directory -] unit-test - -[ "passwd" ] [ "/etc/passwd" file-name ] unit-test -[ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test -[ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test -[ "" ] [ "" file-name ] unit-test - -[ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test -[ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test - -[ ] [ - { "Hello world." } - "test-foo.txt" temp-file ascii set-file-lines -] unit-test - -[ ] [ - "test-foo.txt" temp-file ascii [ - "Hello appender." print - ] with-file-appender -] unit-test - -[ ] [ - "test-bar.txt" temp-file ascii [ - "Hello appender." print - ] with-file-appender -] unit-test - -[ "Hello world.\nHello appender.\n" ] [ - "test-foo.txt" temp-file ascii file-contents -] unit-test - -[ "Hello appender.\n" ] [ - "test-bar.txt" temp-file ascii file-contents -] unit-test - -[ ] [ "test-foo.txt" temp-file delete-file ] unit-test - -[ ] [ "test-bar.txt" temp-file delete-file ] unit-test - -[ f ] [ "test-foo.txt" temp-file exists? ] unit-test - -[ f ] [ "test-bar.txt" temp-file exists? ] unit-test - -[ "test-blah" temp-file delete-tree ] ignore-errors - -[ ] [ "test-blah" temp-file make-directory ] unit-test - -[ ] [ - "test-blah/fooz" temp-file ascii dispose -] unit-test - -[ t ] [ - "test-blah/fooz" temp-file exists? -] unit-test - -[ ] [ "test-blah/fooz" temp-file delete-file ] unit-test - -[ ] [ "test-blah" temp-file delete-directory ] unit-test - -[ f ] [ "test-blah" temp-file exists? ] unit-test - -USE: debugger.threads - -[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test - -[ ] [ "test-quux.txt" temp-file delete-file ] unit-test - -[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test - -[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test - -[ t ] [ "quux-test.txt" temp-file exists? ] unit-test - -[ ] [ "quux-test.txt" temp-file delete-file ] unit-test - -[ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test - -[ ] [ - { "Hi" } - "delete-tree-test/a/b/c/d" temp-file ascii set-file-lines -] unit-test - -[ ] [ - "delete-tree-test" temp-file delete-tree -] unit-test - -[ { "kernel" } ] [ - "core" resource-path [ - "." directory-files [ "kernel" = ] filter - ] with-directory -] unit-test - -[ { "kernel" } ] [ - "resource:core" [ - "." directory-files [ "kernel" = ] filter - ] with-directory -] unit-test - -[ { "kernel" } ] [ - "resource:core" [ - [ "kernel" = ] filter - ] with-directory-files -] unit-test - -[ ] [ - "copy-tree-test/a/b/c" temp-file make-directories -] unit-test - -[ ] [ - "Foobar" - "copy-tree-test/a/b/c/d" temp-file - ascii set-file-contents -] unit-test - -[ ] [ - "copy-tree-test" temp-file - "copy-destination" temp-file copy-tree -] unit-test - -[ "Foobar" ] [ - "copy-destination/a/b/c/d" temp-file ascii file-contents -] unit-test - -[ ] [ - "copy-destination" temp-file delete-tree -] unit-test - -[ ] [ - "copy-tree-test" temp-file - "copy-destination" temp-file copy-tree-into -] unit-test - -[ "Foobar" ] [ - "copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents -] unit-test - -[ ] [ - "copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into -] unit-test - -[ "Foobar" ] [ - "d" temp-file ascii file-contents -] unit-test - -[ ] [ "d" temp-file delete-file ] unit-test - -[ ] [ "copy-destination" temp-file delete-tree ] unit-test - -[ ] [ "copy-tree-test" temp-file delete-tree ] unit-test - -[ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test - -[ t ] [ - temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory - temp-directory "test41" append-path utf8 file-contents "hi41" = -] unit-test - -[ t ] [ - temp-directory [ "test41" file-info size>> ] with-directory 4 = -] unit-test [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test [ ] [ "append-test" temp-file ascii dispose ] unit-test -[ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test -[ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test -[ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test -[ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test -[ "/lib" ] [ "/usr" "../lib" append-path ] unit-test -[ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test - -[ "" ] [ "" "." append-path ] unit-test -[ "" ".." append-path ] must-fail - -[ "/" ] [ "/" "./." append-path ] unit-test -[ "/" ] [ "/" "././" append-path ] unit-test -[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test -[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test - -[ "" "../lib/" append-path ] must-fail -[ "lib" ] [ "" "lib" append-path ] unit-test -[ "lib" ] [ "" "./lib" append-path ] unit-test - -[ "foo/bar/." parent-directory ] must-fail -[ "foo/bar/./" parent-directory ] must-fail -[ "foo/bar/baz/.." parent-directory ] must-fail -[ "foo/bar/baz/../" parent-directory ] must-fail - -[ "." parent-directory ] must-fail -[ "./" parent-directory ] must-fail -[ ".." parent-directory ] must-fail -[ "../" parent-directory ] must-fail -[ "../../" parent-directory ] must-fail -[ "foo/.." parent-directory ] must-fail -[ "foo/../" parent-directory ] must-fail -[ "" parent-directory ] must-fail -[ "." ] [ "boot.x86.64.image" parent-directory ] unit-test - -[ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test -[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test -[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test - -[ t ] [ "resource:core" absolute-path? ] unit-test -[ f ] [ "" absolute-path? ] unit-test - -[ "touch-twice-test" temp-file delete-file ] ignore-errors -[ ] [ 2 [ "touch-twice-test" temp-file touch-file ] times ] unit-test - -! aum's bug [ - "." current-directory set - ".." "resource-path" set - [ "../core/bootstrap/stage2.factor" ] - [ "resource:core/bootstrap/stage2.factor" (normalize-path) ] - unit-test -] with-scope + "This is a line.\rThis is another line.\r" +] [ + "resource:core/io/test/mac-os-eol.txt" latin1 + [ 500 read ] with-input-stream +] unit-test -[ t ] [ "/" file-system-info file-system-info? ] unit-test -[ t ] [ file-systems [ file-system-info? ] all? ] unit-test +[ + 255 +] [ + "resource:core/io/test/binary.txt" latin1 + [ read1 ] with-input-stream >fixnum +] unit-test + +[ ] [ + "It seems Jobs has lost his grasp on reality again.\n" + "separator-test.txt" temp-file latin1 set-file-contents +] unit-test + +[ + { + { "It seems " CHAR: J } + { "obs has lost h" CHAR: i } + { "s grasp on reality again.\n" f } + } +] [ + [ + "separator-test.txt" temp-file + latin1 [ + "J" read-until 2array , + "i" read-until 2array , + "X" read-until 2array , + ] with-input-stream + ] { } make +] unit-test + +[ ] [ + image binary [ + 10 [ 65536 read drop ] times + ] with-file-reader +] unit-test + +! Test EOF behavior +[ 10 ] [ + image binary [ + 0 read drop + 10 read length + ] with-file-reader +] unit-test diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 77b37180c6..19659ee5bb 100644 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -1,10 +1,7 @@ ! Copyright (C) 2004, 2008 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: io.backend io.files.private io hashtables kernel -kernel.private math memory namespaces sequences strings assocs -arrays definitions system combinators splitting sbufs -continuations destructors io.encodings io.encodings.binary init -accessors math.order ; +USING: kernel kernel.private sequences init namespaces system io +io.backend io.pathnames io.encodings io.files.private ; IN: io.files HOOK: (file-reader) io-backend ( path -- stream ) @@ -43,155 +40,9 @@ HOOK: (file-appender) io-backend ( path -- stream ) : with-file-appender ( path encoding quot -- ) [ ] dip with-output-stream ; inline -! Pathnames -: path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ; - -: path-separator ( -- string ) os windows? "\\" "/" ? ; - -: trim-right-separators ( str -- newstr ) - [ path-separator? ] trim-right ; - -: trim-left-separators ( str -- newstr ) - [ path-separator? ] trim-left ; - -: last-path-separator ( path -- n ? ) - [ length 1- ] keep [ path-separator? ] find-last-from ; - -HOOK: root-directory? io-backend ( path -- ? ) - -M: object root-directory? ( path -- ? ) - [ f ] [ [ path-separator? ] all? ] if-empty ; - -ERROR: no-parent-directory path ; - -: parent-directory ( path -- parent ) - dup root-directory? [ - trim-right-separators - dup last-path-separator [ - 1+ cut - ] [ - drop "." swap - ] if - { "" "." ".." } member? [ - no-parent-directory - ] when - ] unless ; - - - -: windows-absolute-path? ( path -- path ? ) - { - { [ dup "\\\\?\\" head? ] [ t ] } - { [ dup length 2 < ] [ f ] } - { [ dup second CHAR: : = ] [ t ] } - [ f ] - } cond ; - -: absolute-path? ( path -- ? ) - { - { [ dup empty? ] [ f ] } - { [ dup "resource:" head? ] [ t ] } - { [ os windows? ] [ windows-absolute-path? ] } - { [ dup first path-separator? ] [ t ] } - [ f ] - } cond nip ; - -: append-path ( str1 str2 -- str ) - { - { [ over empty? ] [ append-path-empty ] } - { [ dup empty? ] [ drop ] } - { [ over trim-right-separators "." = ] [ nip ] } - { [ dup absolute-path? ] [ nip ] } - { [ dup head.? ] [ rest trim-left-separators append-path ] } - { [ dup head..? ] [ - 2 tail trim-left-separators - [ parent-directory ] dip append-path - ] } - { [ over absolute-path? over first path-separator? and ] [ - [ 2 head ] dip append - ] } - [ - [ trim-right-separators "/" ] dip - trim-left-separators 3append - ] - } cond ; - -: prepend-path ( str1 str2 -- str ) - swap append-path ; inline - -: file-name ( path -- string ) - dup root-directory? [ - trim-right-separators - dup last-path-separator [ 1+ tail ] [ - drop "resource:" ?head [ file-name ] when - ] if - ] unless ; - -: file-extension ( filename -- extension ) - "." split1-last nip ; - -! File info -TUPLE: file-info type size permissions created modified -accessed ; - -HOOK: file-info io-backend ( path -- info ) - -! Symlinks -HOOK: link-info io-backend ( path -- info ) - -HOOK: make-link io-backend ( target symlink -- ) - -HOOK: read-link io-backend ( symlink -- path ) - -: copy-link ( target symlink -- ) - [ read-link ] dip make-link ; - -SYMBOL: +regular-file+ -SYMBOL: +directory+ -SYMBOL: +symbolic-link+ -SYMBOL: +character-device+ -SYMBOL: +block-device+ -SYMBOL: +fifo+ -SYMBOL: +socket+ -SYMBOL: +whiteout+ -SYMBOL: +unknown+ - -! File metadata : exists? ( path -- ? ) normalize-path (exists?) ; -: directory? ( file-info -- ? ) type>> +directory+ = ; - -! File-system - -HOOK: file-systems os ( -- array ) - -TUPLE: file-system-info device-name mount-point type -available-space free-space used-space total-space ; - -HOOK: file-system-info os ( path -- file-system-info ) - +! Current directory -SYMBOL: current-directory - [ cwd current-directory set-global 13 getenv cwd prepend-path \ image set-global 14 getenv cwd prepend-path \ vm set-global image parent-directory "resource-path" set-global -] "io.files" add-init-hook - -: resource-path ( path -- newpath ) - "resource-path" get prepend-path ; - -: (normalize-path) ( path -- path' ) - "resource:" ?head [ - trim-left-separators resource-path - (normalize-path) - ] [ - current-directory get prepend-path - ] if ; - -M: object normalize-path ( path -- path' ) - (normalize-path) ; - -: set-current-directory ( path -- ) - (normalize-path) current-directory set ; - -: with-directory ( path quot -- ) - [ (normalize-path) current-directory ] dip with-variable ; inline - -! Creating directories -HOOK: make-directory io-backend ( path -- ) - -: make-directories ( path -- ) - normalize-path trim-right-separators { - { [ dup "." = ] [ ] } - { [ dup root-directory? ] [ ] } - { [ dup empty? ] [ ] } - { [ dup exists? ] [ ] } - [ - dup parent-directory make-directories - dup make-directory - ] - } cond drop ; - -TUPLE: directory-entry name type ; - -HOOK: >directory-entry os ( byte-array -- directory-entry ) - -HOOK: (directory-entries) os ( path -- seq ) - -: directory-entries ( path -- seq ) - normalize-path - (directory-entries) - [ name>> { "." ".." } member? not ] filter ; - -: directory-files ( path -- seq ) - directory-entries [ name>> ] map ; - -: with-directory-files ( path quot -- ) - [ "" directory-files ] prepose with-directory ; inline - -! Touching files -HOOK: touch-file io-backend ( path -- ) - -! Deleting files -HOOK: delete-file io-backend ( path -- ) - -HOOK: delete-directory io-backend ( path -- ) - -: delete-tree ( path -- ) - dup link-info type>> +directory+ = [ - [ [ [ delete-tree ] each ] with-directory-files ] - [ delete-directory ] - bi - ] [ delete-file ] if ; - -: to-directory ( from to -- from to' ) - over file-name append-path ; - -! Moving and renaming files -HOOK: move-file io-backend ( from to -- ) - -: move-file-into ( from to -- ) - to-directory move-file ; - -: move-files-into ( files to -- ) - [ move-file-into ] curry each ; - -! Copying files -HOOK: copy-file io-backend ( from to -- ) - -M: object copy-file - dup parent-directory make-directories - binary [ - swap binary [ - swap stream-copy - ] with-disposal - ] with-disposal ; - -: copy-file-into ( from to -- ) - to-directory copy-file ; - -: copy-files-into ( files to -- ) - [ copy-file-into ] curry each ; - -DEFER: copy-tree-into - -: copy-tree ( from to -- ) - normalize-path - over link-info type>> - { - { +symbolic-link+ [ copy-link ] } - { +directory+ [ - swap [ - [ swap copy-tree-into ] with each - ] with-directory-files - ] } - [ drop copy-file ] - } case ; - -: copy-tree-into ( from to -- ) - to-directory copy-tree ; - -: copy-trees-into ( files to -- ) - [ copy-tree-into ] curry each ; - -! Special paths - -: temp-directory ( -- path ) - "temp" resource-path dup make-directories ; - -: temp-file ( name -- path ) - temp-directory prepend-path ; - -! Pathname presentations -TUPLE: pathname string ; - -C: pathname - -M: pathname <=> [ string>> ] compare ; - -! Home directory -HOOK: home io-backend ( -- dir ) - -M: object home "" resource-path ; +] "io.files" add-init-hook \ No newline at end of file diff --git a/core/io/io-tests.factor b/core/io/io-tests.factor index 18cde1a35c..009ba3a9e7 100644 --- a/core/io/io-tests.factor +++ b/core/io/io-tests.factor @@ -8,55 +8,5 @@ IN: io.tests "foo" "io.tests" lookup ] unit-test -[ - "This is a line.\rThis is another line.\r" -] [ - "resource:core/io/test/mac-os-eol.txt" latin1 - [ 500 read ] with-input-stream -] unit-test - -[ - 255 -] [ - "resource:core/io/test/binary.txt" latin1 - [ read1 ] with-input-stream >fixnum -] unit-test - ! Make sure we use correct to_c_string form when writing [ ] [ "\0" write ] unit-test - -[ ] [ - "It seems Jobs has lost his grasp on reality again.\n" - "separator-test.txt" temp-file latin1 set-file-contents -] unit-test - -[ - { - { "It seems " CHAR: J } - { "obs has lost h" CHAR: i } - { "s grasp on reality again.\n" f } - } -] [ - [ - "separator-test.txt" temp-file - latin1 [ - "J" read-until 2array , - "i" read-until 2array , - "X" read-until 2array , - ] with-input-stream - ] { } make -] unit-test - -[ ] [ - image binary [ - 10 [ 65536 read drop ] times - ] with-file-reader -] unit-test - -! Test EOF behavior -[ 10 ] [ - image binary [ - 0 read drop - 10 read length - ] with-file-reader -] unit-test diff --git a/core/io/pathnames/pathnames-docs.factor b/core/io/pathnames/pathnames-docs.factor new file mode 100644 index 0000000000..21fd5b4b36 --- /dev/null +++ b/core/io/pathnames/pathnames-docs.factor @@ -0,0 +1,78 @@ +USING: help.markup help.syntax io.backend io.files strings ; +IN: io.pathnames + +HELP: path-separator? +{ $values { "ch" "a code point" } { "?" "a boolean" } } +{ $description "Tests if the code point is a platform-specific path separator." } +{ $examples + "On Unix:" + { $example "USING: io.files prettyprint ;" "CHAR: / path-separator? ." "t" } +} ; + +HELP: parent-directory +{ $values { "path" "a pathname string" } { "parent" "a pathname string" } } +{ $description "Strips the last component off a pathname." } +{ $examples { $example "USING: io io.files ;" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; + +HELP: file-name +{ $values { "path" "a pathname string" } { "string" string } } +{ $description "Outputs the last component of a pathname string." } +{ $examples + { $example "USING: io.files prettyprint ;" "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } + { $example "USING: io.files prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } +} ; + +HELP: append-path +{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } +{ $description "Appends " { $snippet "str1" } " and " { $snippet "str2" } " to form a pathname." } ; + +HELP: prepend-path +{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } +{ $description "Appends " { $snippet "str2" } " and " { $snippet "str1" } " to form a pathname." } ; + +{ append-path prepend-path } related-words + +HELP: absolute-path? +{ $values { "path" "a pathname string" } { "?" "a boolean" } } +{ $description "Tests if a pathname is absolute. Examples of absolute pathnames are " { $snippet "/foo/bar" } " on Unix and " { $snippet "c:\\foo\\bar" } " on Windows." } ; + +HELP: windows-absolute-path? +{ $values { "path" "a pathname string" } { "?" "a boolean" } } +{ $description "Tests if a pathname is absolute on Windows. Examples of absolute pathnames on Windows are " { $snippet "c:\\foo\\bar" } " and " { $snippet "\\\\?\\c:\\foo\\bar" } " for absolute Unicode pathnames." } ; + +HELP: root-directory? +{ $values { "path" "a pathname string" } { "?" "a boolean" } } +{ $description "Tests if a pathname is a root directory. Examples of root directory pathnames are " { $snippet "/" } " on Unix and " { $snippet "c:\\" } " on Windows." } ; + +{ absolute-path? windows-absolute-path? root-directory? } related-words + +HELP: resource-path +{ $values { "path" "a pathname string" } { "newpath" "a pathname string" } } +{ $description "Resolve a path relative to the Factor source code location." } ; + +HELP: pathname +{ $class-description "Class of path name objects. Path name objects can be created by calling " { $link } "." } ; + +HELP: normalize-path +{ $values { "str" "a pathname string" } { "newstr" "a new pathname string" } } +{ $description "Called by words such as " { $link } " and " { $link } " to prepare a pathname before passing it to underlying code." } ; + +HELP: ( str -- pathname ) +{ $values { "str" "a pathname string" } { "pathname" pathname } } +{ $description "Creates a new " { $link pathname } "." } ; + +HELP: home +{ $values { "dir" string } } +{ $description "Outputs the user's home directory." } ; + +ARTICLE: "pathnames" "Pathname manipulation" +"Pathname manipulation:" +{ $subsection parent-directory } +{ $subsection file-name } +{ $subsection last-path-separator } +{ $subsection append-path } +"Pathname presentations:" +{ $subsection pathname } +{ $subsection } ; + +ABOUT: "io.pathnames" diff --git a/core/io/pathnames/pathnames-tests.factor b/core/io/pathnames/pathnames-tests.factor new file mode 100644 index 0000000000..eaf3ed0ef7 --- /dev/null +++ b/core/io/pathnames/pathnames-tests.factor @@ -0,0 +1,65 @@ +IN: io.pathnames.tests + +[ "passwd" ] [ "/etc/passwd" file-name ] unit-test +[ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test +[ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test +[ "" ] [ "" file-name ] unit-test + +[ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test +[ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test + +[ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test +[ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test +[ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test +[ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test +[ "/lib" ] [ "/usr" "../lib" append-path ] unit-test +[ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test + +[ "" ] [ "" "." append-path ] unit-test +[ "" ".." append-path ] must-fail + +[ "/" ] [ "/" "./." append-path ] unit-test +[ "/" ] [ "/" "././" append-path ] unit-test +[ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test +[ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test + +[ "" "../lib/" append-path ] must-fail +[ "lib" ] [ "" "lib" append-path ] unit-test +[ "lib" ] [ "" "./lib" append-path ] unit-test + +[ "foo/bar/." parent-directory ] must-fail +[ "foo/bar/./" parent-directory ] must-fail +[ "foo/bar/baz/.." parent-directory ] must-fail +[ "foo/bar/baz/../" parent-directory ] must-fail + +[ "." parent-directory ] must-fail +[ "./" parent-directory ] must-fail +[ ".." parent-directory ] must-fail +[ "../" parent-directory ] must-fail +[ "../../" parent-directory ] must-fail +[ "foo/.." parent-directory ] must-fail +[ "foo/../" parent-directory ] must-fail +[ "" parent-directory ] must-fail +[ "." ] [ "boot.x86.64.image" parent-directory ] unit-test + +[ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test +[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test +[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test + +[ t ] [ "resource:core" absolute-path? ] unit-test +[ f ] [ "" absolute-path? ] unit-test + +[ "touch-twice-test" temp-file delete-file ] ignore-errors +[ ] [ 2 [ "touch-twice-test" temp-file touch-file ] times ] unit-test + +! aum's bug +[ + "." current-directory set + ".." "resource-path" set + [ "../core/bootstrap/stage2.factor" ] + [ "resource:core/bootstrap/stage2.factor" (normalize-path) ] + unit-test +] with-scope + +[ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor new file mode 100644 index 0000000000..e81d8c2bfd --- /dev/null +++ b/core/io/pathnames/pathnames.factor @@ -0,0 +1,143 @@ +! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors combinators io.backend kernel math math.order +namespaces sequences splitting strings system ; +IN: io.pathnames + +SYMBOL: current-directory + +: path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ; + +: path-separator ( -- string ) os windows? "\\" "/" ? ; + +: trim-right-separators ( str -- newstr ) + [ path-separator? ] trim-right ; + +: trim-left-separators ( str -- newstr ) + [ path-separator? ] trim-left ; + +: last-path-separator ( path -- n ? ) + [ length 1- ] keep [ path-separator? ] find-last-from ; + +HOOK: root-directory? io-backend ( path -- ? ) + +M: object root-directory? ( path -- ? ) + [ f ] [ [ path-separator? ] all? ] if-empty ; + +ERROR: no-parent-directory path ; + +: parent-directory ( path -- parent ) + dup root-directory? [ + trim-right-separators + dup last-path-separator [ + 1+ cut + ] [ + drop "." swap + ] if + { "" "." ".." } member? [ + no-parent-directory + ] when + ] unless ; + + + +: windows-absolute-path? ( path -- path ? ) + { + { [ dup "\\\\?\\" head? ] [ t ] } + { [ dup length 2 < ] [ f ] } + { [ dup second CHAR: : = ] [ t ] } + [ f ] + } cond ; + +: absolute-path? ( path -- ? ) + { + { [ dup empty? ] [ f ] } + { [ dup "resource:" head? ] [ t ] } + { [ os windows? ] [ windows-absolute-path? ] } + { [ dup first path-separator? ] [ t ] } + [ f ] + } cond nip ; + +: append-path ( str1 str2 -- str ) + { + { [ over empty? ] [ append-path-empty ] } + { [ dup empty? ] [ drop ] } + { [ over trim-right-separators "." = ] [ nip ] } + { [ dup absolute-path? ] [ nip ] } + { [ dup head.? ] [ rest trim-left-separators append-path ] } + { [ dup head..? ] [ + 2 tail trim-left-separators + [ parent-directory ] dip append-path + ] } + { [ over absolute-path? over first path-separator? and ] [ + [ 2 head ] dip append + ] } + [ + [ trim-right-separators "/" ] dip + trim-left-separators 3append + ] + } cond ; + +: prepend-path ( str1 str2 -- str ) + swap append-path ; inline + +: file-name ( path -- string ) + dup root-directory? [ + trim-right-separators + dup last-path-separator [ 1+ tail ] [ + drop "resource:" ?head [ file-name ] when + ] if + ] unless ; + +: file-extension ( filename -- extension ) + "." split1-last nip ; + +: resource-path ( path -- newpath ) + "resource-path" get prepend-path ; + +GENERIC: (normalize-path) ( path -- path' ) + +M: string (normalize-path) + "resource:" ?head [ + trim-left-separators resource-path + (normalize-path) + ] [ + current-directory get prepend-path + ] if ; + +M: object normalize-path ( path -- path' ) + (normalize-path) ; + +TUPLE: pathname string ; + +C: pathname + +M: pathname (normalize-path) string>> (normalize-path) ; + +M: pathname <=> [ string>> ] compare ; + +HOOK: home io-backend ( -- dir ) + +M: object home "" resource-path ; \ No newline at end of file diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 3ae50a9a15..7ecc967e9e 100644 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays definitions generic assocs kernel math namespaces -sequences strings vectors words quotations io -combinators sorting splitting math.parser effects continuations -io.files checksums checksums.crc32 vocabs hashtables graphs +sequences strings vectors words quotations io io.files +io.pathnames combinators sorting splitting math.parser effects +continuations checksums checksums.crc32 vocabs hashtables graphs compiler.units io.encodings.utf8 accessors ; IN: source-files diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index 2b7de36d56..c1e12ea133 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -1,6 +1,6 @@ USING: generic help.syntax help.markup kernel math parser words effects classes generic.standard classes.tuple generic.math -generic.standard arrays io.files vocabs.loader io sequences +generic.standard arrays io.pathnames vocabs.loader io sequences assocs ; IN: syntax diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 0b7d9d008f..7d76bdd10b 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -4,7 +4,7 @@ USING: accessors alien arrays byte-arrays definitions generic hashtables kernel math namespaces parser lexer sequences strings strings.parser sbufs vectors words quotations io assocs splitting classes.tuple generic.standard generic.math -generic.parser classes io.files vocabs classes.parser +generic.parser classes io.pathnames vocabs classes.parser classes.union classes.intersection classes.mixin classes.predicate classes.singleton classes.tuple.parser compiler.units combinators effects.parser slots ; diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 97fbfe8a07..53f8fbadf6 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2007, 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces make sequences io.files kernel assocs words -vocabs definitions parser continuations io hashtables sorting -source-files arrays combinators strings system math.parser -compiler.errors splitting init accessors sets ; +USING: namespaces make sequences io io.files io.pathnames kernel +assocs words vocabs definitions parser continuations hashtables +sorting source-files arrays combinators strings system +math.parser compiler.errors splitting init accessors sets ; IN: vocabs.loader SYMBOL: vocab-roots From dccbb84629101fe1a9bbc64cb5672e7d26d66c00 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 14 Dec 2008 21:21:44 -0600 Subject: [PATCH 06/19] Updating unit tests for I/O re-organization --- basis/core-foundation/core-foundation.factor | 1 + basis/core-foundation/data/data.factor | 1 - basis/io/backend/unix/unix-tests.factor | 2 +- basis/io/directories/directories-tests.factor | 17 +----- basis/io/directories/directories.factor | 4 +- .../io/directories/search/search-tests.factor | 6 +- basis/io/directories/search/search.factor | 6 +- .../directories/search/windows/windows.factor | 5 +- basis/io/directories/unix/unix.factor | 9 +-- basis/io/files/info/info-tests.factor | 3 + basis/io/files/links/links.factor | 9 ++- basis/io/files/links/unix/unix.factor | 2 +- basis/io/files/unique/unique-tests.factor | 3 +- basis/io/files/unique/unique.factor | 7 ++- basis/io/files/unix/unix-tests.factor | 7 ++- basis/io/launcher/unix/unix-tests.factor | 10 ++-- basis/io/launcher/unix/unix.factor | 13 ++--- basis/io/mmap/mmap-tests.factor | 5 +- basis/io/mmap/mmap.factor | 8 +-- basis/io/monitors/monitors-tests.factor | 3 +- basis/io/paths/authors.txt | 1 - basis/io/paths/paths-tests.factor | 11 ---- basis/io/paths/paths.factor | 58 ------------------- basis/io/paths/windows/authors.txt | 1 - basis/io/paths/windows/tags.txt | 1 - basis/io/paths/windows/windows.factor | 13 ----- .../pipes/unix/{pipes.factor => unix.factor} | 0 .../windows/nt/{pipes.factor => nt.factor} | 0 .../io/sockets/secure/openssl/openssl.factor | 10 ++-- basis/io/sockets/unix/unix.factor | 2 +- basis/tools/vocabs/vocabs.factor | 12 ++-- basis/windows/shell32/shell32.factor | 9 ++- core/io/files/files-tests.factor | 24 ++++++-- 33 files changed, 100 insertions(+), 163 deletions(-) delete mode 100755 basis/io/paths/authors.txt delete mode 100644 basis/io/paths/paths-tests.factor delete mode 100755 basis/io/paths/paths.factor delete mode 100644 basis/io/paths/windows/authors.txt delete mode 100644 basis/io/paths/windows/tags.txt delete mode 100644 basis/io/paths/windows/windows.factor rename basis/io/pipes/unix/{pipes.factor => unix.factor} (100%) rename basis/io/pipes/windows/nt/{pipes.factor => nt.factor} (100%) diff --git a/basis/core-foundation/core-foundation.factor b/basis/core-foundation/core-foundation.factor index 6b7d81c862..ec83ba7a8b 100644 --- a/basis/core-foundation/core-foundation.factor +++ b/basis/core-foundation/core-foundation.factor @@ -14,6 +14,7 @@ TYPEDEF: int SInt32 TYPEDEF: uint UInt32 TYPEDEF: ulong CFTypeID TYPEDEF: UInt32 CFOptionFlags +TYPEDEF: void* CFUUIDRef FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) ; diff --git a/basis/core-foundation/data/data.factor b/basis/core-foundation/data/data.factor index 043fb905ad..f4d2babca7 100644 --- a/basis/core-foundation/data/data.factor +++ b/basis/core-foundation/data/data.factor @@ -8,7 +8,6 @@ TYPEDEF: void* CFDictionaryRef TYPEDEF: void* CFMutableDictionaryRef TYPEDEF: void* CFNumberRef TYPEDEF: void* CFSetRef -TYPEDEF: void* CFUUIDRef TYPEDEF: int CFNumberType : kCFNumberSInt8Type 1 ; inline diff --git a/basis/io/backend/unix/unix-tests.factor b/basis/io/backend/unix/unix-tests.factor index 5add7933a7..5417b9b178 100644 --- a/basis/io/backend/unix/unix-tests.factor +++ b/basis/io/backend/unix/unix-tests.factor @@ -1,4 +1,4 @@ -USING: io.files io.sockets io kernel threads +USING: io.files io.files.temp io.directories io.sockets io kernel threads namespaces tools.test continuations strings byte-arrays sequences prettyprint system io.encodings.binary io.encodings.ascii io.streams.duplex destructors make ; diff --git a/basis/io/directories/directories-tests.factor b/basis/io/directories/directories-tests.factor index 266760f925..0dd759d2b9 100644 --- a/basis/io/directories/directories-tests.factor +++ b/basis/io/directories/directories-tests.factor @@ -1,3 +1,6 @@ +USING: continuations destructors io io.directories +io.encodings.ascii io.encodings.utf8 io.files io.files.info +io.files.temp io.pathnames kernel sequences tools.test ; IN: io.directories.tests [ { "kernel" } ] [ @@ -127,20 +130,6 @@ IN: io.directories.tests [ f ] [ "test-blah" temp-file exists? ] unit-test -USE: debugger.threads - -[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test - -[ ] [ "test-quux.txt" temp-file delete-file ] unit-test - -[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test - -[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test - -[ t ] [ "quux-test.txt" temp-file exists? ] unit-test - -[ ] [ "quux-test.txt" temp-file delete-file ] unit-test - [ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test [ ] [ diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor index 8d7a276959..b6cc521851 100644 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: vocabs.loader combinators ; +USING: accessors combinators destructors io io.backend +io.encodings.binary io.files io.files.info io.files.links +io.pathnames kernel namespaces sequences system vocabs.loader ; IN: io.directories : set-current-directory ( path -- ) diff --git a/basis/io/directories/search/search-tests.factor b/basis/io/directories/search/search-tests.factor index 01763ce5c0..63c9483331 100644 --- a/basis/io/directories/search/search-tests.factor +++ b/basis/io/directories/search/search-tests.factor @@ -1,6 +1,6 @@ -USING: io.paths kernel tools.test io.files.unique sequences -io.files namespaces sorting ; -IN: io.paths.tests +USING: io.directories.search io.files io.files.unique +io.pathnames kernel namespaces sequences sorting tools.test ; +IN: io.directories.search.tests [ t ] [ [ diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index 34f06f08f2..10365e9785 100755 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -1,7 +1,9 @@ ! 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 ; +USING: accessors arrays continuations deques dlists fry +io.directories io.directories.search.private io.files +io.files.info io.pathnames kernel sequences system +vocabs.loader ; IN: io.directories.search TUPLE: directory-iterator path bfs queue ; diff --git a/basis/io/directories/search/windows/windows.factor b/basis/io/directories/search/windows/windows.factor index b4858aaef8..b9ef53f4f5 100644 --- a/basis/io/directories/search/windows/windows.factor +++ b/basis/io/directories/search/windows/windows.factor @@ -1,8 +1,7 @@ ! 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 +USING: arrays fry io.pathnames kernel sequences windows.shell32 ; +IN: io.paths : program-files-directories ( -- array ) program-files program-files-x86 2array ; inline diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor index 11712d8545..90243594d1 100644 --- a/basis/io/directories/unix/unix.factor +++ b/basis/io/directories/unix/unix.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: math.bitwise io.backend kernel io.files unix -io.backend.unix io.encodings.binary io.directories io destructors -accessors io.files.info alien.c-types io.encodings.utf8 fry -sequences system continuations alien.strings ; +USING: accessors alien.c-types alien.strings combinators +continuations destructors fry io io.backend io.backend.unix +io.directories io.encodings.binary io.encodings.utf8 io.files +io.files.info io.pathnames kernel math.bitwise sequences system +unix unix.stat ; IN: io.directories.unix : touch-mode ( -- n ) diff --git a/basis/io/files/info/info-tests.factor b/basis/io/files/info/info-tests.factor index 9d6eca13ca..b94bc0635c 100644 --- a/basis/io/files/info/info-tests.factor +++ b/basis/io/files/info/info-tests.factor @@ -1,3 +1,6 @@ +USING: io.files.info io.pathnames io.encodings.utf8 io.files +io.directories kernel io.pathnames accessors tools.test +sequences io.files.temp ; IN: io.files.info.tests \ file-info must-infer diff --git a/basis/io/files/links/links.factor b/basis/io/files/links/links.factor index 11dfe22f03..02e1a1b078 100644 --- a/basis/io/files/links/links.factor +++ b/basis/io/files/links/links.factor @@ -1,10 +1,13 @@ ! Copyright (C) 2008 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. +USING: system kernel vocabs.loader ; IN: io.files.links -HOOK: make-link io-backend ( target symlink -- ) +HOOK: make-link os ( target symlink -- ) -HOOK: read-link io-backend ( symlink -- path ) +HOOK: read-link os ( symlink -- path ) : copy-link ( target symlink -- ) - [ read-link ] dip make-link ; \ No newline at end of file + [ read-link ] dip make-link ; + +os unix? [ "io.files.links.unix" require ] when \ No newline at end of file diff --git a/basis/io/files/links/unix/unix.factor b/basis/io/files/links/unix/unix.factor index 642b287ea9..69b31c6874 100644 --- a/basis/io/files/links/unix/unix.factor +++ b/basis/io/files/links/unix/unix.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.backend io.backend.unix system unix ; +USING: io.backend io.files.links system unix ; IN: io.files.links.unix M: unix make-link ( path1 path2 -- ) diff --git a/basis/io/files/unique/unique-tests.factor b/basis/io/files/unique/unique-tests.factor index 178e4572d0..8f2e32cea2 100644 --- a/basis/io/files/unique/unique-tests.factor +++ b/basis/io/files/unique/unique-tests.factor @@ -1,5 +1,6 @@ USING: io.encodings.ascii sequences strings io io.files accessors -tools.test kernel io.files.unique namespaces continuations ; +tools.test kernel io.files.unique namespaces continuations +io.files.info io.pathnames ; IN: io.files.unique.tests [ 123 ] [ diff --git a/basis/io/files/unique/unique.factor b/basis/io/files/unique/unique.factor index e53a05b7f9..79afefa05d 100644 --- a/basis/io/files/unique/unique.factor +++ b/basis/io/files/unique/unique.factor @@ -1,8 +1,9 @@ ! 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 system -combinators vocabs.loader fry io.backend ; +USING: arrays combinators continuations fry io io.backend +io.directories io.files io.files.unique.private io.pathnames +kernel math math.bitwise math.parser namespaces random +sequences system vocabs.loader ; IN: io.files.unique HOOK: touch-unique-file io-backend ( path -- ) diff --git a/basis/io/files/unix/unix-tests.factor b/basis/io/files/unix/unix-tests.factor index a112da2876..48a128d862 100644 --- a/basis/io/files/unix/unix-tests.factor +++ b/basis/io/files/unix/unix-tests.factor @@ -1,6 +1,7 @@ -USING: tools.test io.files continuations kernel io.files.unix -math.bitwise calendar accessors math.functions math unix.users -unix.groups arrays sequences ; +USING: tools.test io.files io.files.temp io.pathnames +io.directories io.files.info io.files.info.unix continuations +kernel io.files.unix math.bitwise calendar accessors +math.functions math unix.users unix.groups arrays sequences ; IN: io.files.unix.tests [ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test diff --git a/basis/io/launcher/unix/unix-tests.factor b/basis/io/launcher/unix/unix-tests.factor index f741507011..f375bb41e8 100644 --- a/basis/io/launcher/unix/unix-tests.factor +++ b/basis/io/launcher/unix/unix-tests.factor @@ -1,9 +1,9 @@ IN: io.launcher.unix.tests -USING: io.files tools.test io.launcher arrays io namespaces -continuations math io.encodings.binary io.encodings.ascii -accessors kernel sequences io.encodings.utf8 destructors -io.streams.duplex locals concurrency.promises threads -unix.process ; +USING: io.files io.files.temp io.directories io.pathnames +tools.test io.launcher arrays io namespaces continuations math +io.encodings.binary io.encodings.ascii accessors kernel +sequences io.encodings.utf8 destructors io.streams.duplex locals +concurrency.promises threads unix.process ; [ ] [ [ "launcher-test-1" temp-file delete-file ] ignore-errors diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor index eabb0130af..ac25e4ec2f 100644 --- a/basis/io/launcher/unix/unix.factor +++ b/basis/io/launcher/unix/unix.factor @@ -1,12 +1,11 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces math system sequences -continuations arrays assocs combinators alien.c-types strings -threads accessors environment -io io.backend io.launcher io.ports io.files -io.files.private io.files.unix io.backend.unix -io.launcher.unix.parser -unix unix.process ; +USING: accessors alien.c-types arrays assocs combinators +continuations environment io io.backend io.backend.unix +io.files io.files.private io.files.unix io.launcher +io.launcher.unix.parser io.pathnames io.ports kernel math +namespaces sequences strings system threads unix unix +unix.process ; IN: io.launcher.unix ! Search unix first diff --git a/basis/io/mmap/mmap-tests.factor b/basis/io/mmap/mmap-tests.factor index dc2f0b4687..166167a7e7 100644 --- a/basis/io/mmap/mmap-tests.factor +++ b/basis/io/mmap/mmap-tests.factor @@ -1,5 +1,6 @@ -USING: io io.mmap io.mmap.char io.files kernel tools.test -continuations sequences io.encodings.ascii accessors ; +USING: io io.mmap io.mmap.char io.files io.files.temp +io.directories kernel tools.test continuations sequences +io.encodings.ascii accessors ; IN: io.mmap.tests [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors diff --git a/basis/io/mmap/mmap.factor b/basis/io/mmap/mmap.factor index 5c867d9a45..6f2fabb709 100644 --- a/basis/io/mmap/mmap.factor +++ b/basis/io/mmap/mmap.factor @@ -1,13 +1,13 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: continuations destructors io.files io.backend kernel -quotations system alien alien.accessors accessors system -vocabs.loader combinators alien.c-types ; +USING: continuations destructors io.files io.files.info +io.backend kernel quotations system alien alien.accessors +accessors system vocabs.loader combinators alien.c-types ; IN: io.mmap TUPLE: mapped-file address handle length disposed ; -HOOK: (mapped-file) io-backend ( path length -- address handle ) +HOOK: (mapped-file) os ( path length -- address handle ) : ( path -- mmap ) [ normalize-path ] [ file-info size>> ] bi [ (mapped-file) ] keep diff --git a/basis/io/monitors/monitors-tests.factor b/basis/io/monitors/monitors-tests.factor index 1cc97753b7..50303696a3 100644 --- a/basis/io/monitors/monitors-tests.factor +++ b/basis/io/monitors/monitors-tests.factor @@ -1,7 +1,8 @@ IN: io.monitors.tests USING: io.monitors tools.test io.files system sequences continuations namespaces concurrency.count-downs kernel io -threads calendar prettyprint destructors io.timeouts ; +threads calendar prettyprint destructors io.timeouts +io.files.temp io.directories io.pathnames ; os { winnt linux macosx } member? [ [ diff --git a/basis/io/paths/authors.txt b/basis/io/paths/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/basis/io/paths/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/basis/io/paths/paths-tests.factor b/basis/io/paths/paths-tests.factor deleted file mode 100644 index 01763ce5c0..0000000000 --- a/basis/io/paths/paths-tests.factor +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100755 index 212ba9e396..0000000000 --- a/basis/io/paths/paths.factor +++ /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 -kernel sequences system vocabs.loader fry continuations ; -IN: io.paths - -TUPLE: directory-iterator path bfs queue ; - -> swap bfs>> - [ push-front ] [ push-back ] if - ] curry each ; - -: ( path bfs? -- iterator ) - 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 ) - [ ] dip - [ keep and ] curry iterate-directory ; inline - -: each-file ( path bfs? quot: ( obj -- ? ) -- ) - [ ] dip - [ f ] compose iterate-directory drop ; inline - -: find-all-files ( path bfs? quot: ( obj -- ? ) -- paths ) - [ ] 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 deleted file mode 100644 index 7c1b2f2279..0000000000 --- a/basis/io/paths/windows/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/basis/io/paths/windows/tags.txt b/basis/io/paths/windows/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/basis/io/paths/windows/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/basis/io/paths/windows/windows.factor b/basis/io/paths/windows/windows.factor deleted file mode 100644 index b4858aaef8..0000000000 --- a/basis/io/paths/windows/windows.factor +++ /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 diff --git a/basis/io/pipes/unix/pipes.factor b/basis/io/pipes/unix/unix.factor similarity index 100% rename from basis/io/pipes/unix/pipes.factor rename to basis/io/pipes/unix/unix.factor diff --git a/basis/io/pipes/windows/nt/pipes.factor b/basis/io/pipes/windows/nt/nt.factor similarity index 100% rename from basis/io/pipes/windows/nt/pipes.factor rename to basis/io/pipes/windows/nt/nt.factor diff --git a/basis/io/sockets/secure/openssl/openssl.factor b/basis/io/sockets/secure/openssl/openssl.factor index 60402c37ea..0326969e4f 100644 --- a/basis/io/sockets/secure/openssl/openssl.factor +++ b/basis/io/sockets/secure/openssl/openssl.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors byte-arrays kernel sequences -namespaces math math.order combinators init alien alien.c-types -alien.strings libc continuations destructors summary -splitting assocs random math.parser locals unicode.case openssl -openssl.libcrypto openssl.libssl io.backend io.ports io.files +USING: accessors byte-arrays kernel sequences namespaces math +math.order combinators init alien alien.c-types alien.strings +libc continuations destructors summary splitting assocs random +math.parser locals unicode.case openssl openssl.libcrypto +openssl.libssl io.backend io.ports io.pathnames io.encodings.8-bit io.timeouts io.sockets.secure ; IN: io.sockets.secure.openssl diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor index 90d034a338..1dc92d7d08 100644 --- a/basis/io/sockets/unix/unix.factor +++ b/basis/io/sockets/unix/unix.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.strings generic kernel math namespaces threads sequences byte-arrays io.ports io.binary io.backend.unix io.streams.duplex -io.backend io.ports io.files io.files.private +io.backend io.ports io.pathnames io.files.private io.encodings.utf8 math.parser continuations libc combinators system accessors qualified destructors unix locals init ; diff --git a/basis/tools/vocabs/vocabs.factor b/basis/tools/vocabs/vocabs.factor index ab2d089d94..fe380e0afe 100644 --- a/basis/tools/vocabs/vocabs.factor +++ b/basis/tools/vocabs/vocabs.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel io io.styles io.files io.encodings.utf8 -vocabs.loader vocabs sequences namespaces make math.parser -arrays hashtables assocs memoize summary sorting splitting -combinators source-files debugger continuations compiler.errors -init checksums checksums.crc32 sets accessors generic -definitions words ; +USING: kernel io io.styles io.files io.files.info io.directories +io.pathnames io.encodings.utf8 vocabs.loader vocabs sequences +namespaces make math.parser arrays hashtables assocs memoize +summary sorting splitting combinators source-files debugger +continuations compiler.errors init checksums checksums.crc32 +sets accessors generic definitions words ; IN: tools.vocabs : vocab-xref ( vocab quot -- vocabs ) diff --git a/basis/windows/shell32/shell32.factor b/basis/windows/shell32/shell32.factor index eae796ac08..13d71f1ff3 100644 --- a/basis/windows/shell32/shell32.factor +++ b/basis/windows/shell32/shell32.factor @@ -1,6 +1,9 @@ -USING: alien alien.c-types alien.strings alien.syntax combinators -kernel windows windows.user32 windows.ole32 -windows.com windows.com.syntax io.files io.encodings.utf16n ; +! Copyright (C) 2006, 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien alien.c-types alien.strings alien.syntax +combinators io.encodings.utf16n io.files io.pathnames kernel +windows windows.com windows.com.syntax windows.ole32 +windows.user32 ; IN: windows.shell32 : CSIDL_DESKTOP HEX: 00 ; inline diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index d3ce7f4909..d2611d73a9 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -1,8 +1,10 @@ +USING: tools.test io.files io.files.private io.files.temp +io.directories io.encodings.8-bit arrays make system +io.encodings.binary io +threads kernel continuations io.encodings.ascii sequences +strings accessors io.encodings.utf8 math destructors namespaces +; IN: io.files.tests -USING: tools.test io.files io.files.private io threads kernel -continuations io.encodings.ascii sequences -strings accessors io.encodings.utf8 math destructors -namespaces ; \ exists? must-infer \ (exists?) must-infer @@ -60,3 +62,17 @@ namespaces ; 10 read length ] with-file-reader ] unit-test + +USE: debugger.threads + +[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test + +[ ] [ "test-quux.txt" temp-file delete-file ] unit-test + +[ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test + +[ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test + +[ t ] [ "quux-test.txt" temp-file exists? ] unit-test + +[ ] [ "quux-test.txt" temp-file delete-file ] unit-test From 6ea1de887de9d3956c0e466f5a4e04ed92fc2e18 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 14 Dec 2008 22:38:14 -0600 Subject: [PATCH 07/19] More unit test fixes --- basis/logging/server/server.factor | 10 +++++----- core/io/pathnames/pathnames-tests.factor | 3 +++ core/io/streams/c/c-tests.factor | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/basis/logging/server/server.factor b/basis/logging/server/server.factor index 1872bb0af2..68f8d74571 100644 --- a/basis/logging/server/server.factor +++ b/basis/logging/server/server.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces kernel io calendar sequences io.files -io.sockets continuations destructors prettyprint assocs -math.parser words debugger math combinators -concurrency.messaging threads arrays init math.ranges strings -calendar.format io.encodings.utf8 ; +USING: namespaces kernel io io.files io.pathnames io.directories +io.sockets io.encodings.utf8 +calendar calendar.format sequences continuations destructors +prettyprint assocs math.parser words debugger math combinators +concurrency.messaging threads arrays init math.ranges strings ; IN: logging.server : log-root ( -- string ) diff --git a/core/io/pathnames/pathnames-tests.factor b/core/io/pathnames/pathnames-tests.factor index eaf3ed0ef7..41498fa15a 100644 --- a/core/io/pathnames/pathnames-tests.factor +++ b/core/io/pathnames/pathnames-tests.factor @@ -1,3 +1,6 @@ +USING: io.pathnames io.files.temp io.directories +continuations math io.files.private kernel +namespaces tools.test ; IN: io.pathnames.tests [ "passwd" ] [ "/etc/passwd" file-name ] unit-test diff --git a/core/io/streams/c/c-tests.factor b/core/io/streams/c/c-tests.factor index 4a3d94a172..3dde9152d0 100644 --- a/core/io/streams/c/c-tests.factor +++ b/core/io/streams/c/c-tests.factor @@ -1,4 +1,4 @@ -USING: tools.test io.files io io.streams.c +USING: tools.test io.files io.files.temp io io.streams.c io.encodings.ascii strings ; IN: io.streams.c.tests From 59a5e554d4b062c4850b95e7e9c45930b6b69bcd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 00:01:06 -0600 Subject: [PATCH 08/19] Split up io.directories further, move file types to io.files.types. Bunny demo no longer pulls in file-info and file-system-info code, reducing image size by 35kb --- basis/alien/strings/windows/tags.txt | 1 + basis/bootstrap/image/image-docs.factor | 2 +- basis/bootstrap/image/image.factor | 9 +++-- basis/bootstrap/image/upload/upload.factor | 3 +- basis/editors/editors.factor | 6 +-- basis/editors/jedit/jedit.factor | 2 +- basis/http/client/client-docs.factor | 2 +- basis/http/client/client.factor | 15 +++---- basis/io/directories/directories-docs.factor | 29 +------------- basis/io/directories/directories-tests.factor | 5 ++- basis/io/directories/directories.factor | 38 +++--------------- .../hierarchy/hierarchy-docs.factor | 36 +++++++++++++++++ .../io/directories/hierarchy/hierarchy.factor | 31 ++++++++++++++ basis/io/directories/unix/unix.factor | 7 +--- basis/io/files/info/info-docs.factor | 37 +---------------- basis/io/files/info/info.factor | 12 +----- .../io/files/{ => info}/unix/unix-docs.factor | 8 ++-- basis/io/files/info/unix/unix.factor | 5 ++- basis/io/files/links/links-docs.factor | 1 + basis/io/files/types/types-docs.factor | 40 +++++++++++++++++++ basis/io/files/types/types.factor | 13 ++++++ basis/tools/deploy/backend/backend.factor | 8 ++-- .../tools/deploy/config/editor/editor.factor | 2 +- basis/tools/deploy/macosx/macosx.factor | 8 ++-- basis/tools/deploy/unix/unix.factor | 10 +++-- basis/tools/vocabs/browser/browser.factor | 4 +- basis/tools/vocabs/monitor/monitor.factor | 2 +- basis/ui/tools/operations/operations.factor | 4 +- basis/ui/tools/search/search.factor | 2 +- basis/urls/urls-docs.factor | 4 +- core/source-files/source-files-docs.factor | 2 +- 31 files changed, 187 insertions(+), 161 deletions(-) create mode 100644 basis/alien/strings/windows/tags.txt create mode 100644 basis/io/directories/hierarchy/hierarchy-docs.factor create mode 100644 basis/io/directories/hierarchy/hierarchy.factor rename basis/io/files/{ => info}/unix/unix-docs.factor (97%) create mode 100644 basis/io/files/types/types-docs.factor create mode 100644 basis/io/files/types/types.factor diff --git a/basis/alien/strings/windows/tags.txt b/basis/alien/strings/windows/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/alien/strings/windows/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/bootstrap/image/image-docs.factor b/basis/bootstrap/image/image-docs.factor index 91aa22b738..3856382ffb 100644 --- a/basis/bootstrap/image/image-docs.factor +++ b/basis/bootstrap/image/image-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax io io.files ; +USING: help.markup help.syntax io io.files io.pathnames ; IN: bootstrap.image ARTICLE: "bootstrap.image" "Bootstrapping new images" diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index c7d87776a1..d9ecdf22eb 100644 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -1,14 +1,15 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien arrays byte-arrays generic assocs hashtables assocs -hashtables.private io kernel kernel.private math namespaces make -parser prettyprint sequences sequences.private strings sbufs +hashtables.private io io.binary io.files io.encodings.binary +io.pathnames kernel kernel.private math namespaces make parser +prettyprint sequences sequences.private strings sbufs vectors words quotations assocs system layouts splitting grouping growable classes classes.builtin classes.tuple -classes.tuple.private words.private io.binary io.files vocabs +classes.tuple.private words.private vocabs vocabs.loader source-files definitions debugger quotations.private sequences.private combinators -io.encodings.binary math.order math.private accessors +math.order math.private accessors slots.private compiler.units ; IN: bootstrap.image diff --git a/basis/bootstrap/image/upload/upload.factor b/basis/bootstrap/image/upload/upload.factor index f0edf85e65..d70a253e5f 100644 --- a/basis/bootstrap/image/upload/upload.factor +++ b/basis/bootstrap/image/upload/upload.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: checksums checksums.openssl splitting assocs kernel io.files bootstrap.image sequences io namespaces make -io.launcher math io.encodings.ascii ; +io.launcher math io.encodings.ascii io.files.temp io.pathnames +io.directories ; IN: bootstrap.image.upload SYMBOL: upload-images-destination diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor index 6b49c939c3..53887bd353 100644 --- a/basis/editors/editors.factor +++ b/basis/editors/editors.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: parser lexer kernel namespaces sequences definitions -io.files summary continuations tools.crossref tools.vocabs io -prettyprint source-files assocs vocabs vocabs.loader io.backend -splitting accessors ; +io.files io.backend io.pathnames io summary continuations +tools.crossref tools.vocabs prettyprint source-files assocs +vocabs vocabs.loader splitting accessors ; IN: editors TUPLE: no-edit-hook ; diff --git a/basis/editors/jedit/jedit.factor b/basis/editors/jedit/jedit.factor index fe9abc0e76..e34f0ce175 100644 --- a/basis/editors/jedit/jedit.factor +++ b/basis/editors/jedit/jedit.factor @@ -4,7 +4,7 @@ USING: arrays definitions io kernel math namespaces parser prettyprint sequences strings words editors io.files io.sockets io.streams.byte-array io.binary math.parser io.encodings.ascii io.encodings.binary -io.encodings.utf8 io.files.private ; +io.encodings.utf8 io.files.private io.pathnames ; IN: editors.jedit : jedit-server-info ( -- port auth ) diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index 7a35ba812b..7031f5d16c 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -1,4 +1,4 @@ -USING: http help.markup help.syntax io.files io.streams.string +USING: http help.markup help.syntax io.pathnames io.streams.string io.encodings.8-bit io.encodings.binary kernel strings urls urls.encoding byte-arrays strings assocs sequences ; IN: http.client diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 108ae5ecc4..fc6e296a4f 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -1,17 +1,12 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs kernel math math.parser namespaces make -sequences io io.sockets io.streams.string io.files io.timeouts -strings splitting calendar continuations accessors vectors +sequences strings splitting calendar continuations accessors vectors math.order hashtables byte-arrays destructors -io.encodings -io.encodings.string -io.encodings.ascii -io.encodings.utf8 -io.encodings.8-bit -io.encodings.binary -io.streams.duplex -fry ascii urls urls.encoding present +io io.sockets io.streams.string io.files io.timeouts +io.pathnames io.encodings io.encodings.string io.encodings.ascii +io.encodings.utf8 io.encodings.8-bit io.encodings.binary +io.streams.duplex fry ascii urls urls.encoding present http http.parsers ; IN: http.client diff --git a/basis/io/directories/directories-docs.factor b/basis/io/directories/directories-docs.factor index 1638958e02..edfcf480b0 100644 --- a/basis/io/directories/directories-docs.factor +++ b/basis/io/directories/directories-docs.factor @@ -1,3 +1,5 @@ +USING: help.markup help.syntax io.files.private io.pathnames +quotations ; IN: io.directories HELP: cwd @@ -73,12 +75,6 @@ HELP: touch-file { $description "Updates the modification time of a file or directory. If the file does not exist, creates a new, empty file." } { $errors "Throws an error if the file could not be touched." } ; -HELP: delete-tree -{ $values { "path" "a pathname string" } } -{ $description "Deletes a file or directory, recursing into subdirectories." } -{ $errors "Throws an error if the deletion fails." } -{ $warning "Misuse of this word can lead to catastrophic data loss." } ; - HELP: move-file { $values { "from" "a pathname string" } { "to" "a pathname string" } } { $description "Moves or renames a file." } @@ -110,22 +106,6 @@ HELP: copy-files-into { $description "Copies a set of files to another directory." } { $errors "Throws an error if the file does not exist or if the copy operation fails." } ; -HELP: copy-tree -{ $values { "from" "a pathname string" } { "to" "a pathname string" } } -{ $description "Copies a directory tree recursively." } -{ $notes "This operation attempts to preserve original file attributes, however not all attributes may be preserved." } -{ $errors "Throws an error if the copy operation fails." } ; - -HELP: copy-tree-into -{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } -{ $description "Copies a directory tree to another directory, recursively." } -{ $errors "Throws an error if the copy operation fails." } ; - -HELP: copy-trees-into -{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } -{ $description "Copies a set of directory trees to another directory, recursively." } -{ $errors "Throws an error if the copy operation fails." } ; - ARTICLE: "current-directory" "Current working directory" "File system I/O operations use the value of a variable to resolve relative pathnames:" { $subsection current-directory } @@ -165,7 +145,6 @@ $nl "Deleting files:" { $subsection delete-file } { $subsection delete-directory } -{ $subsection delete-tree } "Moving files:" { $subsection move-file } { $subsection move-file-into } @@ -174,10 +153,6 @@ $nl { $subsection copy-file } { $subsection copy-file-into } { $subsection copy-files-into } -"Copying directory trees recursively:" -{ $subsection copy-tree } -{ $subsection copy-tree-into } -{ $subsection copy-trees-into } "On most operating systems, files can only be moved within the same file system. To move files between file systems, use " { $link copy-file } " followed by " { $link delete-file } " on the old name." ; ARTICLE: "io.directories" "Directory manipulation" diff --git a/basis/io/directories/directories-tests.factor b/basis/io/directories/directories-tests.factor index 0dd759d2b9..b703421b45 100644 --- a/basis/io/directories/directories-tests.factor +++ b/basis/io/directories/directories-tests.factor @@ -1,6 +1,7 @@ USING: continuations destructors io io.directories -io.encodings.ascii io.encodings.utf8 io.files io.files.info -io.files.temp io.pathnames kernel sequences tools.test ; +io.directories.hierarchy io.encodings.ascii io.encodings.utf8 +io.files io.files.info io.files.temp io.pathnames kernel +sequences tools.test ; IN: io.directories.tests [ { "kernel" } ] [ diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor index b6cc521851..0b8fa13791 100644 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators destructors io io.backend -io.encodings.binary io.files io.files.info io.files.links -io.pathnames kernel namespaces sequences system vocabs.loader ; +io.encodings.binary io.files io.pathnames kernel namespaces +sequences system vocabs.loader fry ; IN: io.directories : set-current-directory ( path -- ) @@ -42,7 +42,7 @@ HOOK: (directory-entries) os ( path -- seq ) directory-entries [ name>> ] map ; : with-directory-files ( path quot -- ) - [ "" directory-files ] prepose with-directory ; inline + '[ "" directory-files @ ] with-directory ; inline ! Touching files HOOK: touch-file io-backend ( path -- ) @@ -52,13 +52,6 @@ HOOK: delete-file io-backend ( path -- ) HOOK: delete-directory io-backend ( path -- ) -: delete-tree ( path -- ) - dup link-info type>> +directory+ = [ - [ [ [ delete-tree ] each ] with-directory-files ] - [ delete-directory ] - bi - ] [ delete-file ] if ; - : to-directory ( from to -- from to' ) over file-name append-path ; @@ -69,7 +62,7 @@ HOOK: move-file io-backend ( from to -- ) to-directory move-file ; : move-files-into ( files to -- ) - [ move-file-into ] curry each ; + '[ _ move-file-into ] each ; ! Copying files HOOK: copy-file io-backend ( from to -- ) @@ -86,28 +79,7 @@ M: object copy-file to-directory copy-file ; : copy-files-into ( files to -- ) - [ copy-file-into ] curry each ; - -DEFER: copy-tree-into - -: copy-tree ( from to -- ) - normalize-path - over link-info type>> - { - { +symbolic-link+ [ copy-link ] } - { +directory+ [ - swap [ - [ swap copy-tree-into ] with each - ] with-directory-files - ] } - [ drop copy-file ] - } case ; - -: copy-tree-into ( from to -- ) - to-directory copy-tree ; - -: copy-trees-into ( files to -- ) - [ copy-tree-into ] curry each ; + '[ _ copy-file-into ] each ; { { [ os unix? ] [ "io.directories.unix" require ] } diff --git a/basis/io/directories/hierarchy/hierarchy-docs.factor b/basis/io/directories/hierarchy/hierarchy-docs.factor new file mode 100644 index 0000000000..8b3ca7391d --- /dev/null +++ b/basis/io/directories/hierarchy/hierarchy-docs.factor @@ -0,0 +1,36 @@ +USING: help.markup help.syntax ; +IN: io.directories.hierarchy + +HELP: delete-tree +{ $values { "path" "a pathname string" } } +{ $description "Deletes a file or directory, recursing into subdirectories." } +{ $errors "Throws an error if the deletion fails." } +{ $warning "Misuse of this word can lead to catastrophic data loss." } ; + +HELP: copy-tree +{ $values { "from" "a pathname string" } { "to" "a pathname string" } } +{ $description "Copies a directory tree recursively." } +{ $notes "This operation attempts to preserve original file attributes, however not all attributes may be preserved." } +{ $errors "Throws an error if the copy operation fails." } ; + +HELP: copy-tree-into +{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } } +{ $description "Copies a directory tree to another directory, recursively." } +{ $errors "Throws an error if the copy operation fails." } ; + +HELP: copy-trees-into +{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } } +{ $description "Copies a set of directory trees to another directory, recursively." } +{ $errors "Throws an error if the copy operation fails." } ; + +ARTICLE: "io.directories.hierarchy" "Directory hierarchy manipulation" +"The " { $vocab-link "io.directories.hierarchy" } " vocabulary defines words for operating on directory hierarchies recursively." +$nl +"Deleting directory trees recursively:" +{ $subsection delete-tree } +"Copying directory trees recursively:" +{ $subsection copy-tree } +{ $subsection copy-tree-into } +{ $subsection copy-trees-into } ; + +ABOUT: "io.directories.hierarchy" diff --git a/basis/io/directories/hierarchy/hierarchy.factor b/basis/io/directories/hierarchy/hierarchy.factor new file mode 100644 index 0000000000..555f001bfc --- /dev/null +++ b/basis/io/directories/hierarchy/hierarchy.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel accessors sequences combinators fry io.directories +io.pathnames io.files.info io.files.types io.files.links +io.backend ; +IN: io.directories.hierarchy + +: delete-tree ( path -- ) + dup link-info directory? [ + [ [ [ delete-tree ] each ] with-directory-files ] + [ delete-directory ] + bi + ] [ delete-file ] if ; + +DEFER: copy-tree-into + +: copy-tree ( from to -- ) + normalize-path + over link-info type>> + { + { +symbolic-link+ [ copy-link ] } + { +directory+ [ '[ [ _ copy-tree-into ] each ] with-directory-files ] } + [ drop copy-file ] + } case ; + +: copy-tree-into ( from to -- ) + to-directory copy-tree ; + +: copy-trees-into ( files to -- ) + '[ _ copy-tree-into ] each ; + diff --git a/basis/io/directories/unix/unix.factor b/basis/io/directories/unix/unix.factor index 90243594d1..1ef80b3438 100644 --- a/basis/io/directories/unix/unix.factor +++ b/basis/io/directories/unix/unix.factor @@ -3,7 +3,7 @@ USING: accessors alien.c-types alien.strings combinators continuations destructors fry io io.backend io.backend.unix io.directories io.encodings.binary io.encodings.utf8 io.files -io.files.info io.pathnames kernel math.bitwise sequences system +io.pathnames io.files.types kernel math.bitwise sequences system unix unix.stat ; IN: io.directories.unix @@ -36,10 +36,7 @@ M: unix delete-directory ( path -- ) ] with-disposal ; M: unix copy-file ( from to -- ) - [ normalize-path ] bi@ - [ (copy-file) ] - [ swap file-info permissions>> chmod io-error ] - 2bi ; + [ normalize-path ] bi@ (copy-file) ; : with-unix-directory ( path quot -- ) [ opendir dup [ (io-error) ] unless ] dip diff --git a/basis/io/files/info/info-docs.factor b/basis/io/files/info/info-docs.factor index 8bb79851ec..8db780f976 100644 --- a/basis/io/files/info/info-docs.factor +++ b/basis/io/files/info/info-docs.factor @@ -1,3 +1,4 @@ +USING: help.markup help.syntax arrays io.files ; IN: io.files.info HELP: file-info @@ -11,30 +12,6 @@ HELP: link-info { file-info link-info } related-words -HELP: +regular-file+ -{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ; - -HELP: +directory+ -{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ; - -HELP: +symbolic-link+ -{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ; - -HELP: +character-device+ -{ $description "A Unix character device file. This type exists on Unix platforms only." } ; - -HELP: +block-device+ -{ $description "A Unix block device file. This type exists on Unix platforms only." } ; - -HELP: +fifo+ -{ $description "A Unix fifo file. This type exists on Unix platforms only." } ; - -HELP: +socket+ -{ $description "A Unix socket file. This type exists on Unix platforms only." } ; - -HELP: +unknown+ -{ $description "A unknown file type." } ; - HELP: directory? { $values { "file-info" file-info } { "?" "a boolean" } } { $description "Tests if " { $snippet "file-info" } " is a directory." } ; @@ -49,18 +26,6 @@ HELP: file-system-info { "file-system-info" file-system-info } } { $description "Returns a platform-specific object describing the file-system that contains the path. The cross-platform slot is " { $slot "free-space" } "." } ; -ARTICLE: "file-types" "File types" -"Platform-independent types:" -{ $subsection +regular-file+ } -{ $subsection +directory+ } -"Platform-specific types:" -{ $subsection +character-device+ } -{ $subsection +block-device+ } -{ $subsection +fifo+ } -{ $subsection +symbolic-link+ } -{ $subsection +socket+ } -{ $subsection +unknown+ } ; - ARTICLE: "io.files.info" "File system meta-data" "File meta-data:" { $subsection file-info } diff --git a/basis/io/files/info/info.factor b/basis/io/files/info/info.factor index ae8d806417..fd21850612 100644 --- a/basis/io/files/info/info.factor +++ b/basis/io/files/info/info.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel system sequences combinators -vocabs.loader ; +vocabs.loader io.files.types ; IN: io.files.info ! File info @@ -12,16 +12,6 @@ HOOK: file-info os ( path -- info ) HOOK: link-info os ( path -- info ) -SYMBOL: +regular-file+ -SYMBOL: +directory+ -SYMBOL: +symbolic-link+ -SYMBOL: +character-device+ -SYMBOL: +block-device+ -SYMBOL: +fifo+ -SYMBOL: +socket+ -SYMBOL: +whiteout+ -SYMBOL: +unknown+ - : directory? ( file-info -- ? ) type>> +directory+ = ; ! File systems diff --git a/basis/io/files/unix/unix-docs.factor b/basis/io/files/info/unix/unix-docs.factor similarity index 97% rename from basis/io/files/unix/unix-docs.factor rename to basis/io/files/info/unix/unix-docs.factor index eeac3cea0f..0dff2e4419 100644 --- a/basis/io/files/unix/unix-docs.factor +++ b/basis/io/files/info/unix/unix-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: classes help.markup help.syntax io.streams.string -strings math calendar io.files ; +strings math calendar io.files.info io.files.info.unix ; IN: io.files.unix HELP: file-group-id @@ -268,10 +268,10 @@ ARTICLE: "unix-file-ids" "Unix file user and group ids" { $subsection set-file-group } ; -ARTICLE: "io.files.unix" "Unix file attributes" -"The " { $vocab-link "io.files.unix" } " vocabulary implements the Unix backend for opening files and provides a high-level way to set permissions, timestamps, and user and group ids for files." +ARTICLE: "io.files.info.unix" "Unix file attributes" +"The " { $vocab-link "io.files.info.unix" } " vocabulary implements a high-level way to set Unix-specific permissions, timestamps, and user and group IDs for files." { $subsection "unix-file-permissions" } { $subsection "unix-file-timestamps" } { $subsection "unix-file-ids" } ; -ABOUT: "io.files.unix" +ABOUT: "io.files.info.unix" diff --git a/basis/io/files/info/unix/unix.factor b/basis/io/files/info/unix/unix.factor index 3d08534b71..66b95db144 100644 --- a/basis/io/files/info/unix/unix.factor +++ b/basis/io/files/info/unix/unix.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel system math math.bitwise strings arrays sequences combinators combinators.short-circuit alien.c-types -vocabs.loader calendar calendar.unix io.files.info io.backend -unix unix.stat unix.time unix.users unix.groups ; +vocabs.loader calendar calendar.unix io.files.info +io.files.types io.backend unix unix.stat unix.time unix.users +unix.groups ; IN: io.files.info.unix TUPLE: unix-file-system-info < file-system-info diff --git a/basis/io/files/links/links-docs.factor b/basis/io/files/links/links-docs.factor index 3c00e5d8f5..0e9a375da3 100644 --- a/basis/io/files/links/links-docs.factor +++ b/basis/io/files/links/links-docs.factor @@ -1,3 +1,4 @@ +USING: help.markup help.syntax io.files.info ; IN: io.files.links HELP: make-link diff --git a/basis/io/files/types/types-docs.factor b/basis/io/files/types/types-docs.factor new file mode 100644 index 0000000000..48df9b2328 --- /dev/null +++ b/basis/io/files/types/types-docs.factor @@ -0,0 +1,40 @@ +USING: help.markup help.syntax ; +IN: io.files.types + +HELP: +regular-file+ +{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ; + +HELP: +directory+ +{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ; + +HELP: +symbolic-link+ +{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ; + +HELP: +character-device+ +{ $description "A Unix character device file. This type exists on Unix platforms only." } ; + +HELP: +block-device+ +{ $description "A Unix block device file. This type exists on Unix platforms only." } ; + +HELP: +fifo+ +{ $description "A Unix fifo file. This type exists on Unix platforms only." } ; + +HELP: +socket+ +{ $description "A Unix socket file. This type exists on Unix platforms only." } ; + +HELP: +unknown+ +{ $description "A unknown file type." } ; + +ARTICLE: "file-types" "File types" +"Platform-independent types:" +{ $subsection +regular-file+ } +{ $subsection +directory+ } +"Platform-specific types:" +{ $subsection +character-device+ } +{ $subsection +block-device+ } +{ $subsection +fifo+ } +{ $subsection +symbolic-link+ } +{ $subsection +socket+ } +{ $subsection +unknown+ } ; + +ABOUT: "file-types" diff --git a/basis/io/files/types/types.factor b/basis/io/files/types/types.factor new file mode 100644 index 0000000000..bf8be9ec9b --- /dev/null +++ b/basis/io/files/types/types.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +IN: io.files.types + +SYMBOL: +regular-file+ +SYMBOL: +directory+ +SYMBOL: +symbolic-link+ +SYMBOL: +character-device+ +SYMBOL: +block-device+ +SYMBOL: +fifo+ +SYMBOL: +socket+ +SYMBOL: +whiteout+ +SYMBOL: +unknown+ diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index ee8615ac5a..636e44062e 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -4,9 +4,11 @@ USING: namespaces make continuations.private kernel.private init assocs kernel vocabs words sequences memory io system arrays continuations math definitions mirrors splitting parser classes summary layouts vocabs.loader prettyprint.config prettyprint -debugger io.streams.c io.files io.backend quotations io.launcher -words.private tools.deploy.config tools.deploy.config.editor -bootstrap.image io.encodings.utf8 destructors accessors ; +debugger io.streams.c io.files io.files.temp io.pathnames +io.directories io.directories.hierarchy io.backend quotations +io.launcher words.private tools.deploy.config +tools.deploy.config.editor bootstrap.image io.encodings.utf8 +destructors accessors ; IN: tools.deploy.backend : copy-vm ( executable bundle-name extension -- vm ) diff --git a/basis/tools/deploy/config/editor/editor.factor b/basis/tools/deploy/config/editor/editor.factor index 2b5788adfc..ac89e3290b 100644 --- a/basis/tools/deploy/config/editor/editor.factor +++ b/basis/tools/deploy/config/editor/editor.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs io.files kernel parser prettyprint sequences +USING: assocs io.pathnames kernel parser prettyprint sequences splitting tools.deploy.config tools.vocabs vocabs.loader ; IN: tools.deploy.config.editor diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 94cab2bb9d..10e1566290 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files kernel namespaces make sequences system -tools.deploy.backend tools.deploy.config +USING: io io.files io.files.info.unix io.pathnames +io.directories io.directories.hierarchy kernel namespaces make +sequences system tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint io.backend.unix cocoa io.encodings.utf8 io.backend cocoa.application cocoa.classes cocoa.plists qualified @@ -53,7 +54,8 @@ IN: tools.deploy.macosx } cleave ] [ create-app-plist ] - [ "Contents/MacOS/" append-path "" copy-vm ] 2tri ; + [ "Contents/MacOS/" append-path "" copy-vm ] 2tri + dup OCT: 755 set-file-permissions ; : deploy.app-image ( vocab bundle-name -- str ) [ % "/Contents/Resources/" % % ".image" % ] "" make ; diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index bd49155e84..faafa1e932 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -1,13 +1,15 @@ ! Copyright (C) 2008 James Cash ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files io.backend kernel namespaces make sequences -system tools.deploy.backend tools.deploy.config -tools.deploy.config.editor assocs hashtables prettyprint ; +USING: io io.files io.files.info.unix io.backend kernel +namespaces make sequences system tools.deploy.backend +tools.deploy.config tools.deploy.config.editor assocs hashtables +prettyprint ; IN: tools.deploy.unix : create-app-dir ( vocab bundle-name -- vm ) dup "" copy-fonts - "" copy-vm ; + "" copy-vm + dup OCT: 755 set-file-permissions ; : bundle-name ( -- str ) deploy-name get ; diff --git a/basis/tools/vocabs/browser/browser.factor b/basis/tools/vocabs/browser/browser.factor index e9e8d27870..e4db72a2fe 100644 --- a/basis/tools/vocabs/browser/browser.factor +++ b/basis/tools/vocabs/browser/browser.factor @@ -3,8 +3,8 @@ USING: accessors arrays assocs classes classes.builtin classes.intersection classes.mixin classes.predicate classes.singleton classes.tuple classes.union combinators -definitions effects fry generic help help.markup -help.stylesheet help.topics io io.files io.styles kernel macros +definitions effects fry generic help help.markup help.stylesheet +help.topics io io.files io.pathnames io.styles kernel macros make namespaces prettyprint sequences sets sorting summary tools.vocabs vocabs vocabs.loader words ; IN: tools.vocabs.browser diff --git a/basis/tools/vocabs/monitor/monitor.factor b/basis/tools/vocabs/monitor/monitor.factor index 416eec91d2..ac0160e58f 100644 --- a/basis/tools/vocabs/monitor/monitor.factor +++ b/basis/tools/vocabs/monitor/monitor.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: threads io.files io.monitors init kernel +USING: threads io.files io.pathnames io.monitors init kernel vocabs vocabs.loader tools.vocabs namespaces continuations sequences splitting assocs command-line concurrency.messaging io.backend sets tr ; diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index e3c3d46904..2297382a96 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -3,8 +3,8 @@ USING: continuations definitions ui.tools.browser ui.tools.interactor ui.tools.listener ui.tools.profiler ui.tools.search ui.tools.traceback ui.tools.workspace generic -help.topics stack-checker summary inspector io.files io.styles -kernel namespaces parser prettyprint quotations +help.topics stack-checker summary inspector io.pathnames +io.styles kernel namespaces parser prettyprint quotations tools.annotations editors tools.profiler tools.test tools.time tools.walker ui.commands ui.gadgets.editors ui.gestures ui.operations ui.tools.deploy vocabs vocabs.loader words diff --git a/basis/ui/tools/search/search.factor b/basis/ui/tools/search/search.factor index cf980cfc23..9d248e29bd 100644 --- a/basis/ui/tools/search/search.factor +++ b/basis/ui/tools/search/search.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs help help.topics io.files io.styles +USING: accessors assocs help help.topics io.pathnames io.styles kernel models models.delay models.filter namespaces prettyprint quotations sequences sorting source-files definitions strings tools.completion tools.crossref classes.tuple vocabs words diff --git a/basis/urls/urls-docs.factor b/basis/urls/urls-docs.factor index ce8a7be88c..f6c25980ea 100644 --- a/basis/urls/urls-docs.factor +++ b/basis/urls/urls-docs.factor @@ -1,6 +1,6 @@ USING: assocs hashtables help.markup help.syntax -io.streams.string io.files kernel strings present math multiline -; +io.streams.string io.files io.pathnames kernel strings present +math multiline ; IN: urls HELP: url diff --git a/core/source-files/source-files-docs.factor b/core/source-files/source-files-docs.factor index 89ffbfd795..2c9e2172cc 100644 --- a/core/source-files/source-files-docs.factor +++ b/core/source-files/source-files-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax vocabs.loader io.files strings +USING: help.markup help.syntax vocabs.loader io.pathnames strings definitions quotations compiler.units ; IN: source-files From e0f86889c7427637ba84fc705c8eed8769751aa7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 01:13:35 -0600 Subject: [PATCH 09/19] Fixing load-everything for io.files split --- basis/ftp/client/client.factor | 6 +----- .../client/listing-parser/listing-parser.factor | 2 +- basis/ftp/server/server.factor | 13 +++++++------ basis/help/handbook/handbook.factor | 5 +++++ basis/help/html/html.factor | 2 +- basis/html/templates/chloe/chloe.factor | 6 +++--- basis/http/server/static/static.factor | 15 ++++++--------- basis/io/directories/search/search.factor | 5 ++--- basis/io/files/unique/unique-docs.factor | 2 +- basis/io/files/unique/unique.factor | 2 +- basis/io/monitors/recursive/recursive.factor | 4 ++-- basis/mime/types/types.factor | 4 ++-- basis/tools/files/files.factor | 6 +++--- basis/tools/files/unix/unix.factor | 6 +++--- basis/tools/scaffold/scaffold.factor | 11 ++++++----- basis/xmode/code2html/responder/responder.factor | 6 +++--- core/io/pathnames/pathnames-docs.factor | 2 +- extra/benchmark/mandel/mandel.factor | 5 +++-- extra/benchmark/random/random.factor | 3 ++- extra/benchmark/raytracer/raytracer.factor | 5 +++-- .../reverse-complement/reverse-complement.factor | 8 +++++--- extra/benchmark/xml/xml.factor | 3 ++- extra/bunny/model/model.factor | 4 ++-- extra/contributors/contributors.factor | 6 +++--- extra/fuel/fuel.factor | 10 +++++----- extra/geo-ip/geo-ip.factor | 9 +++++---- extra/irc/ui/load/load.factor | 2 +- extra/log-viewer/log-viewer.factor | 2 +- extra/mason/build/build.factor | 8 ++++---- extra/mason/child/child.factor | 8 ++++---- extra/mason/cleanup/cleanup.factor | 5 +++-- extra/mason/common/common.factor | 7 ++++--- extra/mason/config/config.factor | 3 ++- extra/mason/help/help.factor | 4 ++-- extra/mason/mason.factor | 6 +++--- extra/mason/release/archive/archive.factor | 7 ++++--- extra/mason/release/branch/branch.factor | 5 +++-- extra/mason/release/tidy/tidy.factor | 6 +++--- extra/mason/test/test.factor | 9 +++++---- extra/project-euler/project-euler.factor | 2 +- extra/shell/shell.factor | 10 ++++------ extra/system-info/macosx/macosx.factor | 2 +- extra/tar/tar.factor | 7 ++++--- extra/update/backup/backup.factor | 5 ++--- extra/update/latest/latest.factor | 6 ++---- extra/update/update.factor | 9 ++------- extra/vpri-talk/vpri-talk.factor | 16 ++++++++-------- extra/webapps/help/help.factor | 3 ++- extra/webapps/wiki/wiki.factor | 2 +- .../websites/concatenative/concatenative.factor | 4 ++-- 50 files changed, 146 insertions(+), 142 deletions(-) diff --git a/basis/ftp/client/client.factor b/basis/ftp/client/client.factor index 9c82cdbb50..ac21bb8f78 100644 --- a/basis/ftp/client/client.factor +++ b/basis/ftp/client/client.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays classes.singleton combinators continuations io io.encodings.binary io.encodings.utf8 -io.files io.sockets kernel io.streams.duplex math +io.files io.pathnames io.sockets kernel io.streams.duplex math math.parser sequences splitting namespaces strings fry ftp ftp.client.listing-parser urls ; IN: ftp.client @@ -104,7 +104,3 @@ ERROR: ftp-error got expected ; [ nip parent-directory ftp-cwd drop ] [ file-name (ftp-get) ] 2bi ] with-ftp-client ; - - - - diff --git a/basis/ftp/client/listing-parser/listing-parser.factor b/basis/ftp/client/listing-parser/listing-parser.factor index 04e96ed77a..6183165b3a 100644 --- a/basis/ftp/client/listing-parser/listing-parser.factor +++ b/basis/ftp/client/listing-parser/listing-parser.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators io.files kernel math.parser +USING: accessors combinators io.files.types kernel math.parser sequences splitting ; IN: ftp.client.listing-parser diff --git a/basis/ftp/server/server.factor b/basis/ftp/server/server.factor index ca27cbb784..d71179d599 100644 --- a/basis/ftp/server/server.factor +++ b/basis/ftp/server/server.factor @@ -2,12 +2,13 @@ ! See http://factorcode.org/license.txt for BSD license. USING: combinators.short-circuit accessors combinators io io.encodings.8-bit io.encodings io.encodings.binary -io.encodings.utf8 io.files io.sockets kernel math.parser -namespaces make sequences ftp io.launcher.unix.parser -unicode.case splitting assocs classes io.servers.connection -destructors calendar io.timeouts io.streams.duplex threads -continuations math concurrency.promises byte-arrays -io.backend tools.hexdump tools.files io.streams.string ; +io.encodings.utf8 io.files io.files.info io.directories +io.pathnames io.sockets kernel math.parser namespaces make +sequences ftp io.launcher.unix.parser unicode.case splitting +assocs classes io.servers.connection destructors calendar +io.timeouts io.streams.duplex threads continuations math +concurrency.promises byte-arrays io.backend tools.hexdump +tools.files io.streams.string ; IN: ftp.server TUPLE: ftp-client url mode state command-promise user password ; diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index cc36e9faab..69c2046834 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -168,6 +168,11 @@ ARTICLE: "io" "Input and output" { $heading "Streams" } { $subsection "streams" } { $subsection "io.files" } +{ $heading "The file system" } +{ $subsection "io.pathnames" } +{ $subsection "io.files.info" } +{ $subsection "io.files.links" } +{ $subsection "io.directories" } { $heading "Encodings" } { $subsection "encodings-introduction" } { $subsection "io.encodings" } diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor index a9df0bea81..ec52264643 100644 --- a/basis/help/html/html.factor +++ b/basis/help/html/html.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary -io.files html.streams html.elements help kernel +io.files io.files.temp io.directories html.streams html.elements help kernel assocs sequences make words accessors arrays help.topics vocabs tools.vocabs tools.vocabs.browser namespaces prettyprint io vocabs.loader serialize fry memoize unicode.case math.order diff --git a/basis/html/templates/chloe/chloe.factor b/basis/html/templates/chloe/chloe.factor index 73cc239a56..c3c1ec2b9e 100644 --- a/basis/html/templates/chloe/chloe.factor +++ b/basis/html/templates/chloe/chloe.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel sequences combinators kernel fry namespaces make classes.tuple assocs splitting words arrays io -io.files io.encodings.utf8 io.streams.string unicode.case -mirrors math urls present multiline quotations xml logging -continuations +io.files io.files.info io.encodings.utf8 io.streams.string +unicode.case mirrors math urls present multiline quotations xml +logging continuations xml.data html.forms html.elements diff --git a/basis/http/server/static/static.factor b/basis/http/server/static/static.factor index 0bc644d019..b19bf2ae55 100644 --- a/basis/http/server/static/static.factor +++ b/basis/http/server/static/static.factor @@ -1,14 +1,11 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: calendar io io.files kernel math math.order -math.parser namespaces parser sequences strings -assocs hashtables debugger mime.types sorting logging -calendar.format accessors splitting -io.encodings.binary fry xml.entities destructors urls -html.elements html.templates.fhtml -http -http.server -http.server.responses +USING: calendar kernel math math.order math.parser namespaces +parser sequences strings assocs hashtables debugger mime.types +sorting logging calendar.format accessors splitting io io.files +io.files.info io.directories io.pathnames io.encodings.binary +fry xml.entities destructors urls html.elements +html.templates.fhtml http http.server http.server.responses http.server.redirection ; IN: http.server.static diff --git a/basis/io/directories/search/search.factor b/basis/io/directories/search/search.factor index 10365e9785..17f8552c2b 100755 --- a/basis/io/directories/search/search.factor +++ b/basis/io/directories/search/search.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays continuations deques dlists fry -io.directories io.directories.search.private io.files -io.files.info io.pathnames kernel sequences system -vocabs.loader ; +io.directories io.files io.files.info io.pathnames kernel +sequences system vocabs.loader ; IN: io.directories.search TUPLE: directory-iterator path bfs queue ; diff --git a/basis/io/files/unique/unique-docs.factor b/basis/io/files/unique/unique-docs.factor index bfde09dc48..681cd94a38 100644 --- a/basis/io/files/unique/unique-docs.factor +++ b/basis/io/files/unique/unique-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io io.ports kernel math -io.files.unique.private math.parser io.files ; +io.pathnames io.directories math.parser io.files ; IN: io.files.unique HELP: temporary-path diff --git a/basis/io/files/unique/unique.factor b/basis/io/files/unique/unique.factor index 79afefa05d..02f4d6080c 100644 --- a/basis/io/files/unique/unique.factor +++ b/basis/io/files/unique/unique.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: arrays combinators continuations fry io io.backend -io.directories io.files io.files.unique.private io.pathnames +io.directories io.directories.hierarchy io.files io.pathnames kernel math math.bitwise math.parser namespaces random sequences system vocabs.loader ; IN: io.files.unique diff --git a/basis/io/monitors/recursive/recursive.factor b/basis/io/monitors/recursive/recursive.factor index a96c6f04f1..18fa62f6d6 100644 --- a/basis/io/monitors/recursive/recursive.factor +++ b/basis/io/monitors/recursive/recursive.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors sequences assocs arrays continuations destructors combinators kernel threads concurrency.messaging -concurrency.mailboxes concurrency.promises io.files io.monitors -debugger fry ; +concurrency.mailboxes concurrency.promises io.files io.files.info +io.directories io.pathnames io.monitors debugger fry ; IN: io.monitors.recursive ! Simulate recursive monitors on platforms that don't have them diff --git a/basis/mime/types/types.factor b/basis/mime/types/types.factor index bb0d674f23..ac5233c543 100644 --- a/basis/mime/types/types.factor +++ b/basis/mime/types/types.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files io.encodings.ascii assocs sequences splitting -kernel namespaces fry memoize ; +USING: io.pathnames io.files io.encodings.ascii assocs sequences +splitting kernel namespaces fry memoize ; IN: mime.types MEMO: mime-db ( -- seq ) diff --git a/basis/tools/files/files.factor b/basis/tools/files/files.factor index 7968639d47..54882800b0 100755 --- a/basis/tools/files/files.factor +++ b/basis/tools/files/files.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays combinators io io.files kernel -math.parser sequences system vocabs.loader calendar math -symbols fry prettyprint ; +USING: accessors arrays combinators io io.files io.files.info +io.directories kernel math.parser sequences system vocabs.loader +calendar math symbols fry prettyprint ; IN: tools.files ( root -- responder ) diff --git a/core/io/pathnames/pathnames-docs.factor b/core/io/pathnames/pathnames-docs.factor index 21fd5b4b36..3ba864d471 100644 --- a/core/io/pathnames/pathnames-docs.factor +++ b/core/io/pathnames/pathnames-docs.factor @@ -65,7 +65,7 @@ HELP: home { $values { "dir" string } } { $description "Outputs the user's home directory." } ; -ARTICLE: "pathnames" "Pathname manipulation" +ARTICLE: "io.pathnames" "Pathname manipulation" "Pathname manipulation:" { $subsection parent-directory } { $subsection file-name } diff --git a/extra/benchmark/mandel/mandel.factor b/extra/benchmark/mandel/mandel.factor index 64a673c8ec..c501c35c6a 100755 --- a/extra/benchmark/mandel/mandel.factor +++ b/extra/benchmark/mandel/mandel.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io kernel math math.functions sequences prettyprint -io.files io.encodings io.encodings.ascii io.encodings.binary fry -benchmark.mandel.params benchmark.mandel.colors ; +io.files io.files.temp io.encodings io.encodings.ascii +io.encodings.binary fry benchmark.mandel.params +benchmark.mandel.colors ; IN: benchmark.mandel : x-inc width 200000 zoom-fact * / ; inline diff --git a/extra/benchmark/random/random.factor b/extra/benchmark/random/random.factor index 985c9a59b2..d2eb4cdab5 100755 --- a/extra/benchmark/random/random.factor +++ b/extra/benchmark/random/random.factor @@ -1,4 +1,5 @@ -USING: io.files io.encodings.ascii random math.parser io math ; +USING: io io.files io.files.temp io.encodings.ascii random +math.parser math ; IN: benchmark.random : random-numbers-path ( -- path ) diff --git a/extra/benchmark/raytracer/raytracer.factor b/extra/benchmark/raytracer/raytracer.factor index 7fe46e9c36..c16e47846e 100755 --- a/extra/benchmark/raytracer/raytracer.factor +++ b/extra/benchmark/raytracer/raytracer.factor @@ -2,8 +2,9 @@ ! http://www.ffconsultancy.com/free/ray_tracer/languages.html USING: arrays accessors specialized-arrays.double io io.files -io.encodings.binary kernel math math.functions math.vectors -math.parser make sequences sequences.private words hints ; +io.files.temp io.encodings.binary kernel math math.functions +math.vectors math.parser make sequences sequences.private words +hints ; IN: benchmark.raytracer ! parameters diff --git a/extra/benchmark/reverse-complement/reverse-complement.factor b/extra/benchmark/reverse-complement/reverse-complement.factor index 665cbba30d..3298706da3 100755 --- a/extra/benchmark/reverse-complement/reverse-complement.factor +++ b/extra/benchmark/reverse-complement/reverse-complement.factor @@ -1,6 +1,8 @@ -USING: io io.files io.streams.duplex kernel sequences -sequences.private strings vectors words memoize splitting -grouping hints tr continuations io.encodings.ascii +! Copyright (C) 2006, 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io io.files io.files.temp io.streams.duplex kernel +sequences sequences.private strings vectors words memoize +splitting grouping hints tr continuations io.encodings.ascii unicode.case ; IN: benchmark.reverse-complement diff --git a/extra/benchmark/xml/xml.factor b/extra/benchmark/xml/xml.factor index a61293cd99..a32a98a133 100644 --- a/extra/benchmark/xml/xml.factor +++ b/extra/benchmark/xml/xml.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.encodings.utf8 io.files kernel sequences xml ; +USING: io.encodings.utf8 io.directories io.files kernel +sequences xml ; IN: benchmark.xml : xml-benchmark ( -- ) diff --git a/extra/bunny/model/model.factor b/extra/bunny/model/model.factor index 9dddd0d8cd..3e00191108 100755 --- a/extra/bunny/model/model.factor +++ b/extra/bunny/model/model.factor @@ -1,6 +1,6 @@ USING: accessors alien.c-types arrays combinators destructors -http.client io io.encodings.ascii io.files kernel math -math.matrices math.parser math.vectors opengl +http.client io io.encodings.ascii io.files io.files.temp kernel +math math.matrices math.parser math.vectors opengl opengl.capabilities opengl.gl opengl.demo-support sequences splitting vectors words specialized-arrays.float specialized-arrays.uint ; diff --git a/extra/contributors/contributors.factor b/extra/contributors/contributors.factor index 4d6479db91..1879c52826 100755 --- a/extra/contributors/contributors.factor +++ b/extra/contributors/contributors.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files io.launcher io.styles io.encodings.ascii -prettyprint io hashtables kernel sequences assocs system sorting -math.parser sets ; +USING: io.files io.launcher io.directories io.pathnames +io.encodings.ascii io prettyprint hashtables kernel sequences +assocs system sorting math.parser sets ; IN: contributors : changelog ( -- authors ) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index eee33a13c8..2de80de4a4 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -2,11 +2,11 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays classes classes.tuple compiler.units -combinators continuations debugger definitions eval help -io io.files io.streams.string kernel lexer listener listener.private -make math namespaces parser prettyprint prettyprint.config -quotations sequences strings source-files tools.vocabs -vectors vocabs vocabs.loader ; +combinators continuations debugger definitions eval help io +io.files io.pathnames io.streams.string kernel lexer listener +listener.private make math namespaces parser prettyprint +prettyprint.config quotations sequences strings source-files +tools.vocabs vectors vocabs vocabs.loader ; IN: fuel diff --git a/extra/geo-ip/geo-ip.factor b/extra/geo-ip/geo-ip.factor index aee53f24f5..c878306d7d 100644 --- a/extra/geo-ip/geo-ip.factor +++ b/extra/geo-ip/geo-ip.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences io.files io.launcher io.encodings.ascii -io.streams.string http.client generalizations combinators -math.parser math.vectors math.intervals interval-maps memoize -csv accessors assocs strings math splitting grouping arrays ; +USING: kernel sequences io.files io.files.temp io.launcher +io.pathnames io.encodings.ascii io.streams.string http.client +generalizations combinators math.parser math.vectors +math.intervals interval-maps memoize csv accessors assocs +strings math splitting grouping arrays ; IN: geo-ip : db-path ( -- path ) "IpToCountry.csv" temp-file ; diff --git a/extra/irc/ui/load/load.factor b/extra/irc/ui/load/load.factor index e6f4d07b56..6048d93711 100755 --- a/extra/irc/ui/load/load.factor +++ b/extra/irc/ui/load/load.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 William Schlieper ! See http://factorcode.org/license.txt for BSD license. -USING: kernel io.files parser editors sequences ; +USING: kernel io.files io.pathnames parser editors sequences ; IN: irc.ui.load diff --git a/extra/log-viewer/log-viewer.factor b/extra/log-viewer/log-viewer.factor index 7bc63d3e34..263454f769 100755 --- a/extra/log-viewer/log-viewer.factor +++ b/extra/log-viewer/log-viewer.factor @@ -1,4 +1,4 @@ -USING: kernel io io.files io.monitors io.encodings.utf8 ; +USING: kernel io io.files io.pathnames io.monitors io.encodings.utf8 ; IN: log-viewer : read-lines ( stream -- ) diff --git a/extra/mason/build/build.factor b/extra/mason/build/build.factor index 35070d8902..4d705610b4 100644 --- a/extra/mason/build/build.factor +++ b/extra/mason/build/build.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files io.launcher io.encodings.utf8 prettyprint arrays -calendar namespaces mason.common mason.child -mason.release mason.report mason.email mason.cleanup -mason.help ; +USING: arrays calendar io.directories io.encodings.utf8 +io.files io.launcher mason.child mason.cleanup mason.common +mason.email mason.help mason.release mason.report namespaces +prettyprint ; IN: mason.build : create-build-dir ( -- ) diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 0c9669ed5a..5a3a0d6ceb 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces make debugger sequences io.files -io.launcher arrays accessors calendar continuations -combinators.short-circuit mason.common mason.report -mason.platform mason.config http.client ; +USING: accessors arrays calendar combinators.short-circuit +continuations debugger http.client io.directories io.files +io.launcher io.pathnames kernel make mason.common mason.config +mason.platform mason.report namespaces sequences ; IN: mason.child : make-cmd ( -- args ) diff --git a/extra/mason/cleanup/cleanup.factor b/extra/mason/cleanup/cleanup.factor index ae24f533d6..a2c087392a 100644 --- a/extra/mason/cleanup/cleanup.factor +++ b/extra/mason/cleanup/cleanup.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces arrays continuations io.files io.launcher -mason.common mason.platform mason.config ; +USING: arrays continuations io.directories +io.directories.hierarchy io.files io.launcher kernel +mason.common mason.config mason.platform namespaces ; IN: mason.cleanup : compress-image ( -- ) diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor index 49f280fa84..ec0cbdbc9c 100644 --- a/extra/mason/common/common.factor +++ b/extra/mason/common/common.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces sequences splitting system accessors -math.functions make io io.files io.launcher io.encodings.utf8 -prettyprint combinators.short-circuit parser combinators -calendar calendar.format arrays mason.config locals ; +math.functions make io io.files io.pathnames io.directories +io.launcher io.encodings.utf8 prettyprint +combinators.short-circuit parser combinators calendar +calendar.format arrays mason.config locals ; IN: mason.common : short-running-process ( command -- ) diff --git a/extra/mason/config/config.factor b/extra/mason/config/config.factor index 9169fbf196..b1739d85fa 100644 --- a/extra/mason/config/config.factor +++ b/extra/mason/config/config.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: system io.files namespaces kernel accessors assocs ; +USING: system io.files io.pathnames namespaces kernel accessors +assocs ; IN: mason.config ! (Optional) Location for build directories diff --git a/extra/mason/help/help.factor b/extra/mason/help/help.factor index c9ca50f0c2..9a4e2be996 100644 --- a/extra/mason/help/help.factor +++ b/extra/mason/help/help.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: help.html sequences io.files io.launcher make namespaces -kernel arrays mason.common mason.config ; +USING: arrays help.html io.directories io.files io.launcher +kernel make mason.common mason.config namespaces sequences ; IN: mason.help : make-help-archive ( -- ) diff --git a/extra/mason/mason.factor b/extra/mason/mason.factor index 4f9c8f65d3..299a2f4e1f 100644 --- a/extra/mason/mason.factor +++ b/extra/mason/mason.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel debugger io io.files threads debugger continuations -namespaces accessors calendar mason.common mason.updates -mason.build mason.email ; +USING: accessors calendar continuations debugger debugger io +io.directories io.files kernel mason.build mason.common +mason.email mason.updates namespaces threads ; IN: mason : build-loop-error ( error -- ) diff --git a/extra/mason/release/archive/archive.factor b/extra/mason/release/archive/archive.factor index e76979d885..5ef424ad4f 100644 --- a/extra/mason/release/archive/archive.factor +++ b/extra/mason/release/archive/archive.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel combinators sequences make namespaces io.files -io.launcher prettyprint arrays -mason.common mason.platform mason.config ; +USING: arrays combinators io.directories +io.directories.hierarchy io.files io.launcher io.pathnames +kernel make mason.common mason.config mason.platform namespaces +prettyprint sequences ; IN: mason.release.archive : base-name ( -- string ) diff --git a/extra/mason/release/branch/branch.factor b/extra/mason/release/branch/branch.factor index 600b08c6b6..75ce828c28 100644 --- a/extra/mason/release/branch/branch.factor +++ b/extra/mason/release/branch/branch.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces sequences prettyprint io.files -io.launcher make mason.common mason.platform mason.config ; +USING: io.directories io.files io.launcher kernel make +mason.common mason.config mason.platform namespaces prettyprint +sequences ; IN: mason.release.branch : branch-name ( -- string ) "clean-" platform append ; diff --git a/extra/mason/release/tidy/tidy.factor b/extra/mason/release/tidy/tidy.factor index fb931650d4..58046ce64c 100644 --- a/extra/mason/release/tidy/tidy.factor +++ b/extra/mason/release/tidy/tidy.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces continuations debugger sequences fry -io.files io.launcher bootstrap.image qualified mason.common -mason.config ; +USING: bootstrap.image continuations debugger fry +io.directories io.directories.hierarchy io.files io.launcher +kernel mason.common namespaces qualified sequences ; FROM: mason.config => target-os ; IN: mason.release.tidy diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index b23ad19e5e..a15a96c63e 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces assocs io.files io.encodings.utf8 -prettyprint help.lint benchmark tools.time bootstrap.stage2 -tools.test tools.vocabs help.html mason.common words generic -accessors compiler.errors sequences sets sorting math ; +USING: accessors assocs benchmark bootstrap.stage2 +compiler.errors generic help.html help.lint io.directories +io.encodings.utf8 io.files kernel mason.common math namespaces +prettyprint sequences sets sorting tools.test tools.time +tools.vocabs words ; IN: mason.test : do-load ( -- ) diff --git a/extra/project-euler/project-euler.factor b/extra/project-euler/project-euler.factor index 027e8fe50f..f9fa0f4f18 100644 --- a/extra/project-euler/project-euler.factor +++ b/extra/project-euler/project-euler.factor @@ -1,6 +1,6 @@ ! Copyright (c) 2007, 2008 Aaron Schaefer, Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: definitions io io.files kernel math math.parser +USING: definitions io io.files io.pathnames kernel math math.parser prettyprint project-euler.ave-time sequences vocabs vocabs.loader project-euler.001 project-euler.002 project-euler.003 project-euler.004 project-euler.005 project-euler.006 project-euler.007 project-euler.008 diff --git a/extra/shell/shell.factor b/extra/shell/shell.factor index ae9b94ba0e..d6c98ea203 100644 --- a/extra/shell/shell.factor +++ b/extra/shell/shell.factor @@ -1,10 +1,8 @@ - USING: kernel parser words continuations namespaces debugger - sequences combinators splitting prettyprint - system io io.files io.launcher io.encodings.utf8 io.pipes sequences.deep - accessors multi-methods newfx shell.parser - combinators.short-circuit eval environment ; - +sequences combinators splitting prettyprint system io io.files +io.pathnames io.launcher io.directories io.encodings.utf8 io.pipes +sequences.deep accessors multi-methods newfx shell.parser +combinators.short-circuit eval environment ; IN: shell ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/system-info/macosx/macosx.factor b/extra/system-info/macosx/macosx.factor index a06c01b950..b51fd52995 100644 --- a/extra/system-info/macosx/macosx.factor +++ b/extra/system-info/macosx/macosx.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.strings alien.syntax byte-arrays kernel namespaces sequences unix -system-info.backend system io.unix.backend io.encodings.utf8 ; +system-info.backend system io.encodings.utf8 ; IN: system-info.macosx ! See /usr/include/sys/sysctl.h for constants diff --git a/extra/tar/tar.factor b/extra/tar/tar.factor index e3c14854d3..132e401f16 100755 --- a/extra/tar/tar.factor +++ b/extra/tar/tar.factor @@ -1,6 +1,7 @@ -USING: combinators io io.files io.streams.string kernel math -math.parser continuations namespaces pack prettyprint sequences -strings system tools.hexdump io.encodings.binary summary accessors +USING: combinators io io.files io.files.links io.directories +io.pathnames io.streams.string kernel math math.parser +continuations namespaces pack prettyprint sequences strings +system tools.hexdump io.encodings.binary summary accessors io.backend symbols byte-arrays ; IN: tar diff --git a/extra/update/backup/backup.factor b/extra/update/backup/backup.factor index 0c7b442ffa..7728003189 100644 --- a/extra/update/backup/backup.factor +++ b/extra/update/backup/backup.factor @@ -1,6 +1,5 @@ - -USING: namespaces debugger io.files bootstrap.image update.util ; - +USING: namespaces debugger io.files io.directories +bootstrap.image update.util ; IN: update.backup : backup-boot-image ( -- ) diff --git a/extra/update/latest/latest.factor b/extra/update/latest/latest.factor index 9546379223..98d264d227 100644 --- a/extra/update/latest/latest.factor +++ b/extra/update/latest/latest.factor @@ -1,7 +1,5 @@ - -USING: kernel namespaces system io.files bootstrap.image http.client - update update.backup update.util ; - +USING: kernel namespaces system io.files io.pathnames io.directories +bootstrap.image http.client update update.backup update.util ; IN: update.latest ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/update/update.factor b/extra/update/update.factor index c6a5671345..ba09cc3f3d 100644 --- a/extra/update/update.factor +++ b/extra/update/update.factor @@ -1,10 +1,5 @@ - -USING: kernel system sequences io.files io.launcher bootstrap.image - http.client - update.util ; - - ! builder.util builder.release.branch ; - +USING: kernel system sequences io.files io.directories +io.pathnames io.launcher bootstrap.image http.client update.util ; IN: update ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/vpri-talk/vpri-talk.factor b/extra/vpri-talk/vpri-talk.factor index 131b569a92..35d8bb52ff 100644 --- a/extra/vpri-talk/vpri-talk.factor +++ b/extra/vpri-talk/vpri-talk.factor @@ -80,19 +80,19 @@ IN: vpri-talk { $slide "Object system" "New operation, existing types:" { $code - "GENERIC: perimiter ( shape -- n )" + "GENERIC: perimeter ( shape -- n )" "" - "M: rectangle perimiter" + "M: rectangle perimeter" " [ width>> ] [ height>> ] bi + 2 * ;" "" - "M: circle perimiter" + "M: circle perimeter" " radius>> 2 * pi * ;" } } { $slide "Object system" "We can compute perimiters now." - { $code "100 20 perimiter ." } - { $code "3 perimiter ." } + { $code "100 20 perimeter ." } + { $code "3 perimeter ." } } { $slide "Object system" "New type, extending existing operations:" @@ -110,7 +110,7 @@ IN: vpri-talk { $code ": hypotenuse ( x y -- z ) [ sq ] bi@ + sqrt ;" "" - "M: triangle perimiter" + "M: triangle perimeter" " [ base>> ] [ height>> ] bi" " [ + ] [ hypotenuse ] 2bi + ;" } @@ -151,10 +151,10 @@ IN: vpri-talk "Libraries can define new parsing words" } { $slide "Example: float arrays" - { $vocab-link "float-arrays" } + { $vocab-link "specialized-arrays.float" } "Avoids boxing and unboxing overhead" "Implemented with library code" - { $code "F{ 3.14 7.6 10.3 }" } + { $code "float-array{ 3.14 7.6 10.3 }" } } { $slide "Example: memoization" { "Memoization with " { $link POSTPONE: MEMO: } } diff --git a/extra/webapps/help/help.factor b/extra/webapps/help/help.factor index 96401b6afd..1c17e3214f 100644 --- a/extra/webapps/help/help.factor +++ b/extra/webapps/help/help.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors http.server.dispatchers http.server.static furnace.actions furnace.redirection urls -validators locals io.files html.forms html.components help.html ; +validators locals io.files io.directories html.forms +html.components help.html ; IN: webapps.help TUPLE: help-webapp < dispatcher ; diff --git a/extra/webapps/wiki/wiki.factor b/extra/webapps/wiki/wiki.factor index f2c0600ed5..07fbbe0596 100644 --- a/extra/webapps/wiki/wiki.factor +++ b/extra/webapps/wiki/wiki.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel hashtables calendar random assocs namespaces make splitting sequences sorting math.order present -io.files io.encodings.ascii +io.files io.directories io.encodings.ascii syndication farkup html.components html.forms http.server diff --git a/extra/websites/concatenative/concatenative.factor b/extra/websites/concatenative/concatenative.factor index d7fdfa2460..302967969f 100644 --- a/extra/websites/concatenative/concatenative.factor +++ b/extra/websites/concatenative/concatenative.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel sequences assocs io.files io.sockets -io.sockets.secure io.servers.connection +USING: accessors kernel sequences assocs io.files io.pathnames +io.sockets io.sockets.secure io.servers.connection namespaces db db.tuples db.sqlite smtp urls logging.insomniac html.templates.chloe From e15c3cc901d69ff7e29c6861b1fe8ebd30531b12 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 01:32:21 -0600 Subject: [PATCH 10/19] Updating Windows I/O backend for recent changes --- basis/io/directories/windows/windows.factor | 56 +++ basis/io/files/info/windows/nt/nt.factor | 13 + basis/io/files/info/windows/windows.factor | 190 +++++++++ basis/io/files/windows/files.factor | 378 ------------------ .../{files-tests.factor => nt-tests.factor} | 0 .../windows/nt/{files.factor => nt.factor} | 10 - basis/io/files/windows/windows.factor | 139 +++++++ 7 files changed, 398 insertions(+), 388 deletions(-) create mode 100644 basis/io/directories/windows/windows.factor create mode 100644 basis/io/files/info/windows/nt/nt.factor create mode 100644 basis/io/files/info/windows/windows.factor delete mode 100755 basis/io/files/windows/files.factor rename basis/io/files/windows/nt/{files-tests.factor => nt-tests.factor} (100%) rename basis/io/files/windows/nt/{files.factor => nt.factor} (86%) create mode 100755 basis/io/files/windows/windows.factor diff --git a/basis/io/directories/windows/windows.factor b/basis/io/directories/windows/windows.factor new file mode 100644 index 0000000000..6520602b7e --- /dev/null +++ b/basis/io/directories/windows/windows.factor @@ -0,0 +1,56 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +IN: io.directories.windows + +M: windows move-file ( from to -- ) + [ normalize-path ] bi@ MoveFile win32-error=0/f ; + +M: windows delete-file ( path -- ) + normalize-path DeleteFile win32-error=0/f ; + +M: windows copy-file ( from to -- ) + dup parent-directory make-directories + [ normalize-path ] bi@ 0 CopyFile win32-error=0/f ; + +M: windows make-directory ( path -- ) + normalize-path + f CreateDirectory win32-error=0/f ; + +M: windows delete-directory ( path -- ) + normalize-path + RemoveDirectory win32-error=0/f ; + +: find-first-file ( path -- WIN32_FIND_DATA handle ) + "WIN32_FIND_DATA" tuck + FindFirstFile + [ INVALID_HANDLE_VALUE = [ win32-error-string throw ] when ] keep ; + +: find-next-file ( path -- WIN32_FIND_DATA/f ) + "WIN32_FIND_DATA" tuck + FindNextFile 0 = [ + GetLastError ERROR_NO_MORE_FILES = [ + win32-error + ] unless drop f + ] when ; + +TUPLE: windows-directory-entry < directory-entry attributes ; + +M: windows >directory-entry ( byte-array -- directory-entry ) + [ WIN32_FIND_DATA-cFileName utf16n alien>string ] + [ WIN32_FIND_DATA-dwFileAttributes win32-file-type ] + [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ] + tri + dupd remove windows-directory-entry boa ; + +M: windows (directory-entries) ( path -- seq ) + "\\" ?tail drop "\\*" append + find-first-file [ >directory-entry ] dip + [ + '[ + [ _ find-next-file dup ] + [ >directory-entry ] + [ drop ] produce + over name>> "." = [ nip ] [ swap prefix ] if + ] + ] [ '[ _ FindClose win32-error=0/f ] ] bi [ ] cleanup ; + diff --git a/basis/io/files/info/windows/nt/nt.factor b/basis/io/files/info/windows/nt/nt.factor new file mode 100644 index 0000000000..e1b8062016 --- /dev/null +++ b/basis/io/files/info/windows/nt/nt.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +IN: io.files.info.windows.nt + +ERROR: not-absolute-path ; + +M: winnt root-directory ( string -- string' ) + unicode-prefix ?head drop + dup { + [ length 2 >= ] + [ second CHAR: : = ] + [ first Letter? ] + } 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ; diff --git a/basis/io/files/info/windows/windows.factor b/basis/io/files/info/windows/windows.factor new file mode 100644 index 0000000000..c3068dbafa --- /dev/null +++ b/basis/io/files/info/windows/windows.factor @@ -0,0 +1,190 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +IN: io.files.info.windows + +TUPLE: windows-file-info < file-info attributes ; + +: WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info ) + [ \ windows-file-info new ] dip + { + [ WIN32_FIND_DATA-dwFileAttributes win32-file-type >>type ] + [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes >>attributes ] + [ + [ WIN32_FIND_DATA-nFileSizeLow ] + [ WIN32_FIND_DATA-nFileSizeHigh ] bi >64bit >>size + ] + [ WIN32_FIND_DATA-dwFileAttributes >>permissions ] + [ WIN32_FIND_DATA-ftCreationTime FILETIME>timestamp >>created ] + [ WIN32_FIND_DATA-ftLastWriteTime FILETIME>timestamp >>modified ] + [ WIN32_FIND_DATA-ftLastAccessTime FILETIME>timestamp >>accessed ] + } cleave ; + +: find-first-file-stat ( path -- WIN32_FIND_DATA ) + "WIN32_FIND_DATA" [ + FindFirstFile + [ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep + FindClose win32-error=0/f + ] keep ; + +: BY_HANDLE_FILE_INFORMATION>file-info ( HANDLE_FILE_INFORMATION -- file-info ) + [ \ windows-file-info new ] dip + { + [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-type >>type ] + [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-attributes >>attributes ] + [ + [ BY_HANDLE_FILE_INFORMATION-nFileSizeLow ] + [ BY_HANDLE_FILE_INFORMATION-nFileSizeHigh ] bi >64bit >>size + ] + [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>permissions ] + [ + BY_HANDLE_FILE_INFORMATION-ftCreationTime + FILETIME>timestamp >>created + ] + [ + BY_HANDLE_FILE_INFORMATION-ftLastWriteTime + FILETIME>timestamp >>modified + ] + [ + BY_HANDLE_FILE_INFORMATION-ftLastAccessTime + FILETIME>timestamp >>accessed + ] + ! [ BY_HANDLE_FILE_INFORMATION-nNumberOfLinks ] + ! [ + ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexLow ] + ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexHigh ] bi >64bit + ! ] + } cleave ; + +: get-file-information ( handle -- BY_HANDLE_FILE_INFORMATION ) + [ + "BY_HANDLE_FILE_INFORMATION" + [ GetFileInformationByHandle win32-error=0/f ] keep + ] keep CloseHandle win32-error=0/f ; + +: get-file-information-stat ( path -- BY_HANDLE_FILE_INFORMATION ) + dup + GENERIC_READ FILE_SHARE_READ f + OPEN_EXISTING FILE_FLAG_BACKUP_SEMANTICS f + CreateFileW dup INVALID_HANDLE_VALUE = [ + drop find-first-file-stat WIN32_FIND_DATA>file-info + ] [ + nip + get-file-information BY_HANDLE_FILE_INFORMATION>file-info + ] if ; + +M: winnt file-info ( path -- info ) + normalize-path get-file-information-stat ; + +M: winnt link-info ( path -- info ) + file-info ; + +: volume-information ( normalized-path -- volume-name volume-serial max-component flags type ) + MAX_PATH 1+ [ ] keep + "DWORD" + "DWORD" + "DWORD" + MAX_PATH 1+ [ ] keep + [ GetVolumeInformation win32-error=0/f ] 7 nkeep + drop 5 nrot drop + [ utf16n alien>string ] 4 ndip + utf16n alien>string ; + +: file-system-space ( normalized-path -- available-space total-space free-space ) + "ULARGE_INTEGER" + "ULARGE_INTEGER" + "ULARGE_INTEGER" + [ GetDiskFreeSpaceEx win32-error=0/f ] 3keep ; + +: calculate-file-system-info ( file-system-info -- file-system-info' ) + { + [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ] + [ ] + } cleave ; + +TUPLE: win32-file-system-info < file-system-info max-component flags device-serial ; + +HOOK: root-directory os ( string -- string' ) + +M: winnt file-system-info ( path -- file-system-info ) + normalize-path root-directory + dup [ volume-information ] [ file-system-space ] bi + \ win32-file-system-info new + swap *ulonglong >>free-space + swap *ulonglong >>total-space + swap *ulonglong >>available-space + swap >>type + swap *uint >>flags + swap *uint >>max-component + swap *uint >>device-serial + swap >>device-name + swap >>mount-point + calculate-file-system-info ; + +: volume>paths ( string -- array ) + 16384 "ushort" tuck dup length + 0 dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [ + win32-error-string throw + ] [ + *uint "ushort" heap-size * head + utf16n alien>string CHAR: \0 split + ] if ; + +: find-first-volume ( -- string handle ) + MAX_PATH 1+ [ ] keep + dupd + FindFirstVolume dup win32-error=0/f + [ utf16n alien>string ] dip ; + +: find-next-volume ( handle -- string/f ) + MAX_PATH 1+ [ tuck ] keep + FindNextVolume 0 = [ + GetLastError ERROR_NO_MORE_FILES = + [ drop f ] [ win32-error-string throw ] if + ] [ + utf16n alien>string + ] if ; + +: find-volumes ( -- array ) + find-first-volume + [ + '[ + [ _ find-next-volume dup ] + [ ] + [ drop ] produce + swap prefix + ] + ] [ '[ _ FindVolumeClose win32-error=0/f ] ] bi [ ] cleanup ; + +M: winnt file-systems ( -- array ) + find-volumes [ volume>paths ] map + concat [ + [ file-system-info ] + [ drop \ file-system-info new swap >>mount-point ] recover + ] map ; + +: file-times ( path -- timestamp timestamp timestamp ) + [ + normalize-path open-existing &dispose handle>> + "FILETIME" + "FILETIME" + "FILETIME" + [ GetFileTime win32-error=0/f ] 3keep + [ FILETIME>timestamp >local-time ] tri@ + ] with-destructors ; + +: set-file-times ( path timestamp/f timestamp/f timestamp/f -- ) + #! timestamp order: creation access write + [ + [ + normalize-path open-existing &dispose handle>> + ] 3dip (set-file-times) + ] with-destructors ; + +: set-file-create-time ( path timestamp -- ) + f f set-file-times ; + +: set-file-access-time ( path timestamp -- ) + [ f ] dip f set-file-times ; + +: set-file-write-time ( path timestamp -- ) + [ f f ] dip set-file-times ; diff --git a/basis/io/files/windows/files.factor b/basis/io/files/windows/files.factor deleted file mode 100755 index 76105c5fe6..0000000000 --- a/basis/io/files/windows/files.factor +++ /dev/null @@ -1,378 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types io.binary io.backend io.files io.buffers -io.encodings.utf16n io.ports io.backend.windows kernel math splitting -fry alien.strings windows windows.kernel32 windows.time calendar -combinators math.functions sequences namespaces make words -symbols system destructors accessors math.bitwise continuations -windows.errors arrays byte-arrays generalizations ; -IN: io.files.windows - -: open-file ( path access-mode create-mode flags -- handle ) - [ - [ share-mode default-security-attributes ] 2dip - CreateFile-flags f CreateFile opened-file - ] with-destructors ; - -: open-pipe-r/w ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags - OPEN_EXISTING 0 open-file ; - -: open-read ( path -- win32-file ) - GENERIC_READ OPEN_EXISTING 0 open-file 0 >>ptr ; - -: open-write ( path -- win32-file ) - GENERIC_WRITE CREATE_ALWAYS 0 open-file 0 >>ptr ; - -: (open-append) ( path -- win32-file ) - GENERIC_WRITE OPEN_ALWAYS 0 open-file ; - -: open-existing ( path -- win32-file ) - { GENERIC_READ GENERIC_WRITE } flags - share-mode - f - OPEN_EXISTING - FILE_FLAG_BACKUP_SEMANTICS - f CreateFileW dup win32-error=0/f ; - -: maybe-create-file ( path -- win32-file ? ) - #! return true if file was just created - { GENERIC_READ GENERIC_WRITE } flags - share-mode - f - OPEN_ALWAYS - 0 CreateFile-flags - f CreateFileW dup win32-error=0/f - GetLastError ERROR_ALREADY_EXISTS = not ; - -: set-file-pointer ( handle length method -- ) - [ dupd d>w/w ] dip SetFilePointer - INVALID_SET_FILE_POINTER = [ - CloseHandle "SetFilePointer failed" throw - ] when drop ; - -HOOK: open-append os ( path -- win32-file ) - -TUPLE: FileArgs - hFile lpBuffer nNumberOfBytesToRead - lpNumberOfBytesRet lpOverlapped ; - -C: FileArgs - -: make-FileArgs ( port -- ) - { - [ handle>> check-disposed ] - [ handle>> handle>> ] - [ buffer>> ] - [ buffer>> buffer-length ] - [ drop "DWORD" ] - [ FileArgs-overlapped ] - } cleave ; - -: setup-read ( -- hFile lpBuffer nNumberOfBytesToRead lpNumberOfBytesRead lpOverlapped ) - { - [ hFile>> ] - [ lpBuffer>> buffer-end ] - [ lpBuffer>> buffer-capacity ] - [ lpNumberOfBytesRet>> ] - [ lpOverlapped>> ] - } cleave ; - -: setup-write ( -- hFile lpBuffer nNumberOfBytesToWrite lpNumberOfBytesWritten lpOverlapped ) - { - [ hFile>> ] - [ lpBuffer>> buffer@ ] - [ lpBuffer>> buffer-length ] - [ lpNumberOfBytesRet>> ] - [ lpOverlapped>> ] - } cleave ; - -M: windows (file-reader) ( path -- stream ) - open-read ; - -M: windows (file-writer) ( path -- stream ) - open-write ; - -M: windows (file-appender) ( path -- stream ) - open-append ; - -M: windows move-file ( from to -- ) - [ normalize-path ] bi@ MoveFile win32-error=0/f ; - -M: windows delete-file ( path -- ) - normalize-path DeleteFile win32-error=0/f ; - -M: windows copy-file ( from to -- ) - dup parent-directory make-directories - [ normalize-path ] bi@ 0 CopyFile win32-error=0/f ; - -M: windows make-directory ( path -- ) - normalize-path - f CreateDirectory win32-error=0/f ; - -M: windows delete-directory ( path -- ) - normalize-path - RemoveDirectory win32-error=0/f ; - -: find-first-file ( path -- WIN32_FIND_DATA handle ) - "WIN32_FIND_DATA" tuck - FindFirstFile - [ INVALID_HANDLE_VALUE = [ win32-error-string throw ] when ] keep ; - -: find-next-file ( path -- WIN32_FIND_DATA/f ) - "WIN32_FIND_DATA" tuck - FindNextFile 0 = [ - GetLastError ERROR_NO_MORE_FILES = [ - win32-error - ] unless drop f - ] when ; - -M: windows (directory-entries) ( path -- seq ) - "\\" ?tail drop "\\*" append - find-first-file [ >directory-entry ] dip - [ - '[ - [ _ find-next-file dup ] - [ >directory-entry ] - [ drop ] produce - over name>> "." = [ nip ] [ swap prefix ] if - ] - ] [ '[ _ FindClose win32-error=0/f ] ] bi [ ] cleanup ; - -SYMBOLS: +read-only+ +hidden+ +system+ -+archive+ +device+ +normal+ +temporary+ -+sparse-file+ +reparse-point+ +compressed+ +offline+ -+not-content-indexed+ +encrypted+ ; - -TUPLE: windows-file-info < file-info attributes ; - -: win32-file-attribute ( n attr symbol -- ) - rot mask? [ , ] [ drop ] if ; - -: win32-file-attributes ( n -- seq ) - [ - { - [ +read-only+ FILE_ATTRIBUTE_READONLY win32-file-attribute ] - [ +hidden+ FILE_ATTRIBUTE_HIDDEN win32-file-attribute ] - [ +system+ FILE_ATTRIBUTE_SYSTEM win32-file-attribute ] - [ +directory+ FILE_ATTRIBUTE_DIRECTORY win32-file-attribute ] - [ +archive+ FILE_ATTRIBUTE_ARCHIVE win32-file-attribute ] - [ +device+ FILE_ATTRIBUTE_DEVICE win32-file-attribute ] - [ +normal+ FILE_ATTRIBUTE_NORMAL win32-file-attribute ] - [ +temporary+ FILE_ATTRIBUTE_TEMPORARY win32-file-attribute ] - [ +sparse-file+ FILE_ATTRIBUTE_SPARSE_FILE win32-file-attribute ] - [ +reparse-point+ FILE_ATTRIBUTE_REPARSE_POINT win32-file-attribute ] - [ +compressed+ FILE_ATTRIBUTE_COMPRESSED win32-file-attribute ] - [ +offline+ FILE_ATTRIBUTE_OFFLINE win32-file-attribute ] - [ +not-content-indexed+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED win32-file-attribute ] - [ +encrypted+ FILE_ATTRIBUTE_ENCRYPTED win32-file-attribute ] - } cleave - ] { } make ; - -: win32-file-type ( n -- symbol ) - FILE_ATTRIBUTE_DIRECTORY mask? +directory+ +regular-file+ ? ; - -TUPLE: windows-directory-entry < directory-entry attributes ; - -M: windows >directory-entry ( byte-array -- directory-entry ) - [ WIN32_FIND_DATA-cFileName utf16n alien>string ] - [ WIN32_FIND_DATA-dwFileAttributes win32-file-type ] - [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ] - tri - dupd remove windows-directory-entry boa ; - -: WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info ) - [ \ windows-file-info new ] dip - { - [ WIN32_FIND_DATA-dwFileAttributes win32-file-type >>type ] - [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes >>attributes ] - [ - [ WIN32_FIND_DATA-nFileSizeLow ] - [ WIN32_FIND_DATA-nFileSizeHigh ] bi >64bit >>size - ] - [ WIN32_FIND_DATA-dwFileAttributes >>permissions ] - [ WIN32_FIND_DATA-ftCreationTime FILETIME>timestamp >>created ] - [ WIN32_FIND_DATA-ftLastWriteTime FILETIME>timestamp >>modified ] - [ WIN32_FIND_DATA-ftLastAccessTime FILETIME>timestamp >>accessed ] - } cleave ; - -: find-first-file-stat ( path -- WIN32_FIND_DATA ) - "WIN32_FIND_DATA" [ - FindFirstFile - [ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep - FindClose win32-error=0/f - ] keep ; - -: BY_HANDLE_FILE_INFORMATION>file-info ( HANDLE_FILE_INFORMATION -- file-info ) - [ \ windows-file-info new ] dip - { - [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-type >>type ] - [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes win32-file-attributes >>attributes ] - [ - [ BY_HANDLE_FILE_INFORMATION-nFileSizeLow ] - [ BY_HANDLE_FILE_INFORMATION-nFileSizeHigh ] bi >64bit >>size - ] - [ BY_HANDLE_FILE_INFORMATION-dwFileAttributes >>permissions ] - [ - BY_HANDLE_FILE_INFORMATION-ftCreationTime - FILETIME>timestamp >>created - ] - [ - BY_HANDLE_FILE_INFORMATION-ftLastWriteTime - FILETIME>timestamp >>modified - ] - [ - BY_HANDLE_FILE_INFORMATION-ftLastAccessTime - FILETIME>timestamp >>accessed - ] - ! [ BY_HANDLE_FILE_INFORMATION-nNumberOfLinks ] - ! [ - ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexLow ] - ! [ BY_HANDLE_FILE_INFORMATION-nFileIndexHigh ] bi >64bit - ! ] - } cleave ; - -: get-file-information ( handle -- BY_HANDLE_FILE_INFORMATION ) - [ - "BY_HANDLE_FILE_INFORMATION" - [ GetFileInformationByHandle win32-error=0/f ] keep - ] keep CloseHandle win32-error=0/f ; - -: get-file-information-stat ( path -- BY_HANDLE_FILE_INFORMATION ) - dup - GENERIC_READ FILE_SHARE_READ f - OPEN_EXISTING FILE_FLAG_BACKUP_SEMANTICS f - CreateFileW dup INVALID_HANDLE_VALUE = [ - drop find-first-file-stat WIN32_FIND_DATA>file-info - ] [ - nip - get-file-information BY_HANDLE_FILE_INFORMATION>file-info - ] if ; - -M: winnt file-info ( path -- info ) - normalize-path get-file-information-stat ; - -M: winnt link-info ( path -- info ) - file-info ; - -HOOK: root-directory os ( string -- string' ) - -: volume-information ( normalized-path -- volume-name volume-serial max-component flags type ) - MAX_PATH 1+ [ ] keep - "DWORD" - "DWORD" - "DWORD" - MAX_PATH 1+ [ ] keep - [ GetVolumeInformation win32-error=0/f ] 7 nkeep - drop 5 nrot drop - [ utf16n alien>string ] 4 ndip - utf16n alien>string ; - -: file-system-space ( normalized-path -- available-space total-space free-space ) - "ULARGE_INTEGER" - "ULARGE_INTEGER" - "ULARGE_INTEGER" - [ GetDiskFreeSpaceEx win32-error=0/f ] 3keep ; - -: calculate-file-system-info ( file-system-info -- file-system-info' ) - { - [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ] - [ ] - } cleave ; - -TUPLE: win32-file-system-info < file-system-info max-component flags device-serial ; - -M: winnt file-system-info ( path -- file-system-info ) - normalize-path root-directory - dup [ volume-information ] [ file-system-space ] bi - \ win32-file-system-info new - swap *ulonglong >>free-space - swap *ulonglong >>total-space - swap *ulonglong >>available-space - swap >>type - swap *uint >>flags - swap *uint >>max-component - swap *uint >>device-serial - swap >>device-name - swap >>mount-point - calculate-file-system-info ; - -: volume>paths ( string -- array ) - 16384 "ushort" tuck dup length - 0 dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [ - win32-error-string throw - ] [ - *uint "ushort" heap-size * head - utf16n alien>string CHAR: \0 split - ] if ; - -: find-first-volume ( -- string handle ) - MAX_PATH 1+ [ ] keep - dupd - FindFirstVolume dup win32-error=0/f - [ utf16n alien>string ] dip ; - -: find-next-volume ( handle -- string/f ) - MAX_PATH 1+ [ tuck ] keep - FindNextVolume 0 = [ - GetLastError ERROR_NO_MORE_FILES = - [ drop f ] [ win32-error-string throw ] if - ] [ - utf16n alien>string - ] if ; - -: find-volumes ( -- array ) - find-first-volume - [ - '[ - [ _ find-next-volume dup ] - [ ] - [ drop ] produce - swap prefix - ] - ] [ '[ _ FindVolumeClose win32-error=0/f ] ] bi [ ] cleanup ; - -M: winnt file-systems ( -- array ) - find-volumes [ volume>paths ] map - concat [ - [ file-system-info ] - [ drop \ file-system-info new swap >>mount-point ] recover - ] map ; - -: file-times ( path -- timestamp timestamp timestamp ) - [ - normalize-path open-existing &dispose handle>> - "FILETIME" - "FILETIME" - "FILETIME" - [ GetFileTime win32-error=0/f ] 3keep - [ FILETIME>timestamp >local-time ] tri@ - ] with-destructors ; - -: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- ) - [ timestamp>FILETIME ] tri@ - SetFileTime win32-error=0/f ; - -: set-file-times ( path timestamp/f timestamp/f timestamp/f -- ) - #! timestamp order: creation access write - [ - [ - normalize-path open-existing &dispose handle>> - ] 3dip (set-file-times) - ] with-destructors ; - -: set-file-create-time ( path timestamp -- ) - f f set-file-times ; - -: set-file-access-time ( path timestamp -- ) - [ f ] dip f set-file-times ; - -: set-file-write-time ( path timestamp -- ) - [ f f ] dip set-file-times ; - -M: winnt touch-file ( path -- ) - [ - normalize-path - maybe-create-file [ &dispose ] dip - [ drop ] [ handle>> f now dup (set-file-times) ] if - ] with-destructors ; diff --git a/basis/io/files/windows/nt/files-tests.factor b/basis/io/files/windows/nt/nt-tests.factor similarity index 100% rename from basis/io/files/windows/nt/files-tests.factor rename to basis/io/files/windows/nt/nt-tests.factor diff --git a/basis/io/files/windows/nt/files.factor b/basis/io/files/windows/nt/nt.factor similarity index 86% rename from basis/io/files/windows/nt/files.factor rename to basis/io/files/windows/nt/nt.factor index b50b4cfa3d..f3a534388a 100755 --- a/basis/io/files/windows/nt/files.factor +++ b/basis/io/files/windows/nt/nt.factor @@ -29,16 +29,6 @@ M: winnt root-directory? ( path -- ? ) [ drop f ] } cond ; -ERROR: not-absolute-path ; - -M: winnt root-directory ( string -- string' ) - unicode-prefix ?head drop - dup { - [ length 2 >= ] - [ second CHAR: : = ] - [ first Letter? ] - } 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ; - : prepend-prefix ( string -- string' ) dup unicode-prefix head? [ unicode-prefix prepend diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor new file mode 100755 index 0000000000..30915f8c71 --- /dev/null +++ b/basis/io/files/windows/windows.factor @@ -0,0 +1,139 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types io.binary io.backend io.files io.buffers +io.encodings.utf16n io.ports io.backend.windows kernel math splitting +fry alien.strings windows windows.kernel32 windows.time calendar +combinators math.functions sequences namespaces make words +symbols system destructors accessors math.bitwise continuations +windows.errors arrays byte-arrays generalizations ; +IN: io.files.windows + +: open-file ( path access-mode create-mode flags -- handle ) + [ + [ share-mode default-security-attributes ] 2dip + CreateFile-flags f CreateFile opened-file + ] with-destructors ; + +: open-pipe-r/w ( path -- win32-file ) + { GENERIC_READ GENERIC_WRITE } flags + OPEN_EXISTING 0 open-file ; + +: open-read ( path -- win32-file ) + GENERIC_READ OPEN_EXISTING 0 open-file 0 >>ptr ; + +: open-write ( path -- win32-file ) + GENERIC_WRITE CREATE_ALWAYS 0 open-file 0 >>ptr ; + +: (open-append) ( path -- win32-file ) + GENERIC_WRITE OPEN_ALWAYS 0 open-file ; + +: open-existing ( path -- win32-file ) + { GENERIC_READ GENERIC_WRITE } flags + share-mode + f + OPEN_EXISTING + FILE_FLAG_BACKUP_SEMANTICS + f CreateFileW dup win32-error=0/f ; + +: maybe-create-file ( path -- win32-file ? ) + #! return true if file was just created + { GENERIC_READ GENERIC_WRITE } flags + share-mode + f + OPEN_ALWAYS + 0 CreateFile-flags + f CreateFileW dup win32-error=0/f + GetLastError ERROR_ALREADY_EXISTS = not ; + +: set-file-pointer ( handle length method -- ) + [ dupd d>w/w ] dip SetFilePointer + INVALID_SET_FILE_POINTER = [ + CloseHandle "SetFilePointer failed" throw + ] when drop ; + +HOOK: open-append os ( path -- win32-file ) + +TUPLE: FileArgs + hFile lpBuffer nNumberOfBytesToRead + lpNumberOfBytesRet lpOverlapped ; + +C: FileArgs + +: make-FileArgs ( port -- ) + { + [ handle>> check-disposed ] + [ handle>> handle>> ] + [ buffer>> ] + [ buffer>> buffer-length ] + [ drop "DWORD" ] + [ FileArgs-overlapped ] + } cleave ; + +: setup-read ( -- hFile lpBuffer nNumberOfBytesToRead lpNumberOfBytesRead lpOverlapped ) + { + [ hFile>> ] + [ lpBuffer>> buffer-end ] + [ lpBuffer>> buffer-capacity ] + [ lpNumberOfBytesRet>> ] + [ lpOverlapped>> ] + } cleave ; + +: setup-write ( -- hFile lpBuffer nNumberOfBytesToWrite lpNumberOfBytesWritten lpOverlapped ) + { + [ hFile>> ] + [ lpBuffer>> buffer@ ] + [ lpBuffer>> buffer-length ] + [ lpNumberOfBytesRet>> ] + [ lpOverlapped>> ] + } cleave ; + +M: windows (file-reader) ( path -- stream ) + open-read ; + +M: windows (file-writer) ( path -- stream ) + open-write ; + +M: windows (file-appender) ( path -- stream ) + open-append ; + +SYMBOLS: +read-only+ +hidden+ +system+ ++archive+ +device+ +normal+ +temporary+ ++sparse-file+ +reparse-point+ +compressed+ +offline+ ++not-content-indexed+ +encrypted+ ; + +: win32-file-attribute ( n attr symbol -- ) + rot mask? [ , ] [ drop ] if ; + +: win32-file-attributes ( n -- seq ) + [ + { + [ +read-only+ FILE_ATTRIBUTE_READONLY win32-file-attribute ] + [ +hidden+ FILE_ATTRIBUTE_HIDDEN win32-file-attribute ] + [ +system+ FILE_ATTRIBUTE_SYSTEM win32-file-attribute ] + [ +directory+ FILE_ATTRIBUTE_DIRECTORY win32-file-attribute ] + [ +archive+ FILE_ATTRIBUTE_ARCHIVE win32-file-attribute ] + [ +device+ FILE_ATTRIBUTE_DEVICE win32-file-attribute ] + [ +normal+ FILE_ATTRIBUTE_NORMAL win32-file-attribute ] + [ +temporary+ FILE_ATTRIBUTE_TEMPORARY win32-file-attribute ] + [ +sparse-file+ FILE_ATTRIBUTE_SPARSE_FILE win32-file-attribute ] + [ +reparse-point+ FILE_ATTRIBUTE_REPARSE_POINT win32-file-attribute ] + [ +compressed+ FILE_ATTRIBUTE_COMPRESSED win32-file-attribute ] + [ +offline+ FILE_ATTRIBUTE_OFFLINE win32-file-attribute ] + [ +not-content-indexed+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED win32-file-attribute ] + [ +encrypted+ FILE_ATTRIBUTE_ENCRYPTED win32-file-attribute ] + } cleave + ] { } make ; + +: win32-file-type ( n -- symbol ) + FILE_ATTRIBUTE_DIRECTORY mask? +directory+ +regular-file+ ? ; + +: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- ) + [ timestamp>FILETIME ] tri@ + SetFileTime win32-error=0/f ; + +M: winnt touch-file ( path -- ) + [ + normalize-path + maybe-create-file [ &dispose ] dip + [ drop ] [ handle>> f now dup (set-file-times) ] if + ] with-destructors ; From 023ae576b5016f7d01beca6de95e49e97ab01aa0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 01:40:50 -0600 Subject: [PATCH 11/19] Updating unit tests for io.files split --- basis/io/monitors/monitors-tests.factor | 3 ++- basis/tools/crossref/crossref-tests.factor | 5 +++-- basis/tools/deploy/deploy-tests.factor | 9 +++++---- basis/tools/vocabs/monitor/monitor-tests.factor | 2 +- basis/ui/tools/search/search-tests.factor | 2 +- core/parser/parser-tests.factor | 8 ++++---- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/basis/io/monitors/monitors-tests.factor b/basis/io/monitors/monitors-tests.factor index 50303696a3..9efa785061 100644 --- a/basis/io/monitors/monitors-tests.factor +++ b/basis/io/monitors/monitors-tests.factor @@ -2,7 +2,8 @@ IN: io.monitors.tests USING: io.monitors tools.test io.files system sequences continuations namespaces concurrency.count-downs kernel io threads calendar prettyprint destructors io.timeouts -io.files.temp io.directories io.pathnames ; +io.files.temp io.directories io.directories.hierarchy +io.pathnames ; os { winnt linux macosx } member? [ [ diff --git a/basis/tools/crossref/crossref-tests.factor b/basis/tools/crossref/crossref-tests.factor index 5bf917f906..e7e2e55259 100644 --- a/basis/tools/crossref/crossref-tests.factor +++ b/basis/tools/crossref/crossref-tests.factor @@ -1,5 +1,6 @@ -USING: math kernel sequences io.files tools.crossref tools.test -parser namespaces source-files generic definitions ; +USING: math kernel sequences io.files io.pathnames +tools.crossref tools.test parser namespaces source-files generic +definitions ; IN: tools.crossref.tests GENERIC: foo diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index a390ce56c4..d5cb4ab387 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -1,8 +1,9 @@ IN: tools.deploy.tests -USING: tools.test system io.files kernel tools.deploy.config -tools.deploy.config.editor tools.deploy.backend math sequences -io.launcher arrays namespaces continuations layouts accessors -io.encodings.ascii urls math.parser ; +USING: tools.test system io.files io.files.temp kernel +tools.deploy.config tools.deploy.config.editor +tools.deploy.backend math sequences io.launcher arrays +namespaces continuations layouts accessors io.encodings.ascii +urls math.parser ; : shake-and-bake ( vocab -- ) [ "test.image" temp-file delete-file ] ignore-errors diff --git a/basis/tools/vocabs/monitor/monitor-tests.factor b/basis/tools/vocabs/monitor/monitor-tests.factor index f1eece91c2..0e767a3d34 100644 --- a/basis/tools/vocabs/monitor/monitor-tests.factor +++ b/basis/tools/vocabs/monitor/monitor-tests.factor @@ -1,4 +1,4 @@ -USING: tools.test tools.vocabs.monitor io.files ; +USING: tools.test tools.vocabs.monitor io.pathnames ; IN: tools.vocabs.monitor.tests [ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test diff --git a/basis/ui/tools/search/search-tests.factor b/basis/ui/tools/search/search-tests.factor index 39a6442308..4f239ba6e9 100644 --- a/basis/ui/tools/search/search-tests.factor +++ b/basis/ui/tools/search/search-tests.factor @@ -1,4 +1,4 @@ -USING: assocs ui.tools.search help.topics io.files io.styles +USING: assocs ui.tools.search help.topics io.pathnames io.styles kernel namespaces sequences source-files threads tools.test ui.gadgets ui.gestures vocabs accessors vocabs.loader words tools.test.ui debugger calendar ; diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index cc97b78eb6..6ddf299f7f 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -1,8 +1,8 @@ USING: arrays math parser tools.test kernel generic words -io.streams.string namespaces classes effects source-files -assocs sequences strings io.files definitions continuations -sorting classes.tuple compiler.units debugger vocabs -vocabs.loader accessors eval combinators lexer ; +io.streams.string namespaces classes effects source-files assocs +sequences strings io.files io.pathnames definitions +continuations sorting classes.tuple compiler.units debugger +vocabs vocabs.loader accessors eval combinators lexer ; IN: parser.tests \ run-file must-infer From 7b62d199241b9ac737aaff18025c43e5ce6e8a80 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 02:02:22 -0600 Subject: [PATCH 12/19] Oops --- basis/io/files/temp/temp-docs.factor | 9 +++++++++ basis/io/files/temp/temp.factor | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 basis/io/files/temp/temp-docs.factor create mode 100644 basis/io/files/temp/temp.factor diff --git a/basis/io/files/temp/temp-docs.factor b/basis/io/files/temp/temp-docs.factor new file mode 100644 index 0000000000..e9f49283de --- /dev/null +++ b/basis/io/files/temp/temp-docs.factor @@ -0,0 +1,9 @@ +USING: help.markup help.syntax ; +IN: io.files.temp + +ARTICLE: "io.files.temp" "Temporary files" +"Pathnames relative to Factor's temporary files directory:" +{ $subsection temp-directory } +{ $subsection temp-file } ; + +ABOUT: "io.files.temp" diff --git a/basis/io/files/temp/temp.factor b/basis/io/files/temp/temp.factor new file mode 100644 index 0000000000..7ace21932a --- /dev/null +++ b/basis/io/files/temp/temp.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2008 Slava Pestov, Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel io.pathnames io.directories ; +IN: io.files.temp + +: temp-directory ( -- path ) + "temp" resource-path dup make-directories ; + +: temp-file ( name -- path ) + temp-directory prepend-path ; \ No newline at end of file From 82e452a885c0718c49e4c0095e88dc076430eb1c Mon Sep 17 00:00:00 2001 From: slava Date: Mon, 15 Dec 2008 02:18:59 -0600 Subject: [PATCH 13/19] Fix Linux bootstrap --- basis/io/files/info/unix/freebsd/freebsd.factor | 2 +- basis/io/files/info/unix/linux/linux.factor | 2 +- basis/io/files/info/unix/netbsd/netbsd.factor | 2 +- basis/io/files/info/unix/openbsd/openbsd.factor | 2 +- basis/io/monitors/linux/linux.factor | 2 +- basis/tools/deploy/unix/unix.factor | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/basis/io/files/info/unix/freebsd/freebsd.factor b/basis/io/files/info/unix/freebsd/freebsd.factor index c36a750997..398e4ff968 100644 --- a/basis/io/files/info/unix/freebsd/freebsd.factor +++ b/basis/io/files/info/unix/freebsd/freebsd.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators -io.backend io.files io.files.unix kernel math system unix +io.backend io.files io.files.info io.files.unix kernel math system unix unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd sequences grouping alien.strings io.encodings.utf8 specialized-arrays.direct.uint arrays io.files.info.unix ; diff --git a/basis/io/files/info/unix/linux/linux.factor b/basis/io/files/info/unix/linux/linux.factor index 9d611bdc5c..ee4a1ed91f 100644 --- a/basis/io/files/info/unix/linux/linux.factor +++ b/basis/io/files/info/unix/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators csv -io.backend io.encodings.utf8 io.files io.streams.string +io.backend io.encodings.utf8 io.files io.files.info io.streams.string io.files.unix kernel math.order namespaces sequences sorting system unix unix.statfs.linux unix.statvfs.linux specialized-arrays.direct.uint arrays io.files.info.unix ; diff --git a/basis/io/files/info/unix/netbsd/netbsd.factor b/basis/io/files/info/unix/netbsd/netbsd.factor index 0c26a2a2c9..6dc0bb3f87 100644 --- a/basis/io/files/info/unix/netbsd/netbsd.factor +++ b/basis/io/files/info/unix/netbsd/netbsd.factor @@ -3,7 +3,7 @@ USING: alien.syntax kernel unix.stat math unix combinators system io.backend accessors alien.c-types io.encodings.utf8 alien.strings unix.types io.files.unix -io.files unix.statvfs.netbsd unix.getfsstat.netbsd arrays +io.files io.files.info unix.statvfs.netbsd unix.getfsstat.netbsd arrays grouping sequences io.encodings.utf8 specialized-arrays.direct.uint io.files.info.unix ; IN: io.files.info.unix.netbsd diff --git a/basis/io/files/info/unix/openbsd/openbsd.factor b/basis/io/files/info/unix/openbsd/openbsd.factor index 7057e2e8c7..62783a968b 100644 --- a/basis/io/files/info/unix/openbsd/openbsd.factor +++ b/basis/io/files/info/unix/openbsd/openbsd.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.strings alien.syntax -combinators io.backend io.files io.files.unix kernel math +combinators io.backend io.files io.files.info io.files.unix kernel math sequences system unix unix.getfsstat.openbsd grouping unix.statfs.openbsd unix.statvfs.openbsd unix.types specialized-arrays.direct.uint arrays io.files.info.unix ; diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor index 12efd8112d..e914f32a48 100644 --- a/basis/io/monitors/linux/linux.factor +++ b/basis/io/monitors/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel io.backend io.monitors io.monitors.recursive -io.files io.buffers io.monitors io.ports io.timeouts +io.files io.pathnames io.buffers io.monitors io.ports io.timeouts io.backend.unix io.encodings.utf8 unix.linux.inotify assocs namespaces make threads continuations init math math.bitwise sets alien alien.strings alien.c-types vocabs.loader accessors diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index faafa1e932..9e0bb8ac68 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 James Cash ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files io.files.info.unix io.backend kernel -namespaces make sequences system tools.deploy.backend -tools.deploy.config tools.deploy.config.editor assocs hashtables -prettyprint ; +USING: io io.pathnames io.directories io.files +io.files.info.unix io.backend kernel namespaces make sequences +system tools.deploy.backend tools.deploy.config +tools.deploy.config.editor assocs hashtables prettyprint ; IN: tools.deploy.unix : create-app-dir ( vocab bundle-name -- vm ) From f4c3bf1dd65f969c0297bfe1c72799dd8c565a91 Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Sat, 13 Dec 2008 04:49:16 -0600 Subject: [PATCH 14/19] Fix compile warning and fix (sleep) primitive on Windows --- vm/os-windows.c | 4 ++-- vm/os-windows.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/vm/os-windows.c b/vm/os-windows.c index ee2c721111..c3e9e50cee 100755 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -166,7 +166,7 @@ long getpagesize(void) return g_pagesize; } -void sleep_micros(DWORD usec) +void sleep_micros(u64 usec) { - Sleep(usec); + Sleep((DWORD)(usec / 1000)); } diff --git a/vm/os-windows.h b/vm/os-windows.h index af9b75bca5..227d44af77 100755 --- a/vm/os-windows.h +++ b/vm/os-windows.h @@ -20,17 +20,18 @@ typedef wchar_t F_CHAR; #define STRNCMP wcsncmp #define STRDUP _wcsdup -#define FIXNUM_FORMAT "%Id" #define CELL_FORMAT "%lu" -#define CELL_HEX_FORMAT "%Ix" #ifdef WIN64 + #define CELL_HEX_FORMAT "%Ix" #define CELL_HEX_PAD_FORMAT "%016Ix" + #define FIXNUM_FORMAT "%Id" #else + #define CELL_HEX_FORMAT "%lx" #define CELL_HEX_PAD_FORMAT "%08lx" + #define FIXNUM_FORMAT "%ld" #endif -#define FIXNUM_FORMAT "%Id" #define OPEN_READ(path) _wfopen(path,L"rb") #define OPEN_WRITE(path) _wfopen(path,L"wb") @@ -49,7 +50,7 @@ void ffi_dlopen(F_DLL *dll); void *ffi_dlsym(F_DLL *dll, F_SYMBOL *symbol); void ffi_dlclose(F_DLL *dll); -void sleep_micros(DWORD msec); +void sleep_micros(u64 msec); INLINE void init_signals(void) {} INLINE void early_init(void) {} From cccacdaa5a80502fc410e0101400d023ff82be4a Mon Sep 17 00:00:00 2001 From: "U-SLAVA-DFB8FF805\\Slava" Date: Sat, 13 Dec 2008 04:49:28 -0600 Subject: [PATCH 15/19] io.backend.windows.nt needs to set io-backend --- basis/io/backend/windows/nt/nt.factor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor index e41293b6de..bb8175b35c 100755 --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -118,3 +118,5 @@ M: winnt (wait-to-read) ( port -- ) ] with-destructors ; M: winnt (init-stdio) init-c-stdio ; + +winnt set-io-backend From 5cb18d51b36e80d5ab7e919c3d2461d44ac7bdde Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 03:33:04 -0600 Subject: [PATCH 16/19] Fixing test-all and help-lint-all failures --- basis/concurrency/distributed/distributed-tests.factor | 5 +++-- basis/db/pools/pools-tests.factor | 4 ++-- basis/db/sqlite/sqlite-tests.factor | 4 ++-- basis/db/tuples/tuples-tests.factor | 2 +- basis/furnace/auth/providers/db/db-tests.factor | 2 +- basis/furnace/sessions/sessions-tests.factor | 6 +++--- basis/http/http-tests.factor | 2 +- basis/io/directories/windows/tags.txt | 1 + basis/io/files/info/windows/nt/nt.factor | 4 ---- basis/io/files/info/windows/tags.txt | 1 + basis/io/files/types/types-docs.factor | 6 +++--- basis/io/monitors/linux/linux-tests.factor | 7 ++++--- basis/io/monitors/recursive/recursive-tests.factor | 3 ++- basis/mime/multipart/multipart-tests.factor | 7 ++++--- basis/tools/deploy/deploy-tests.factor | 2 +- core/io/pathnames/pathnames-docs.factor | 8 ++++---- core/syntax/syntax-docs.factor | 2 +- extra/mason/common/common-tests.factor | 2 +- extra/system-info/linux/linux.factor | 2 +- 19 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 basis/io/directories/windows/tags.txt delete mode 100755 basis/io/files/info/windows/nt/nt.factor create mode 100644 basis/io/files/info/windows/tags.txt diff --git a/basis/concurrency/distributed/distributed-tests.factor b/basis/concurrency/distributed/distributed-tests.factor index 1087823aa0..996e3db4c0 100644 --- a/basis/concurrency/distributed/distributed-tests.factor +++ b/basis/concurrency/distributed/distributed-tests.factor @@ -1,7 +1,8 @@ IN: concurrency.distributed.tests USING: tools.test concurrency.distributed kernel io.files -arrays io.sockets system combinators threads math sequences -concurrency.messaging continuations accessors prettyprint ; +io.files.temp io.directories arrays io.sockets system +combinators threads math sequences concurrency.messaging +continuations accessors prettyprint ; : test-node ( -- addrspec ) { diff --git a/basis/db/pools/pools-tests.factor b/basis/db/pools/pools-tests.factor index 0a68db501b..7ff2a33d92 100644 --- a/basis/db/pools/pools-tests.factor +++ b/basis/db/pools/pools-tests.factor @@ -1,6 +1,6 @@ IN: db.pools.tests -USING: db.pools tools.test continuations io.files namespaces -accessors kernel math destructors ; +USING: db.pools tools.test continuations io.files io.files.temp +io.directories namespaces accessors kernel math destructors ; \ must-infer diff --git a/basis/db/sqlite/sqlite-tests.factor b/basis/db/sqlite/sqlite-tests.factor index fe95980bcf..b816e414ba 100644 --- a/basis/db/sqlite/sqlite-tests.factor +++ b/basis/db/sqlite/sqlite-tests.factor @@ -1,5 +1,5 @@ -USING: io io.files io.launcher kernel namespaces -prettyprint tools.test db.sqlite db sequences +USING: io io.files io.files.temp io.directories io.launcher +kernel namespaces prettyprint tools.test db.sqlite db sequences continuations db.types db.tuples unicode.case ; IN: db.sqlite.tests diff --git a/basis/db/tuples/tuples-tests.factor b/basis/db/tuples/tuples-tests.factor index 0432f38683..b834c2c990 100644 --- a/basis/db/tuples/tuples-tests.factor +++ b/basis/db/tuples/tuples-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files kernel tools.test db db.tuples classes +USING: io.files io.files.temp kernel tools.test db db.tuples classes db.types continuations namespaces math math.ranges prettyprint calendar sequences db.sqlite math.intervals db.postgresql accessors random math.bitwise system diff --git a/basis/furnace/auth/providers/db/db-tests.factor b/basis/furnace/auth/providers/db/db-tests.factor index 3bcd82a15d..de7650d9ef 100644 --- a/basis/furnace/auth/providers/db/db-tests.factor +++ b/basis/furnace/auth/providers/db/db-tests.factor @@ -5,7 +5,7 @@ furnace.auth.login furnace.auth.providers furnace.auth.providers.db tools.test namespaces db db.sqlite db.tuples continuations -io.files accessors kernel ; +io.files io.files.temp io.directories accessors kernel ; "test" realm set diff --git a/basis/furnace/sessions/sessions-tests.factor b/basis/furnace/sessions/sessions-tests.factor index 907e657125..14cdce3811 100644 --- a/basis/furnace/sessions/sessions-tests.factor +++ b/basis/furnace/sessions/sessions-tests.factor @@ -2,9 +2,9 @@ IN: furnace.sessions.tests USING: tools.test http furnace.sessions furnace.actions http.server http.server.responses math namespaces make kernel accessors io.sockets io.servers.connection prettyprint -io.streams.string io.files splitting destructors sequences db -db.tuples db.sqlite continuations urls math.parser furnace -furnace.utilities ; +io.streams.string io.files io.files.temp io.directories +splitting destructors sequences db db.tuples db.sqlite +continuations urls math.parser furnace furnace.utilities ; : with-session [ diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 6e93d5ee3a..92a296c2d3 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -179,7 +179,7 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes ! Live-fire exercise USING: http.server http.server.static furnace.sessions furnace.alloy furnace.actions furnace.auth furnace.auth.login furnace.db http.client -io.servers.connection io.files io io.encodings.ascii +io.servers.connection io.files io.files.temp io.directories io io.encodings.ascii accessors namespaces threads http.server.responses http.server.redirection furnace.redirection http.server.dispatchers db.tuples ; diff --git a/basis/io/directories/windows/tags.txt b/basis/io/directories/windows/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/io/directories/windows/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/io/files/info/windows/nt/nt.factor b/basis/io/files/info/windows/nt/nt.factor deleted file mode 100755 index 19ea0864ed..0000000000 --- a/basis/io/files/info/windows/nt/nt.factor +++ /dev/null @@ -1,4 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -IN: io.files.info.windows.nt - diff --git a/basis/io/files/info/windows/tags.txt b/basis/io/files/info/windows/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/io/files/info/windows/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/io/files/types/types-docs.factor b/basis/io/files/types/types-docs.factor index 48df9b2328..a6402851ea 100644 --- a/basis/io/files/types/types-docs.factor +++ b/basis/io/files/types/types-docs.factor @@ -2,13 +2,13 @@ USING: help.markup help.syntax ; IN: io.files.types HELP: +regular-file+ -{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ; +{ $description "A regular file. This type exists on all platforms. See " { $link "io.files" } " for words operating on files." } ; HELP: +directory+ -{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ; +{ $description "A directory. This type exists on all platforms. See " { $link "io.directories" } " for words operating on directories." } ; HELP: +symbolic-link+ -{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ; +{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "io.files.links" } " for words operating on symbolic links." } ; HELP: +character-device+ { $description "A Unix character device file. This type exists on Unix platforms only." } ; diff --git a/basis/io/monitors/linux/linux-tests.factor b/basis/io/monitors/linux/linux-tests.factor index 8e2cebc3a4..67558942f8 100644 --- a/basis/io/monitors/linux/linux-tests.factor +++ b/basis/io/monitors/linux/linux-tests.factor @@ -1,7 +1,8 @@ IN: io.monitors.linux.tests -USING: io.monitors tools.test io.files system sequences -continuations namespaces concurrency.count-downs kernel io -threads calendar prettyprint destructors io.timeouts ; +USING: io.monitors tools.test io.files io.files.temp +io.directories system sequences continuations namespaces +concurrency.count-downs kernel io threads calendar prettyprint +destructors io.timeouts ; ! On Linux, a notification on the directory itself would report an invalid ! path name diff --git a/basis/io/monitors/recursive/recursive-tests.factor b/basis/io/monitors/recursive/recursive-tests.factor index fba879a6d2..ace93ace44 100644 --- a/basis/io/monitors/recursive/recursive-tests.factor +++ b/basis/io/monitors/recursive/recursive-tests.factor @@ -1,6 +1,7 @@ USING: accessors math kernel namespaces continuations io.files io.monitors io.monitors.recursive io.backend -concurrency.mailboxes tools.test destructors ; +concurrency.mailboxes tools.test destructors io.files.info +io.pathnames io.files.temp io.directories.hierarchy ; IN: io.monitors.recursive.tests \ pump-thread must-infer diff --git a/basis/mime/multipart/multipart-tests.factor b/basis/mime/multipart/multipart-tests.factor index 1445af8309..1fb2530705 100644 --- a/basis/mime/multipart/multipart-tests.factor +++ b/basis/mime/multipart/multipart-tests.factor @@ -1,7 +1,8 @@ USING: accessors checksums checksums.md5 io io.encodings.ascii -io.encodings.binary io.files io.streams.byte-array -io.streams.string kernel make mime.multipart -mime.multipart.private multiline sequences strings tools.test ; +io.encodings.binary io.files io.files.temp io.files.info +io.streams.byte-array io.streams.string kernel make +mime.multipart mime.multipart.private multiline sequences +strings tools.test ; IN: mime.multipart.tests [ { "a" } ] [ diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index d5cb4ab387..0275f7fdf0 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -3,7 +3,7 @@ USING: tools.test system io.files io.files.temp kernel tools.deploy.config tools.deploy.config.editor tools.deploy.backend math sequences io.launcher arrays namespaces continuations layouts accessors io.encodings.ascii -urls math.parser ; +urls math.parser io.directories ; : shake-and-bake ( vocab -- ) [ "test.image" temp-file delete-file ] ignore-errors diff --git a/core/io/pathnames/pathnames-docs.factor b/core/io/pathnames/pathnames-docs.factor index 3ba864d471..8ef0de86b7 100644 --- a/core/io/pathnames/pathnames-docs.factor +++ b/core/io/pathnames/pathnames-docs.factor @@ -6,20 +6,20 @@ HELP: path-separator? { $description "Tests if the code point is a platform-specific path separator." } { $examples "On Unix:" - { $example "USING: io.files prettyprint ;" "CHAR: / path-separator? ." "t" } + { $example "USING: io.pathnames prettyprint ;" "CHAR: / path-separator? ." "t" } } ; HELP: parent-directory { $values { "path" "a pathname string" } { "parent" "a pathname string" } } { $description "Strips the last component off a pathname." } -{ $examples { $example "USING: io io.files ;" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; +{ $examples { $example "USING: io io.pathnames ;" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; HELP: file-name { $values { "path" "a pathname string" } { "string" string } } { $description "Outputs the last component of a pathname string." } { $examples - { $example "USING: io.files prettyprint ;" "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } - { $example "USING: io.files prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } + { $example "USING: io.pathnames prettyprint ;" "\"/usr/bin/gcc\" file-name ." "\"gcc\"" } + { $example "USING: io.pathnames prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" } } ; HELP: append-path diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index c1e12ea133..7a1cb5fd92 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -144,7 +144,7 @@ ARTICLE: "syntax-byte-arrays" "Byte array syntax" ARTICLE: "syntax-pathnames" "Pathname syntax" { $subsection POSTPONE: P" } -"Pathnames are documented in " { $link "pathnames" } "." ; +"Pathnames are documented in " { $link "io.pathnames" } "." ; ARTICLE: "syntax-literals" "Literals" "Many different types of objects can be constructed at parse time via literal syntax. Numbers are a special case since support for reading them is built-in to the parser. All other literals are constructed via parsing words." diff --git a/extra/mason/common/common-tests.factor b/extra/mason/common/common-tests.factor index ed6ffecdd1..095cbd1a80 100644 --- a/extra/mason/common/common-tests.factor +++ b/extra/mason/common/common-tests.factor @@ -1,6 +1,6 @@ IN: mason.common.tests USING: prettyprint mason.common mason.config -namespaces calendar tools.test io.files io.encodings.utf8 ; +namespaces calendar tools.test io.files io.files.temp io.encodings.utf8 ; [ "00:01:01" ] [ 61000 milli-seconds>time ] unit-test diff --git a/extra/system-info/linux/linux.factor b/extra/system-info/linux/linux.factor index d7f53fb9fb..d9c39ca6cf 100644 --- a/extra/system-info/linux/linux.factor +++ b/extra/system-info/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: unix alien alien.c-types kernel math sequences strings -io.unix.backend splitting ; +io.backend.unix splitting ; IN: system-info.linux : (uname) ( buf -- int ) From 89255e08c1e9de2c7f709d726d5e7dcce2955949 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 03:46:57 -0600 Subject: [PATCH 17/19] Fix tools.deploy test --- basis/tools/deploy/deploy-tests.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index 0275f7fdf0..e15ba9b90e 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -1,9 +1,9 @@ IN: tools.deploy.tests -USING: tools.test system io.files io.files.temp kernel -tools.deploy.config tools.deploy.config.editor -tools.deploy.backend math sequences io.launcher arrays -namespaces continuations layouts accessors io.encodings.ascii -urls math.parser io.directories ; +USING: tools.test system io.pathnames io.files io.files.info +io.files.temp kernel tools.deploy.config +tools.deploy.config.editor tools.deploy.backend math sequences +io.launcher arrays namespaces continuations layouts accessors +io.encodings.ascii urls math.parser io.directories ; : shake-and-bake ( vocab -- ) [ "test.image" temp-file delete-file ] ignore-errors From b14c49f1a539b6b35b8f2d67cd408ac8fd731f51 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 03:47:13 -0600 Subject: [PATCH 18/19] Fix windows-time>FILETIME (why was this broken for so long?) --- basis/windows/time/time.factor | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/windows/time/time.factor b/basis/windows/time/time.factor index 54a7a8e32a..e63834d369 100644 --- a/basis/windows/time/time.factor +++ b/basis/windows/time/time.factor @@ -11,8 +11,9 @@ IN: windows.time 1601 1 1 0 0 0 instant ; : FILETIME>windows-time ( FILETIME -- n ) - [ FILETIME-dwLowDateTime ] keep - FILETIME-dwHighDateTime >64bit ; + [ FILETIME-dwLowDateTime ] + [ FILETIME-dwHighDateTime ] + bi >64bit ; : windows-time>timestamp ( n -- timestamp ) 10000000 /i seconds windows-1601 swap time+ ; @@ -28,12 +29,12 @@ IN: windows.time : windows-time>FILETIME ( n -- FILETIME ) "FILETIME" [ - [ 32 bits set-FILETIME-dwLowDateTime ] 2keep - [ -32 shift ] dip set-FILETIME-dwHighDateTime + [ [ 32 bits ] dip set-FILETIME-dwLowDateTime ] + [ [ -32 shift ] dip set-FILETIME-dwHighDateTime ] 2bi ] keep ; : timestamp>FILETIME ( timestamp -- FILETIME/f ) - [ >gmt timestamp>windows-time windows-time>FILETIME ] [ f ] if* ; + dup [ >gmt timestamp>windows-time windows-time>FILETIME ] when ; : FILETIME>timestamp ( FILETIME -- timestamp/f ) FILETIME>windows-time windows-time>timestamp ; From e335059a87c58316fa35bdf05839312f2dbc816e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 15 Dec 2008 08:15:32 -0600 Subject: [PATCH 19/19] Add meta-data to new I/O vocabularies --- basis/io/directories/authors.txt | 2 ++ basis/io/directories/hierarchy/authors.txt | 1 + basis/io/directories/hierarchy/summary.txt | 1 + basis/io/directories/summary.txt | 1 + basis/io/files/info/authors.txt | 2 ++ basis/io/files/info/summary.txt | 1 + basis/io/files/links/authors.txt | 2 ++ basis/io/files/links/summary.txt | 1 + core/io/pathnames/authors.txt | 2 ++ core/io/pathnames/summary.txt | 1 + 10 files changed, 14 insertions(+) create mode 100644 basis/io/directories/authors.txt create mode 100644 basis/io/directories/hierarchy/authors.txt create mode 100644 basis/io/directories/hierarchy/summary.txt create mode 100644 basis/io/directories/summary.txt create mode 100644 basis/io/files/info/authors.txt create mode 100644 basis/io/files/info/summary.txt create mode 100644 basis/io/files/links/authors.txt create mode 100644 basis/io/files/links/summary.txt create mode 100644 core/io/pathnames/authors.txt create mode 100644 core/io/pathnames/summary.txt diff --git a/basis/io/directories/authors.txt b/basis/io/directories/authors.txt new file mode 100644 index 0000000000..f372b574ae --- /dev/null +++ b/basis/io/directories/authors.txt @@ -0,0 +1,2 @@ +Slava Pestov +Doug Coleman diff --git a/basis/io/directories/hierarchy/authors.txt b/basis/io/directories/hierarchy/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/basis/io/directories/hierarchy/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/basis/io/directories/hierarchy/summary.txt b/basis/io/directories/hierarchy/summary.txt new file mode 100644 index 0000000000..3480f88d49 --- /dev/null +++ b/basis/io/directories/hierarchy/summary.txt @@ -0,0 +1 @@ +Deleting and copying directory hierarchies diff --git a/basis/io/directories/summary.txt b/basis/io/directories/summary.txt new file mode 100644 index 0000000000..b77012207b --- /dev/null +++ b/basis/io/directories/summary.txt @@ -0,0 +1 @@ +Listing directories, moving, copying and deleting files diff --git a/basis/io/files/info/authors.txt b/basis/io/files/info/authors.txt new file mode 100644 index 0000000000..f372b574ae --- /dev/null +++ b/basis/io/files/info/authors.txt @@ -0,0 +1,2 @@ +Slava Pestov +Doug Coleman diff --git a/basis/io/files/info/summary.txt b/basis/io/files/info/summary.txt new file mode 100644 index 0000000000..5d354fb573 --- /dev/null +++ b/basis/io/files/info/summary.txt @@ -0,0 +1 @@ +File and file system meta-data diff --git a/basis/io/files/links/authors.txt b/basis/io/files/links/authors.txt new file mode 100644 index 0000000000..f372b574ae --- /dev/null +++ b/basis/io/files/links/authors.txt @@ -0,0 +1,2 @@ +Slava Pestov +Doug Coleman diff --git a/basis/io/files/links/summary.txt b/basis/io/files/links/summary.txt new file mode 100644 index 0000000000..6f5e4598db --- /dev/null +++ b/basis/io/files/links/summary.txt @@ -0,0 +1 @@ +Working with symbolic links diff --git a/core/io/pathnames/authors.txt b/core/io/pathnames/authors.txt new file mode 100644 index 0000000000..f372b574ae --- /dev/null +++ b/core/io/pathnames/authors.txt @@ -0,0 +1,2 @@ +Slava Pestov +Doug Coleman diff --git a/core/io/pathnames/summary.txt b/core/io/pathnames/summary.txt new file mode 100644 index 0000000000..de19eed0d1 --- /dev/null +++ b/core/io/pathnames/summary.txt @@ -0,0 +1 @@ +Pathname manipulation