Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cuae2!ihnp4!ptsfa!lll-lcc!pyramid!oliveb!sun!cmcmanis From: cmcmanis@sun.UUCP Newsgroups: comp.sys.amiga Subject: Getting the Volume Name Message-ID: <13256@sun.uucp> Date: Fri, 13-Feb-87 04:31:34 EST Article-I.D.: sun.13256 Posted: Fri Feb 13 04:31:34 1987 Date-Received: Sat, 14-Feb-87 15:22:05 EST Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 51 Keywords: Volume, AmigaDOS Locks Recently someone asked how to get the volume name that a given file resided on. The following code will do just that in a supported and nice kind of way. It only needs the FileLock to work. --Chuck ----snip here----- /* GetVolume.c -- Written 02/13/87 by Chuck McManis feel free to use it * * This simple Program can be used to get the Volume name for a given file. * Works on any device, even the RAM: device. * * Note: The BADDR macro is in the dos.h file */ #include #include #include #include void main() { char VolumeName[40], FileName[80], *MyVolume; struct FileLock *MyLock; printf("Enter a file name :"); gets(FileName); /* Simultaneous get a lock and convert BPTR to a C pointer */ MyLock = (struct FileLock *)BADDR(Lock(FileName,ACCESS_READ)); if (MyLock == NULL) { printf("File could not be found!\n"); exit(20); /* Die appropriately on failure */ } /* This next statement chases the BCPL pointers thru a FileLock and * * DeviceList structures */ MyVolume = (char *) BADDR(((struct DeviceList *)BADDR(MyLock->fl_Volume))->dl_Name); /* Lattice V3.10 function to copy a string and Null terminate it */ stccpy(VolumeName,MyVolume+1,MyVolume[0]+1); printf("That file resides on Volume '%s' \n",VolumeName); UnLock(((long)MyLock) >> 2); /* You must UnLock or the GURU visits */ exit(0); } -- --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.