mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-20 18:31:13 +00:00
Place common routine into matchfiles
This commit is contained in:
parent
ec629745f9
commit
f8a6589f34
src
@ -2,4 +2,5 @@ import matchfiles
|
||||
predef matchName(src, exp)#1
|
||||
predef matchList(pathptr, exp)#2
|
||||
predef isWildName(exp)#1
|
||||
predef fileFromPath(filestr, pathstr)#0
|
||||
end
|
||||
|
@ -113,4 +113,18 @@ export def isWildName(exp)#1
|
||||
fin
|
||||
return FALSE
|
||||
end
|
||||
//
|
||||
// Utility routine to separate filename from path
|
||||
//
|
||||
export def fileFromPath(filestr, pathstr)#0
|
||||
byte i
|
||||
|
||||
for i = ^pathstr downto 1
|
||||
if pathstr->[i] == '/'
|
||||
break
|
||||
fin
|
||||
next
|
||||
^filestr = ^pathstr - i
|
||||
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
|
||||
end
|
||||
done
|
||||
|
@ -485,11 +485,11 @@ $(MON): utilsrc/apple/mon.pla $(PLASM)
|
||||
./$(PLASM) -AMOW < utilsrc/apple/mon.pla > utilsrc/apple/mon.a
|
||||
acme --setpc 4094 -o $(MON) utilsrc/apple/mon.a
|
||||
|
||||
$(COPY): utilsrc/apple/copy.pla $(PLASM)
|
||||
$(COPY): utilsrc/apple/copy.pla $(MATCHFILES) $(PLASM)
|
||||
./$(PLASM) -AMOW < utilsrc/apple/copy.pla > utilsrc/apple/copy.a
|
||||
acme --setpc 4094 -o $(COPY) utilsrc/apple/copy.a
|
||||
|
||||
$(DEL): utilsrc/apple/del.pla $(PLASM)
|
||||
$(DEL): utilsrc/apple/del.pla $(MATCHFILES) $(PLASM)
|
||||
./$(PLASM) -AMOW < utilsrc/apple/del.pla > utilsrc/apple/del.a
|
||||
acme --setpc 4094 -o $(DEL) utilsrc/apple/del.a
|
||||
|
||||
@ -497,7 +497,7 @@ $(REN): utilsrc/apple/ren.pla $(PLASM)
|
||||
./$(PLASM) -AMOW < utilsrc/apple/ren.pla > utilsrc/apple/ren.a
|
||||
acme --setpc 4094 -o $(REN) utilsrc/apple/ren.a
|
||||
|
||||
$(CAT): utilsrc/apple/cat.pla $(PLASM)
|
||||
$(CAT): utilsrc/apple/cat.pla $(MATCHFILES) $(PLASM)
|
||||
./$(PLASM) -AMOW < utilsrc/apple/cat.pla > utilsrc/apple/cat.a
|
||||
acme --setpc 4094 -o $(CAT) utilsrc/apple/cat.a
|
||||
|
||||
|
@ -12,23 +12,6 @@ char[64] path, wildname
|
||||
res[t_fileinfo] fileinfo
|
||||
res[t_fileentry] fileentry
|
||||
//
|
||||
// Convert byte to two hex chars
|
||||
//
|
||||
def putb(b)#0
|
||||
char h
|
||||
|
||||
h = ((b >> 4) & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
putc(h)
|
||||
h = (b & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
putc(h)
|
||||
end
|
||||
//
|
||||
// Copy string with upper case conversion
|
||||
//
|
||||
def struprcpy(dst, src)#0
|
||||
@ -46,23 +29,12 @@ def struprcpy(dst, src)#0
|
||||
fin
|
||||
^dst = ^src
|
||||
end
|
||||
def filefrompath(filestr, pathstr)#0
|
||||
byte i
|
||||
|
||||
for i = ^pathstr downto 1
|
||||
if pathstr->[i] == '/'
|
||||
break
|
||||
fin
|
||||
next
|
||||
^filestr = ^pathstr - i
|
||||
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
|
||||
end
|
||||
//
|
||||
// Print out a directory entry
|
||||
//
|
||||
def printentry(entryptr)#0
|
||||
char type, pad, eofstr[12]
|
||||
|
||||
|
||||
puts(entryptr)
|
||||
when entryptr->entry_type
|
||||
is $0F // Is it a directory?
|
||||
@ -88,12 +60,12 @@ def printentry(entryptr)#0
|
||||
for pad = eofstr to 9
|
||||
putc(' ')
|
||||
next
|
||||
puts(@eofstr)
|
||||
puts(@eofstr)
|
||||
putln
|
||||
end
|
||||
def printentries(pathstr, entries, num)#0
|
||||
byte page
|
||||
|
||||
|
||||
puts(pathstr); putln
|
||||
puts("=NAME==========TYPE===AUX====LENGTH=\n")
|
||||
page = 20
|
||||
|
@ -67,17 +67,6 @@ def pathdiff(path1, path2)#1
|
||||
next
|
||||
return FALSE
|
||||
end
|
||||
def filefrompath(filestr, pathstr)#0
|
||||
byte i
|
||||
|
||||
for i = ^pathstr downto 1
|
||||
if pathstr->[i] == '/'
|
||||
break
|
||||
fin
|
||||
next
|
||||
^filestr = ^pathstr - i
|
||||
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
|
||||
end
|
||||
//
|
||||
// Check destination path
|
||||
//
|
||||
@ -115,7 +104,7 @@ def copyfiles(srcfile, dstfile)#0
|
||||
strcpy(@srcpath, srcfile)
|
||||
wildname = 0
|
||||
if fileio:getfileinfo(@srcpath, @srcfileinfo) <> FILE_ERR_OK or (srcfileinfo.storage_type & $0D <> $0D)
|
||||
filefrompath(@wildname, @srcpath)
|
||||
fileFromPath(@wildname, @srcpath)
|
||||
srcpath = srcpath - wildname
|
||||
fin
|
||||
entrylist, entrycnt = matchList(@srcpath, @wildname)
|
||||
|
@ -25,17 +25,6 @@ def struprcpy(dst, src)#0
|
||||
fin
|
||||
^dst = ^src
|
||||
end
|
||||
def filefrompath(filestr, pathstr)#0
|
||||
byte i
|
||||
|
||||
for i = ^pathstr downto 1
|
||||
if pathstr->[i] == '/'
|
||||
break
|
||||
fin
|
||||
next
|
||||
^filestr = ^pathstr - i
|
||||
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
|
||||
end
|
||||
//
|
||||
// Check filename
|
||||
//
|
||||
@ -81,9 +70,8 @@ def delfiles(delfile)#0
|
||||
|
||||
strcpy(@delpath, delfile)
|
||||
wildname = 0
|
||||
//if fileio:getfileinfo(@delpath, @fileinfo) <> FILE_ERR_OK or fileinfo.file_type <> $0F
|
||||
if delpath[delpath] <> '/'
|
||||
filefrompath(@wildname, @delpath)
|
||||
fileFromPath(@wildname, @delpath)
|
||||
delpath = delpath - wildname
|
||||
fin
|
||||
//
|
||||
@ -115,7 +103,7 @@ def delfiles(delfile)#0
|
||||
fileio:destroy(@delfilepath)
|
||||
fin
|
||||
entry = entry + t_fileentry
|
||||
entrycnt--
|
||||
entrycnt--
|
||||
loop
|
||||
elsif not wildname
|
||||
puts("Not found: "); puts(@delpath); puts("/"); puts(@wildname); putln
|
||||
@ -156,7 +144,7 @@ if not except(exit)
|
||||
strcpy(@path,fileptr)
|
||||
strcat(@path, "/")
|
||||
delfiles(@path)
|
||||
fin
|
||||
fin
|
||||
delfiles(fileptr)
|
||||
fileptr = fileptr + ^fileptr + 1
|
||||
filecnt--
|
||||
|
@ -8,23 +8,23 @@ var arg, type, aux
|
||||
//
|
||||
// Convert byte to two hex chars
|
||||
//
|
||||
def putb(b)#0
|
||||
char h
|
||||
|
||||
h = ((b >> 4) & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
putc(h)
|
||||
h = (b & $0F) + '0'
|
||||
if h > '9'
|
||||
h = h + 7
|
||||
fin
|
||||
putc(h)
|
||||
end
|
||||
//def putb(b)#0
|
||||
// char h
|
||||
//
|
||||
// h = ((b >> 4) & $0F) + '0'
|
||||
// if h > '9'
|
||||
// h = h + 7
|
||||
// fin
|
||||
// putc(h)
|
||||
// h = (b & $0F) + '0'
|
||||
// if h > '9'
|
||||
// h = h + 7
|
||||
// fin
|
||||
// putc(h)
|
||||
//end
|
||||
def htoi(hexptr)
|
||||
var val, i, n
|
||||
|
||||
|
||||
val = 0
|
||||
for i = 1 to ^hexptr
|
||||
n = toupper(^(hexptr + i)) - '0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user