Fixed extra/webapps/imagebin vocab to increment path count correctly and added file detection.

db4
otoburb 2010-11-10 18:09:45 +00:00
parent cefb541c33
commit 0a8020c06b
1 changed files with 4 additions and 3 deletions

View File

@ -3,7 +3,8 @@
USING: accessors furnace.actions furnace.redirection USING: accessors furnace.actions furnace.redirection
html.forms http http.server http.server.dispatchers html.forms http http.server http.server.dispatchers
io.directories io.encodings.utf8 io.files io.pathnames io.directories io.encodings.utf8 io.files io.pathnames
kernel math.parser multiline namespaces sequences urls ; kernel math.parser multiline namespaces sequences urls
math ;
IN: webapps.imagebin IN: webapps.imagebin
TUPLE: imagebin < dispatcher path n ; TUPLE: imagebin < dispatcher path n ;
@ -14,13 +15,13 @@ TUPLE: imagebin < dispatcher path n ;
: next-image-path ( -- path ) : next-image-path ( -- path )
imagebin get imagebin get
[ path>> ] [ n>> number>string ] bi append-path ; [ path>> ] [ [ 1 + ] change-n n>> number>string ] bi append-path ;
M: imagebin call-responder* M: imagebin call-responder*
[ imagebin set ] [ call-next-method ] bi ; [ imagebin set ] [ call-next-method ] bi ;
: move-image ( mime-file -- ) : move-image ( mime-file -- )
next-image-path [ next-image-path dup exists? ] [ drop ] while
[ [ temporary-path>> ] dip move-file ] [ [ temporary-path>> ] dip move-file ]
[ [ filename>> ] dip ".txt" append utf8 set-file-contents ] 2bi ; [ [ filename>> ] dip ".txt" append utf8 set-file-contents ] 2bi ;