Merge branch 'master' of git://factorcode.org/git/factor
commit
19b1de8b5e
|
@ -1,5 +1,5 @@
|
||||||
USING: help.markup help.syntax io io.styles strings
|
USING: help.markup help.syntax io io.styles strings
|
||||||
io.backend io.files.private quotations ;
|
io.backend io.files.private quotations ;
|
||||||
IN: io.files
|
IN: io.files
|
||||||
|
|
||||||
ARTICLE: "file-streams" "Reading and writing files"
|
ARTICLE: "file-streams" "Reading and writing files"
|
||||||
|
@ -43,12 +43,18 @@ ARTICLE: "directories" "Directories"
|
||||||
{ $subsection make-directory }
|
{ $subsection make-directory }
|
||||||
{ $subsection make-directories } ;
|
{ $subsection make-directories } ;
|
||||||
|
|
||||||
|
! ARTICLE: "file-types" "File Types"
|
||||||
|
|
||||||
|
! { $table { +directory+ "" } }
|
||||||
|
|
||||||
|
! ;
|
||||||
|
|
||||||
ARTICLE: "fs-meta" "File meta-data"
|
ARTICLE: "fs-meta" "File meta-data"
|
||||||
|
|
||||||
{ $subsection file-info }
|
{ $subsection file-info }
|
||||||
{ $subsection link-info }
|
{ $subsection link-info }
|
||||||
{ $subsection exists? }
|
{ $subsection exists? }
|
||||||
{ $subsection directory? }
|
{ $subsection directory? }
|
||||||
{ $subsection file-length }
|
|
||||||
{ $subsection file-modified }
|
{ $subsection file-modified }
|
||||||
{ $subsection stat } ;
|
{ $subsection stat } ;
|
||||||
|
|
||||||
|
@ -119,11 +125,26 @@ HELP: file-name
|
||||||
! need a $class-description file-info
|
! need a $class-description file-info
|
||||||
|
|
||||||
HELP: file-info
|
HELP: file-info
|
||||||
|
|
||||||
{ $values { "path" "a pathname string" }
|
{ $values { "path" "a pathname string" }
|
||||||
{ "info" "a file-info tuple" } }
|
{ "info" file-info } }
|
||||||
{ $description "Queries the file system for meta data. "
|
{ $description "Queries the file system for meta data. "
|
||||||
"If path refers to a symbolic link, it is followed."
|
"If path refers to a symbolic link, it is followed."
|
||||||
"If the file does not exist, an exception is thrown." } ;
|
"If the file does not exist, an exception is thrown." }
|
||||||
|
|
||||||
|
{ $class-description "File meta data" }
|
||||||
|
|
||||||
|
{ $table
|
||||||
|
{ "type" { "One of the following:"
|
||||||
|
{ $list { $link +regular-file+ }
|
||||||
|
{ $link +directory+ }
|
||||||
|
{ $link +symbolic-link+ } } } }
|
||||||
|
|
||||||
|
{ "size" "Size of the file in bytes" }
|
||||||
|
{ "modified" "Last modification timestamp." } }
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
! need a see also to link-info
|
! need a see also to link-info
|
||||||
|
|
||||||
HELP: link-info
|
HELP: link-info
|
||||||
|
@ -135,6 +156,8 @@ HELP: link-info
|
||||||
"If the file does not exist, an exception is thrown." } ;
|
"If the file does not exist, an exception is thrown." } ;
|
||||||
! need a see also to file-info
|
! need a see also to file-info
|
||||||
|
|
||||||
|
{ file-info link-info } related-words
|
||||||
|
|
||||||
HELP: <file-reader>
|
HELP: <file-reader>
|
||||||
{ $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" } }
|
||||||
{ "stream" "an input stream" } }
|
{ "stream" "an input stream" } }
|
||||||
|
@ -199,7 +222,7 @@ HELP: stat ( path -- directory? permissions length modified )
|
||||||
"Queries the file system for file meta data. If the file does not exist, outputs " { $link f } " for all four values."
|
"Queries the file system for file meta data. If the file does not exist, outputs " { $link f } " for all four values."
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
{ stat exists? directory? file-length file-modified } related-words
|
{ stat exists? directory? file-modified } related-words
|
||||||
|
|
||||||
HELP: path+
|
HELP: path+
|
||||||
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
||||||
|
@ -227,10 +250,6 @@ HELP: directory*
|
||||||
{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." }
|
{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." }
|
||||||
{ $notes "Unlike " { $link directory } ", this word prepends the directory's path to all file names in the list." } ;
|
{ $notes "Unlike " { $link directory } ", this word prepends the directory's path to all file names in the list." } ;
|
||||||
|
|
||||||
HELP: file-length
|
|
||||||
{ $values { "path" "a pathname string" } { "n" "a non-negative integer or " { $link f } } }
|
|
||||||
{ $description "Outputs the length of the file in bytes, or " { $link f } " if it does not exist." } ;
|
|
||||||
|
|
||||||
HELP: file-modified
|
HELP: file-modified
|
||||||
{ $values { "path" "a pathname string" } { "n" "a non-negative integer or " { $link f } } }
|
{ $values { "path" "a pathname string" } { "n" "a non-negative integer or " { $link f } } }
|
||||||
{ $description "Outputs a file's last modification time, since midnight January 1, 1970. If the file does not exist, outputs " { $link f } "." } ;
|
{ $description "Outputs a file's last modification time, since midnight January 1, 1970. If the file does not exist, outputs " { $link f } "." } ;
|
||||||
|
|
|
@ -30,9 +30,11 @@ SYMBOL: person3
|
||||||
SYMBOL: person4
|
SYMBOL: person4
|
||||||
|
|
||||||
: test-tuples ( -- )
|
: test-tuples ( -- )
|
||||||
[ person drop-table ] [ drop ] recover
|
[ ] [ person ensure-table ] unit-test
|
||||||
|
[ ] [ person drop-table ] unit-test
|
||||||
[ ] [ person create-table ] unit-test
|
[ ] [ person create-table ] unit-test
|
||||||
[ person create-table ] must-fail
|
[ person create-table ] must-fail
|
||||||
|
[ ] [ person ensure-table ] unit-test
|
||||||
|
|
||||||
[ ] [ person1 get insert-tuple ] unit-test
|
[ ] [ person1 get insert-tuple ] unit-test
|
||||||
|
|
||||||
|
@ -191,8 +193,8 @@ TUPLE: annotation n paste-id summary author mode contents ;
|
||||||
[ native-person-schema test-tuples ] test-sqlite
|
[ native-person-schema test-tuples ] test-sqlite
|
||||||
[ assigned-person-schema test-tuples ] test-sqlite
|
[ assigned-person-schema test-tuples ] test-sqlite
|
||||||
|
|
||||||
[ native-person-schema test-tuples ] test-postgresql
|
! [ native-person-schema test-tuples ] test-postgresql
|
||||||
[ assigned-person-schema test-tuples ] test-postgresql
|
! [ assigned-person-schema test-tuples ] test-postgresql
|
||||||
|
|
||||||
TUPLE: serialize-me id data ;
|
TUPLE: serialize-me id data ;
|
||||||
|
|
||||||
|
@ -211,7 +213,7 @@ TUPLE: serialize-me id data ;
|
||||||
] [ T{ serialize-me f 1 } select-tuples ] unit-test ;
|
] [ T{ serialize-me f 1 } select-tuples ] unit-test ;
|
||||||
|
|
||||||
[ test-serialize ] test-sqlite
|
[ test-serialize ] test-sqlite
|
||||||
[ test-serialize ] test-postgresql
|
! [ test-serialize ] test-postgresql
|
||||||
|
|
||||||
TUPLE: exam id name score ;
|
TUPLE: exam id name score ;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
USING: arrays assocs classes db kernel namespaces
|
USING: arrays assocs classes db kernel namespaces
|
||||||
tuples words sequences slots math
|
tuples words sequences slots math
|
||||||
math.parser io prettyprint db.types continuations
|
math.parser io prettyprint db.types continuations
|
||||||
mirrors sequences.lib tools.walker combinators.lib ;
|
mirrors sequences.lib tools.walker combinators.lib
|
||||||
|
combinators.cleave ;
|
||||||
IN: db.tuples
|
IN: db.tuples
|
||||||
|
|
||||||
: define-persistent ( class table columns -- )
|
: define-persistent ( class table columns -- )
|
||||||
|
@ -73,6 +74,9 @@ HOOK: insert-tuple* db ( tuple statement -- )
|
||||||
: drop-table ( class -- )
|
: drop-table ( class -- )
|
||||||
drop-sql-statement [ execute-statement ] with-disposals ;
|
drop-sql-statement [ execute-statement ] with-disposals ;
|
||||||
|
|
||||||
|
: ensure-table ( class -- )
|
||||||
|
[ dup drop-table ] ignore-errors create-table ;
|
||||||
|
|
||||||
: insert-native ( tuple -- )
|
: insert-native ( tuple -- )
|
||||||
dup class
|
dup class
|
||||||
db get db-insert-statements [ <insert-native-statement> ] cache
|
db get db-insert-statements [ <insert-native-statement> ] cache
|
||||||
|
|
Loading…
Reference in New Issue