1;
2; Ullrich von Bassewitz, 2012-05-30
3;
4; Based on C code by Groepaz
5;
6; int __fastcall__ closedir(DIR *dir);
7;
8
9
10        .include        "dir.inc"
11        .include        "zeropage.inc"
12
13        .import         _close, _free
14
15
16.proc   _closedir
17
18        sta     ptr1
19        stx     ptr1+1
20
21; Load dir->fd
22
23        ldy     #DIR::fd+1
24        lda     (ptr1),y
25        tax
26        dey
27        lda     (ptr1),y
28
29; Close the file
30
31        jsr     _close
32
33; Save the error code
34
35        pha
36        txa
37        pha
38
39; Free the memory block
40
41        lda     ptr1
42        ldx     ptr1+1
43        jsr     _free
44
45; Return the error code from close()
46
47        pla
48        tax
49        pla
50        rts
51
52.endproc
53
54