Hi factorers!
I want to use my factored "file-copier" in my MS vista, but when I
deploy with the deploy-tool, it aborts (die was called by library...
please report), and the listener hangs.
Can someone tell if can get exe from this source?

thanks,
michele pes

USING:  kernel math sequences accessors namespaces
        io io.files io.files.info io.pathnames ;
FROM: io.encodings.binary => binary ;
FROM: math.parser => number>string ;
FROM: io.backend => normalize-path ;
FROM: destructors => dispose ;
FROM: continuations => recover ;
FROM: system => exit ;
FROM: ascii => ch>upper ;
FROM: command-line => command-line ;

IN: file-copier

SYMBOLS: g-source g-destination g-is g-os g-block ret-val ;
CONSTANT: BUF_SIZE 32768


: write-banner ( -- )
    g-source get write " -> " write
    g-destination get write ; inline


: open-source? ( -- ? )
    [ g-source get binary <file-reader> g-is set t ]
    [ nl g-source get write ": " write write f ] recover ;


: must-overwrite? ( -- ? )
    g-destination get exists?
    [
        nl "Overwrite ? [Y/?] " write
        read1 ch>upper CHAR: Y =
        [ t ] [ "Aborted." write f ] if
    ]
    [ t ]
    if ;


: enough-space? ( -- ? )
    g-source get file-info size-on-disk>>
    g-destination get file-system-info free-space>>
    <=
    dup [ nl "Not Enough Space." write ] unless ;


: open-destination? ( -- ? )
    [ g-destination get binary <file-writer> g-os set t ]
    [ g-destination get write ": " write write f ]
    recover ;


: core-io ( -- n )
    0 ret-val set
    [
        [ BUF_SIZE g-is get stream-read g-block set ]
        [
            nl g-source get write ": " write write
            2 ret-val set
        ]
        recover

        ret-val get zero? g-block get f = not and
        [
            [ g-block get g-os get stream-write t ]
            [ nl g-destination get write ": " write write f ]
            recover
        ]
        [ f ]
        if
    ]
    loop
    ret-val get ;


: copy ( -- n )
    write-banner
    open-source?
    [
        must-overwrite?
        [
            enough-space?
            [
                open-destination?
                [ core-io g-os get dispose ] [ 3 ] if
            ]
            [ 3 ]
            if
        ]
        [ 0 ] if
        g-is get dispose
    ]
    [ 2 ]
    if ;



: main ( -- )
"File copier by Mike P. '81" print nl

command-line get
dup length dup 1 = swap 2 = or
[
    dup first g-source set
    dup length 1 =
    [ g-source get file-name g-destination set ]
    [ dup second g-destination set ]
    if

    g-source get normalize-path
    g-destination get normalize-path
    =
    [ "Source and Dest are the same file." write 3 exit ]
    [
        g-destination get dup exists?
        [
            file-info directory?
            [
                g-destination get g-source get file-name
                append-path g-destination set
            ]
            when
        ] when
        copy exit
    ]
    if
]
[ drop "Enter: copy <src> [dst] " write 1 exit ]
if ;

MAIN: main
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to