home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 465.lha / ParM_v2.5r / ParMCD.c < prev    next >
C/C++ Source or Header  |  1991-01-05  |  2KB  |  62 lines

  1. /*
  2.  *    ParMCD.c - Copyright © 1990 by Devil's child.
  3.  *
  4.  *    Created:    08 Oct 1990  20:51:16
  5.  *    Modified:    21 Nov 1990  17:15:45
  6.  *
  7.  *    Make>> cc -qf -ps -m0b -wp -wd -wu -so -hi ram:ParM.syms <file>.c
  8.  *    Make>> ln <file>.o
  9.  *    Make>> Protect <file> +p
  10.  */
  11.  
  12. #include <arp_ports.h>
  13.  
  14. void ParMCD(long len, char *line);
  15. #pragma regcall(ParMCD(d0,a0))
  16.  
  17. void ParMCD(long len, char *line)
  18. {
  19.     struct ExecBase *SysBase = *((struct ExecBase **)4L);
  20.     struct ArpBase *ArpBase;
  21.     struct Process *MyProcess;
  22.     short argc;
  23.     char *argv[2];
  24.     struct InfoData *infodata;
  25.     long args[8];
  26.     struct Window *W;
  27.     struct MsgPort *ReplyPort;
  28.     struct IntuiMessage Msg;
  29.     char dir[120];
  30.  
  31.     if (!(ArpBase = (struct ArpBase *)OpenLibrary("arp.library", 39L))) return;
  32.     MyProcess = (struct Process *)SysBase->ThisTask;
  33.     SysBase->ThisTask->tc_UserData = (APTR)&ArpBase; /* for GADS() ??? used to be for my resident Printf() */
  34.  
  35.     argc = GADS(line, len, "Usage: ParMCD [New current directory name]", (char **)&argv, "Dir");
  36.     if (argc < 0) {
  37.         Puts(argv[0]);
  38.         ArpExit(20L, ERROR_LINE_TOO_LONG);
  39.     }
  40.     infodata = ArpAlloc(sizeof(struct InfoData));
  41.     args[0] = (long)infodata >> 2;
  42.     SendPacket(ACTION_DISK_INFO, args, (struct MsgPort *)MyProcess->pr_ConsoleTask);
  43.     W = (struct Window *)infodata->id_VolumeNode;
  44.     if ( (W->IDCMPFlags & MENUPICK) && (ReplyPort = CreatePort(NULL, NULL)) ) {
  45.         PathName( MyProcess->pr_CurrentDir, dir, 80);
  46.         Msg.Class = 0x0FL;
  47.         if (argv[0])
  48.             Msg.IAddress = (APTR)argv[0];
  49.         else
  50.             Msg.IAddress = (APTR)dir;
  51.         Msg.ExecMessage.mn_Node.ln_Type = NT_MESSAGE;
  52.         Msg.ExecMessage.mn_Length = sizeof( struct IntuiMessage );
  53.         Msg.ExecMessage.mn_ReplyPort = ReplyPort;      
  54.         PutMsg(W->UserPort, (struct Message *)&Msg);
  55.         WaitPort(ReplyPort);
  56.         GetMsg(ReplyPort);
  57.         DeletePort(ReplyPort);
  58.     }
  59.     CloseLibrary(ArpBase);
  60. }
  61.  
  62.