comparison CoCoOS9/level2v3/CMDS/makdir.asm @ 31:bd2b07db8917 cocoos9lv2v3

CoCoOS9 version
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Jul 2018 15:16:13 +0900
parents
children
comparison
equal deleted inserted replaced
30:7b1b25ff010a 31:bd2b07db8917
1 ********************************************************************
2 * MakDir - create directories
3 *
4 * $Id: makdir.asm,v 1.1.1.1 2001/02/21 23:30:54 boisy Exp $
5 *
6 * Ed. Comments Who YY/MM/DD
7 * ------------------------------------------------------------------
8 * 5 Makes multiple directories from a single ADK
9 * pathlist (i.e. foo/bar/bar2)
10
11 nam Makdir
12 ttl program module
13
14 * Disassembled 94/12/08 21:42:56 by Alan DeKok
15
16 ifp1
17 use defsfile
18 endc
19
20 tylg set Prgrm+Objct
21 atrv set ReEnt+rev
22 rev set $01
23 edition set 5
24
25 mod eom,name,tylg,atrv,start,size
26
27 Param rmb 2 parameter area
28 MFlag rmb 1 made a directory yet from this pathlist?
29 rmb 200 stack space
30 size equ .
31
32 name fcs /MakDir/
33 fcb edition
34
35 Sk.1 leax 1,x go on to the next character
36 Skip lda ,x get a character
37 cmpa #C$SPAC space?
38 beq Sk.1 if so, skip it
39 rts
40
41 * Any pathnames at all?
42 * Exit with error if none
43 Start bsr Skip skip the first bit, if applicable
44 cmpa #C$SPAC is it a CR?
45 bne start2 no, go ahead and make directories
46 comb set carry
47 ldb #E$BPNam a CR is a bad pathname...
48 bra Exit and go exit
49
50 * skip leading spaces or '/' and setup pointers
51 start1 bsr Skip skip any non-zero characters, if applicable
52 start2 ldb #$FF a non-zero value
53 stb <MFlag we haven't made a directory from this pathname yet
54 stx <Param save in the parameter area
55 cmpa #PDELIM leading slash?
56 bne S.020 if not, go get the name
57
58 * find the pseudo-end of the pathname, stopping at space, cr, '/'
59 S.010 leax 1,x
60 S.020 lda ,x
61 cmpa #C$SPAC space?
62 beq S.030
63 cmpa #C$CR cr?
64 beq S.030
65 cmpa #PDELIM slash?
66 bne S.010 if none of these, then skip this character
67
68 * force the pathname to be a subset of the full pathname
69 S.030 pshs a,x save byte found, where we found it
70 lda #C$CR force it to be a CR
71 sta ,x
72
73 *try to open it for reading, i.e. does it already exists?
74 ldx <Param get the start address of this pathname
75 lda #DIR.+READ. open the directory for reading
76 os9 I$Open check if the directory already exists
77 bcs S.040 if there was an error opening it, go make it
78 OS9 I$Close close the path to the file
79 bra S.050 skip making this directory
80
81 * The partial pathname doesn't exist, so create it
82 S.040 ldx <Param get the start address of this pathname
83 ldb #^SHARE. everything but SHARE.
84 os9 I$MakDir
85 bcs Error
86 clr <MFlag clear the flag: we've successfully made a directory
87
88 * make pathname full again, and continue
89 S.050 puls a,x restore byte, address
90 sta ,x restore it
91 cmpa #PDELIM was it a slash?
92 beq S.010 yes, make pathname full again, and find next one
93
94 * searched this pathname, have we made a directory from it?
95 tst <MFlag have we made a directory?
96 bne CEF if not, error out with fake E$CEF
97
98 * check for end/continue flag
99 cmpa #C$SPAC was it a space?
100 beq start1 yup, go get another pathname to create
101
102 ClnExit clrb no error
103 Exit OS9 F$Exit and exit
104
105 CEF comb set carry
106 ldb #E$CEF we've just tried to create an existing file
107 Error pshs b,cc save error code
108
109 lda #2 to STDERR
110 leax EMsg,pc to error found string
111 ldy #Elen
112 OS9 I$Write
113
114 ldx <param get pathname we're trying to open
115 ldy #200 a _very_ long pathname
116 OS9 I$WritLn we're sure that the name ends in a CR...
117 puls b,cc restore error code, condition
118 bra Exit
119
120 EMsg fcc /makdir: error creating /
121 ELen equ *-EMsg
122
123 emod
124 eom equ *
125 end