Subversion Repositories Spectranet

[/] [trunk/] [modules/] [basext/] [copy.asm] - Diff between revs 440 and 442

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 440 Rev 442
Line 24... Line 24...
 
 
.include        "defs.inc"
.include        "defs.inc"
.include        "fcntl.inc"
.include        "fcntl.inc"
.include        "spectranet.inc"
.include        "spectranet.inc"
.include        "stat.inc"
.include        "stat.inc"
 
.include        "errno.inc"
 
 
;------------------------------------------------------------------------
;------------------------------------------------------------------------
; F_copy expects the destination filename in WORKSPACE and the
; F_copy expects the destination filename in WORKSPACE and the
; source in WORKSPACE+256.
; source in WORKSPACE+256.
.globl F_copy
.globl F_copy
Line 39... Line 40...
        jr c, .trytocopy        ; non-existent destination, that's OK, it
        jr c, .trytocopy        ; non-existent destination, that's OK, it
                                ; might be specifying a file that's
                                ; might be specifying a file that's
                                ; not yet been created.
                                ; not yet been created.
        ld a, (INTERPWKSPC+512+STAT_MODE+1)
        ld a, (INTERPWKSPC+512+STAT_MODE+1)
        and S_IFDIR / 256       ; check directory flag
        and S_IFDIR / 256       ; check directory flag
        jr z, .trytocopy        ; not a dir, try to overwrite the file
        jr nz, .catdir
 
 
 
        ; If the destination is a file, we'll not overwrite it (this avoids
 
        ; having to compare paths to test for file being copied onto itself
 
        ; at the expense of not being able to use the copy command to
 
        ; overwrite a file).
 
        ld a, EEXIST
 
        scf
 
        ret
 
 
 
.catdir:
        ld hl, INTERPWKSPC+256  ; source filename
        ld hl, INTERPWKSPC+256  ; source filename
        call F_basename         ; HL now points at the file name
        call F_basename         ; HL now points at the file name
        ex de, hl               ; move into DE for the catpath call
        ex de, hl               ; move into DE for the catpath call
        ld hl, INTERPWKSPC      ; destination directory
        ld hl, INTERPWKSPC      ; destination directory
        call F_catpath
        call F_catpath