[comp.sys.amiga] Assign

keithd@cadovax.UUCP (Keith Doyle) (10/14/87)

Hi gang,

Does anyone out there have any idea how to find out (from 'C')
if something in particular is in the 'Assign' table?  I want to
find out if a file exists using an Assign foo: wherever, and by
referencing the file as foo:filename.  If either the file does
not exist, or the foo: has never been assigned, is what I want
to find out from my program.  Unfortunately, if foo: has not
been assigned, what I get is a requester that says 'insert
foo: in any drive' which is not what I want.  If it is not
in the Assign table, I want to assume that it does not
exist.

Any ideas?  I'd prefer not to do an   Execute("Assign >ram:tmp",0,0);
followed by an investigation of ram:tmp.  Yuk!

Keith Doyle
#  {ucbvax,decvax}!trwrb!cadovax!keithd  Contel Business Systems 213-323-8170

higgin@cbmvax.UUCP (Paul Higginbottom SALES) (10/15/87)

in article <1799@cadovax.UUCP>, keithd@cadovax.UUCP (Keith Doyle) says:
> Does anyone out there have any idea how to find out (from 'C')
> if something in particular is in the 'Assign' table?  I want to
> find out if a file exists using an Assign foo: wherever, and by
> referencing the file as foo:filename.  If either the file does
> not exist, or the foo: has never been assigned, is what I want
> to find out from my program.  Unfortunately, if foo: has not
> been assigned, what I get is a requester that says 'insert
> foo: in any drive' which is not what I want.  If it is not
> in the Assign table, I want to assume that it does not
> exist.
> Keith Doyle

Turn off requesters by setting your Process' pr_WindowPtr (I seem to recall,
been a while) to -1L (or was it 0L?) and restoring it after.  Then you can
try locking foo, and DOS will give you the error code (if foo is no good)
without bringing up the requester.

Sorry for the sloppiness of this message.
Haven't had my morning coffee...
                                ..
                                  .

                                   .


	Paul.

cmcmanis%pepper@Sun.COM (Chuck McManis) (10/15/87)

In article <1799@cadovax.UUCP> keithd@cadovax.UUCP (Keith Doyle) writes:
>
>Hi gang,
>Does anyone out there have any idea how to find out (from 'C')
>if something in particular is in the 'Assign' table?  I want to
>find out if a file exists using an Assign foo: wherever, and by
>referencing the file as foo:filename.  If either the file does
>not exist, or the foo: has never been assigned, is what I want
>to find out from my program.  Unfortunately, if foo: has not
>been assigned, what I get is a requester that says 'insert
>foo: in any drive' which is not what I want.  If it is not
>in the Assign table, I want to assume that it does not
>exist.

Yes, I have an idea on how it works. :-) Actually, assignments are 
stored in the link list of DeviceList structures that are pointed to
by DevInfo in the root structure. Assigns have type DLT_DIRECTORY, there
are also entries for devices (DLT_DEVICE) and volumes (DLT_VOLUME). Look
at the code in my Assign.c program on Fish Disk 52, or the 'Assigned' 
program source on disk 66. Note that the assign.c on 52 does not do
memory allocations correctly and therefore conflicts with the 'real'
assign command. That has been fixed in the arp version, basically DOS 
puts the length of a memory allocation as a long word in front of the block 
of memory. My original assign did not do this. So for references see the
include file <libraries/filehandler.h> for the DeviceList struct and 
<libraries/dosextens.h> for the root structure definition. The manual
AmigaDOS Technical Reference has a discussion on how to find the root node,
or you can use the code in assign.c. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

peter@sugar.UUCP (Peter da Silva) (10/18/87)

In article <1799@cadovax.UUCP>, keithd@cadovax.UUCP (Keith Doyle) writes:
> Does anyone out there have any idea how to find out (from 'C')
> if something in particular is in the 'Assign' table?

Look at the file VolList.c that was in both the STDFILE and INSTANT APPLICATION
postings. Or wait for Mike Meyers to do his stuff and do and Examine on DEV:.
Probably diddling with my code would be a bit more transportable for now, even
though it gets sinfully close to AmigaDOS internals.
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.