bryce@COGSCI.BERKELEY.EDU (Bryce Nesbitt) (05/25/87)
In article <144@sugar.UUCP><3987> Peter da Silva typed: > [All this] bloats [mounted] up to 8K. A little tidying up can probably get > it down quite a bit. But it fits nicely in *my* c: directory and I'm > arrogant enough to think I have better things to do. Well, *my* C: directory did not have space for this handy item. I've now deleted very last scrap of extra space from my WB1.2:. I even passed all the execuatables past BLINK to strip EMPTY and SYMBOL hunks. The only thing left to do was code it in 68000. My version is a bit less flexible, it is a CLI command and is not useful to the workbench. The executable comes to 152 bytes. If you want to see the entire scoop of what mounted returns, use the "WHY" command I posted a while back. The source shows a way to use the pr_WindowPtr to good effect. ---- cut here for executable ---- begin 777 mounted M```#\P`````````!```````````````=```#Z0```!U",`#_?@4F2"QX``1#J M^@!"3J[^:"I`D\E.KO[:*$`L+`"X</\I0`"X(@MT_BQ-3J[_K$J`9P@B`$ZN6 M_Z9^`"E&`+@B32QX``1.KOYB(`=.=61O<RYL:6)R87)Y`"A#*3$Y.#<@0G)Y* 18V4@3F5S8FET=````````_)B8 `` end ---- cut here for source ---- ;MOUNTED Copyright 1987 Bryce Nesbitt. Revokable licence hereby granted for ;any entity to use or absue this code in any way they see fit provided that ;such entity, in the judgement of the author: ;1> Retains this and any other Copyright notices. ;2> Is paid up on any monetary imbalance with author. ;3> Does not have unjustified litigation pending against author. ;Please tell me about any enhacements,changes,bugs or brain-damage in this ;code. bryce@hoser.berkeley.EDU -or- bryce@cogsci.berkeley.EDU ;Bryce Nesbitt 1712 Marin Ave. Berkeley, Ca 94707-2206 ;Some inspirational assistence by Peter da Silva. ; ;FUNCTION: ; MOUNTED can determind if a volume or file is on-line. It may be used ;for conditional execution in a command file. If returns OK if the path ;is present, or WARN if it is not. It does the test "quietly" without ;bringing up a requester. ; ;FAIL means serious error, like no DOS or memory ;ERROR is less fatal, maybe syntax or "file not found" for a TYPE command. ;WARN is used for things like "file not found" on a DELETE or here in ; MOUNTED. Also used by TYPE when <CTRL><C> is hit. ; ;EXAMPLE: ; mounted assem:c ; if not warn ; echo #27 "[43m" ; path assem:c ; endif ; ;BUGS: ; Because I use the parser code from the ARP.LIBRARY, which I cannot yet ;distribute, no parsing of the line is done. The entire input line will be ;used, spaces, quotes and all. ; It would be nice to be able to determine if a physical device such as ;DF0: is present. As it stands MOUNTED will return a WARN if a connected ;drive is present, but empty. There are better ways of attaining this ;function than adding a kludge to MOUNTED. ; The executable is 152 bytes long when assembled with METACOMCO 10.178 ;and linked using BLINK 6.5 with the NODEBUG option enabled. *********************** NOLIST ;INCLUDE 'lib/exec_lib.i' ;INCLUDE 'lib/dos_lib.i' INCLUDE 'exec/ables.i' INCLUDE 'libraries/dosextens.i' LIST jsrlib MACRO XREF _LVO\1 jsr _LVO\1(a6) ENDM jmplib macro XREF _LVO\1 jmp _LVO\1(a6) ENDM blink MACRO bchg.b #1,$bfe001 ENDM *********************** DOSBase equr a5 MyProcess equr a4 LinePointer equr a3 returncode equr d7 WindowSave equr d6 CODE startup: clr.b -1(a0,d0) ;cheap way to NULL terminate moveq #5,returncode ;default WARN condition move.l a0,LinePointer move.l 4,a6 lea DOSName(pc),a1 jsrlib OldOpenLibrary ;V1.0 Compatible move.l d0,DOSBase ;Look ma, no error check! suba.l a1,a1 jsrlib FindTask ;Process, really move.l d0,MyProcess ;-- Report errors "quietly" -- move.l pr_WindowPtr(MyProcess),WindowSave moveq #-1,d0 move.l d0,pr_WindowPtr(MyProcess) ;-- Attempt lock -- move.l LinePointer,d1 moveq #ACCESS_READ,d2 move.l DOSBase,a6 jsrlib Lock ;Attempt lock tst.l d0 beq.s NoLock ;Can't find it, exit code 10 move.l d0,d1 jsrlib UnLock moveq #0,returncode ;It's there, return zero ;-- Restore environment / "noisy" errors -- NoLock: move.l WindowSave,pr_WindowPtr(MyProcess) move.l DOSBase,a1 move.l 4,a6 jsrlib CloseLibrary move.l returncode,d0 rts DOSName: dc.b 'dos.library',0 dc.b '(C)1987 Bryce Nesbitt' END ---- cut your wrists for death --- Ack! (NAK,EOT,SOH) |\ /| . {o O} . bryce@cogsci.berkeley.EDU -or- ucbvax!cogsci!bryce ( " ) U Single tasking? Just say *NO!*