From 91a1b1680793dee8ead96feb8156ce1e986d33b7 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 20 Dec 2019 17:50:10 -0800 Subject: [PATCH] show & change af files type and aux --- src/inc/fileio.plh | 1 + src/libsrc/apple/fileio.pla | 30 ++++++++++- src/libsrc/cat.pla | 16 +++--- src/libsrc/type.pla | 103 +++++++++++++++++++++--------------- src/makefile | 7 ++- src/mkrel | 1 + 6 files changed, 103 insertions(+), 55 deletions(-) diff --git a/src/inc/fileio.plh b/src/inc/fileio.plh index ba7ee72..2dd87b1 100644 --- a/src/inc/fileio.plh +++ b/src/inc/fileio.plh @@ -37,6 +37,7 @@ import fileio word getpfx word setpfx word getfileinfo + word setfileinfo word geteof word iobufalloc word open diff --git a/src/libsrc/apple/fileio.pla b/src/libsrc/apple/fileio.pla index d074c6a..0060c2a 100644 --- a/src/libsrc/apple/fileio.pla +++ b/src/libsrc/apple/fileio.pla @@ -26,6 +26,7 @@ struc t_fileio word getpfx word setpfx word getfileinfo + word setfileinfo word geteof word iobufalloc word open @@ -40,14 +41,14 @@ struc t_fileio word readblock word writeblock end -predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2iobufs(iobufs), a2open(path), a2close(refnum) +predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum), a2iobufs(iobufs), a2open(path), a2close(refnum) predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path), a23rename(path, newpath) predef a2newline(refnum, emask, nlchar), a2online(unit, buf), a2readblock(unit, buf, block), a2writeblock(unit, buf, block) // // Exported function table. // word fileio[] -word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a23geteof, @a2iobufs, @a2open, @a2close +word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2setfileinfo, @a23geteof, @a2iobufs, @a2open, @a2close word = @a23read, @a2write, @a2create, @a23destroy, @a23rename word = @a2newline, @a2online, @a2readblock, @a2writeblock // @@ -119,6 +120,29 @@ def a3getfileinfo(path, fileinfo) perr = syscall($C4, @params) return perr end +def a1setfileinfo(path, fileinfo) + perr = $01 + return perr +end +def a2setfileinfo(path, fileinfo) + byte params[14] + + params.0 = 7 + params:1 = path + memcpy(@params + 3, fileinfo, 11) + perr = syscall($C3, @params) + return perr +end +def a3setfileinfo(path, fileinfo) + byte params[6] + + params.0 = 3 + params:1 = path + params:3 = fileinfo + params.5 = 15 + perr = syscall($C3, @params) + return perr +end def a1geteof(refnum) return 0 end @@ -427,6 +451,7 @@ when MACHID & MACHID_MODEL is MACHID_III fileio:getpfx = @a3getpfx fileio:getfileinfo = @a3getfileinfo + fileio:setfileinfo = @a3setfileinfo fileio:iobufalloc = @a13iobufs fileio:open = @a3open fileio:close = @a3close @@ -441,6 +466,7 @@ when MACHID & MACHID_MODEL fileio:getpfx = @a1getpfx fileio:setpfx = @a1setpfx fileio:getfileinfo = @a1getfileinfo + fileio:setfileinfo = @a1setfileinfo fileio:geteof = @a1geteof fileio:iobufalloc = @a13iobufs fileio:open = @a1open diff --git a/src/libsrc/cat.pla b/src/libsrc/cat.pla index fd10654..3c01efe 100644 --- a/src/libsrc/cat.pla +++ b/src/libsrc/cat.pla @@ -72,16 +72,16 @@ if refnum if ^entry printentry() filecnt-- + // + // Pause display every screenfull + // + page++ + if page == 23 + getc + page = 0 + fin fin entry = entry + entrylen - // - // Pause display every screenfull - // - page++ - if page == 23 - getc - page = 0 - fin next firstblk = 0 fin diff --git a/src/libsrc/type.pla b/src/libsrc/type.pla index 10ac895..799f9f7 100644 --- a/src/libsrc/type.pla +++ b/src/libsrc/type.pla @@ -3,59 +3,40 @@ include "inc/args.plh" include "inc/fileio.plh" char[64] filename -var arg +res[t_fileinfo] fileinfo +var arg, type, aux // // Convert byte to two hex chars // -def btoh(cptr, b)#0 - byte h - +def putb(b)#0 + char h + h = ((b >> 4) & $0F) + '0' if h > '9' h = h + 7 fin - ^cptr = h - cptr++ + putc(h) h = (b & $0F) + '0' if h > '9' h = h + 7 fin - ^cptr = h + putc(h) end -// -// Check filename -// -def checkfile - var refnum, dirbuf - res[t_fileinfo] fileinfo - - // - // Check if file exists - // - if fileio:getfileinfo(@filename, @fileinfo) == FILE_ERR_OK - // - // Check if deleting a directory - // - if fileinfo.file_type == $0F - refnum = fileio:open(@filename) - if refnum - // - // Check for files inside directory - // - dirbuf = heapalloc(512) - if fileio:read(refnum, dirbuf, 512) == 512 - fileio:close(refnum) - if dirbuf=>$25 // File count in directory - puts("Directory not empty: "); puts(@filename); putln - return FALSE - fin - fin - fin +def htoi(hexptr) + var val, i, n + + val = 0 + for i = 1 to ^hexptr + n = toupper(^(hexptr + i)) - '0' + if n > 9 + n = n - 7 fin - return TRUE - fin - puts("File not found: "); puts(@filename); putln - return FALSE + if n > 15 or n < 0 + return val + fin + val = (val << 4) + n + next + return val end // // Check arguments and file types @@ -71,12 +52,46 @@ if ^arg // Check if re-typing a directory // if fileinfo.file_type <> $0F + // + // Check for optional overrides + // + arg = argNext(arg) + if ^arg + type = htoi(arg) + if type > 255 + puts("TYPE value out of range\n") + return + fin + // + // Can't change something into directory + // + if type <> $0F + fileinfo.file_type = type + arg = argNext(arg) + if ^arg + aux = htoi(arg) + fileinfo:aux_type = aux + fin + // + // Update file type and aux values + // + if fileio:setfileinfo(@filename, @fileinfo) == FILE_ERR_OK + if fileio:getfileinfo(@filename, @fileinfo) <> FILE_ERR_OK + puts("Unable to reload file info: "); puts(@filename) + fin + else + puts("Unable to change TYPE & AUX values: "); puts(@filename) + return + fin + fin + fin + else + puts("Unable to get file info: "); puts(@filename); putln fin fin - // - // Close all files - // - fileio:close(0) + puts(@filename); putc(':') + putc('$'); putb(fileinfo.file_type); putc(' ') + putc('$'); puth(fileinfo:aux_type); putln return fin puts("Usage: +TYPE FILE [HEXTYPE [HEXAUX]]\n") diff --git a/src/makefile b/src/makefile index efe8a7f..ec34786 100755 --- a/src/makefile +++ b/src/makefile @@ -23,6 +23,7 @@ DEL = rel/DEL\#FE1000 REN = rel/REN\#FE1000 CAT = rel/CAT\#FE1000 NEWDIR = rel/NEWDIR\#FE1000 +TYPE = rel/TYPE\#FE1000 SIEVE = rel/SIEVE\#FE1000 PRIMEGAP = rel/PRIMEGAP\#FE1000 ARGS = rel/ARGS\#FE1000 @@ -95,7 +96,7 @@ TXTTYPE = .TXT #SYSTYPE = \#FF2000 #TXTTYPE = \#040000 -apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ) +apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(GRAFIX) $(GFXDEMO) $(LINESPANS) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ) -rm vmsrc/plvmzp.inc @@ -434,6 +435,10 @@ $(NEWDIR): libsrc/newdir.pla $(PLVM03) $(PLASM) ./$(PLASM) -AMOW < libsrc/newdir.pla > libsrc/newdir.a acme --setpc 4094 -o $(NEWDIR) libsrc/newdir.a +$(TYPE): libsrc/type.pla $(PLVM03) $(PLASM) + ./$(PLASM) -AMOW < libsrc/type.pla > libsrc/type.a + acme --setpc 4094 -o $(TYPE) libsrc/type.a + $(SOS): libsrc/apple/sos.pla $(PLVM03) $(PLASM) ./$(PLASM) -AMOW < libsrc/apple/sos.pla > libsrc/apple/sos.a acme --setpc 4094 -o $(SOS) libsrc/apple/sos.a diff --git a/src/mkrel b/src/mkrel index 57cc74b..a1eef8d 100755 --- a/src/mkrel +++ b/src/mkrel @@ -17,6 +17,7 @@ cp rel/DEL#FE1000 prodos/sys/DEL.REL cp rel/REN#FE1000 prodos/sys/REN.REL cp rel/CAT#FE1000 prodos/sys/CAT.REL cp rel/NEWDIR#FE1000 prodos/sys/NEWDIR.REL +cp rel/TYPE#FE1000 prodos/sys/TYPE.REL cp rel/ARGS#FE1000 prodos/sys/ARGS.REL cp rel/ED#FE1000 prodos/sys/ED.REL cp rel/FIBER#FE1000 prodos/sys/FIBER.REL