#Workbench Args
1 messages in this thread
I'm writing a program which I want to interface with Workbench. I am
working on the routines to parse the Workbench arguments and I've run into
a snag. I need to get the full directory path to any project files that
were 'extend-clicked'. Using the Libraries and Devices manual and an
Amiga Transactor article by Rob Peck I've determined to call the AmigaDOS
library command CurrentDir() with the file lock supplied in the WBArg
struct, and then use the C function getcwd() to get the directory.
However, this doesn't seem work always. If all the files are in the same
directory it works fine. But, if the tool is in one directory and the
project is in another I don't get the correct directories. Mostly, when I
get bad directories, I get the name of the volume that happens to be in
DF0:. The following is the function that I am using to get these
directories. It is called with a pointer to a WBArg struct, and a char *
to a destination buffer to hold the result.
void getwbarg(arg, dest)
struct WBArg *arg;
char *dest;
{
char temp[80];
char *c;
struct FileLock *oldlock;
/* make sure that lock isn't NULL */
if (!arg->wa_Lock)
{
strcpy(dest,arg->wa_Name);
return;
}
/* get the directory */
oldlock=CurrentDir(arg->wa_Lock);
dest[0]='\0';
getcwd(temp,sizeof(temp));
CurrentDir(oldlock);
if (temp[0]==':') strcat(dest,"RAM"); /* a little hack to fix RAM: */
strcat(dest,temp); /* bug in AmigaDOS 1.2 */
c=(dest+strlen(dest)-1);
/* add a slash if appropriate */
if ( (*c!=':') && (*c!='/') )
{
*(++c)='/';
*(++c)='\0';
}
strcat(dest,arg->wa_Name);
}