home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d502 / cells.lha / CELLS / CELLSSource.lzh / cDoFile.c < prev    next >
C/C++ Source or Header  |  1991-04-20  |  19KB  |  715 lines

  1. /*
  2.  *  CELLS       An Implementation of the WireWorld cellular automata
  3.  *              as described in Scientific American, Jan 1990.
  4.  *
  5.  *              Copyright 1990 by Davide P. Cervone.
  6.  *  You may use this code, provided this copyright notice is kept intact.
  7.  *  See the CELLS.HELP file for complete information on distribution conditions.
  8.  */
  9.  
  10. /*
  11.  *  File:  cDoFile.c        Handles the file requester
  12.  */
  13.  
  14.  
  15. #include "cGadget.h"
  16. #include "cRequest.h"
  17. #include "cReqLS.h"
  18. #include "cDos.h"
  19. #include "cParts.h"
  20.  
  21. extern char FileName[];         /* The current circuit file name */
  22. extern char LSNameBuf[];        /* The name gadget buffer area */
  23. extern int RequestID;           /* The type of file requester in use */
  24. extern FILEINFO FirstFile;      /* The list of names in the current directory */
  25.  
  26. extern FILEINFO FindFile();
  27.  
  28. char DirName[MAXFNAME];         /* The current directory name */
  29.  
  30. #define LSGADGET    LSRequest.er_Request.ReqGadget
  31.  
  32.  
  33. /*
  34.  *  NewDirectory()
  35.  *
  36.  *  If the directory name is not empty, then get a lock on the current
  37.  *  directory; if successful, change directories to that directory, otherwise
  38.  *  set the lookup flag (change the name of the current directory instead
  39.  *  of changing the current directory to the named one).
  40.  *
  41.  *  If we are looking up the name (e.g., an error occured or DirName only
  42.  *  contains a relative path), the get the complete path name.  Set the 
  43.  *  gadgets in the requester to reflect the new name and contents.
  44.  *
  45.  *  If no directory name is present, look up the device list instead.
  46.  *
  47.  *  Since directory look-ups can take long, record the mounted drives so
  48.  *  that disk insert events will not cause an update before the user has 
  49.  *  had a chance to look at the current directory.
  50.  */
  51.  
  52. void NewDirectory(Flag)
  53. int Flag;
  54. {
  55.    LOCK lock;
  56.    int Last = strlen(DirName) - 1;
  57.    
  58.    if (Last >= 0)
  59.    {
  60.       if (DosLock(&lock,DirName,TYPE_DIR))
  61.          UnLock(CurrentDir(lock)); else Flag = LOOKUPDIR;
  62.       if (Flag == LOOKUPDIR) GetProcessDir(DirName);
  63.       SetLSDirectory(DirName);
  64.    } else {
  65.       SetLSDevices();
  66.    }
  67.    Mounted = MountedDrives();
  68. }
  69.  
  70.  
  71. /*
  72.  *  AttemptOpen()
  73.  *
  74.  *  If a file name was given, then
  75.  *    If the file can not be locked for reading, then
  76.  *      If the operation is SAVE and the file does not exist, then were done,
  77.  *      Otherwise, report the failure to open the file;
  78.  *    Otherwise, (the file exists and can be read)
  79.  *      Get the FIB of the file.
  80.  *      If it is not a directory, then
  81.  *        If the operation is SAVE warn about re-writing,
  82.  *        Otherwise we've found the file to open.
  83.  *      Otherwise, (it IS a directory)
  84.  *        re-activate the name gadget (bug in Intuition makes this fail)
  85.  *        CD to the selected directory and get its name
  86.  *        look up the directory contents, etc.
  87.  *    Unlock the lock.
  88.  */
  89.  
  90. static int AttemptOpen(Name,ID)
  91. char *Name;
  92. int ID;
  93. {
  94.    FIB theFib;
  95.    LOCK lock;
  96.    int status = FALSE;
  97.  
  98.    if (Name && Name[0])
  99.    {
  100.       if ((lock = Lock(Name,ACCESS_READ)) == 0)
  101.       {
  102.          if (RequestID == LS_SAVE && IoErr() == ERROR_OBJECT_NOT_FOUND)
  103.             status = TRUE;
  104.            else
  105.             DosError("Open","File");
  106.       } else {
  107.          if (DosExamine(lock,&theFib,TYPE_FILE))
  108.          {
  109.             if (theFib->fib_DirEntryType < 0)
  110.             {
  111.                if (RequestID == LS_SAVE && ID != LS_REWRITE)
  112.                   SetReWrite(); else status = TRUE;
  113.             } else {
  114.                ActivateLSName();
  115.                lock = CurrentDir(lock);
  116.                GetProcessDir(DirName);
  117.                NewDirectory(NOLOOKUP);
  118.             }
  119.          }
  120.          UnLock(lock);
  121.       }
  122.    } else {
  123.       LSMessage("Can't Open File: No File Specified");
  124.    }
  125.    return(status);
  126. }
  127.  
  128.  
  129. /*
  130.  *  DoOpen()
  131.  *
  132.  *  Try to open the file specified in the name gadget.
  133.  *  If successful,
  134.  *    If the operation will save a new file to the current directory, 
  135.  *      disable the directory list (so that it will be looked up fresh 
  136.  *      the next time - we don't actually know what directory the file
  137.  *      will go into, since the name could include a path)
  138.  *    Remove the requester and clean up
  139.  *    Read or write the curcuit as necessary (include PARTS gadget status)
  140.  */
  141.  
  142. static void DoOpen(theGadget)
  143. struct Gadget *theGadget;
  144. {
  145.    if (AttemptOpen(LSNameBuf,theGadget->GadgetID))
  146.    {
  147.       if (RequestID == LS_SAVE && theGadget->GadgetID != LS_REWRITE)
  148.           DisableLSList(&LSGADGET[LS_NLIST]);
  149.       RemoveRequest(&LSRequest);
  150.       SetPointerColor(PenInUse);
  151.       if (RequestID == LS_LOAD)
  152.          ReadFile(LSNameBuf,LSGADGET[LS_CHECK].Flags & SELECTED);
  153.         else
  154.          WriteFile(LSNameBuf,LSGADGET[LS_CHECK].Flags & SELECTED);
  155.    }
  156. }
  157.  
  158.  
  159. /*
  160.  *  DoDirUpPressed()
  161.  *
  162.  *  If SHIFT is held down (meaning go to the root directory)
  163.  *    get the directory name if necessary
  164.  *    find the ':' in the name
  165.  *    If found and it is not the last character in the name,
  166.  *      remove the rest of the name and look up the new directory
  167.  *  Otherwiese (no SHIFT)
  168.  *    If there is a directory named, get its length
  169.  *      look backward for the first '/' or ':'
  170.  *      truncate the directory name and look up the new directory
  171.  */
  172.  
  173. static void DoDirUpPressed(Shifted)
  174. int Shifted;
  175. {
  176.    int len;
  177.    short i;
  178.  
  179.    if (Shifted)
  180.    {
  181.       if ((len = strlen(DirName)) == 0) GetProcessDir(DirName);
  182.       for (i=0; DirName[i] && DirName[i] != ':'; i++);
  183.       if ((DirName[i] == ':' && DirName[i+1]) || len == 0)
  184.       {
  185.          DirName[i+1] = 0;
  186.          NewDirectory(NOLOOKUP);
  187.       }
  188.    } else {
  189.       if ((i = strlen(DirName)) > 0)
  190.       {
  191.          for (i-=2; i>=0 && DirName[i] != '/' && DirName[i] != ':'; i--);
  192.          if (i < 0 || DirName[i] == ':') i++;
  193.          DirName[MAX(i,0)] = 0;
  194.          NewDirectory(NOLOOKUP);
  195.       }
  196.    }
  197. }
  198.  
  199.  
  200. /*
  201.  *  DoDirPressed()
  202.  *
  203.  *  Look up the current directory.
  204.  *  If SHIFT pressed, then disable the directory listing
  205.  *  otherwise refresh the directory listing.
  206.  */
  207.  
  208. static void DoDirPressed(Shifted)
  209. int Shifted;
  210. {
  211.    GetProcessDir(DirName);
  212.    if (Shifted)
  213.    {
  214.       DisableLSList(&LSGADGET[LS_NLIST]);
  215.       ClearDirectoryList();
  216.    } else {
  217.       EnableLSList(&LSGADGET[LS_NLIST]);
  218.       SetLSDirectory(DirName);
  219.    }
  220. }
  221.  
  222.  
  223. /*
  224.  *  DoDrive()
  225.  *
  226.  *  Get the name of the next mounted disk drive
  227.  *  If no error, then look up the directory contents
  228.  *  otherwise give an appropriate message.
  229.  */
  230.  
  231. static void DoDrive()
  232. {
  233.    switch(DosNextDisk(DirName))
  234.    {
  235.       case NOERROR:
  236.          NewDirectory(NOLOOKUP);
  237.          break;
  238.  
  239.       case NOVOLMOUNT:
  240.          LSMessage("No Volumes Mounted");
  241.          DirName[0] = 0;
  242.          NewDirectory(NOLOOKUP);
  243.          break;
  244.  
  245.       case NOVOLOTHER:
  246.          LSMessage("No Other Volumes Mounted");
  247.          GetProcessDir(DirName);
  248.          break;
  249.    }
  250. }
  251.  
  252.  
  253. /*
  254.  *  DoInfo()
  255.  *
  256.  *  If the specified file name can be locked, then
  257.  *    If the ALT key is pressed
  258.  *      If we can get an Info Block for the current disk,
  259.  *        display its information
  260.  *    Otherwise
  261.  *      If we can get an FIB for the specified file
  262.  *        If SHIFT is pressed
  263.  *          display its comment field
  264.  *        Otherwise
  265.  *          get the file's creation date and its protection
  266.  *          display the appropriate message for a file or directory
  267.  *    Unlock the lock
  268.  */
  269.  
  270. static void DoInfo(Shifted,ALTed)
  271. int Shifted,ALTed;
  272. {
  273.    LOCK lock;
  274.    FIB Fib;
  275.    INFODATA theInfo;
  276.    char time[16],prot[9];
  277.    int i;
  278.  
  279.    if (DosLock(&lock,LSNameBuf,TYPE_FILE))
  280.    {
  281.       if (ALTed)
  282.       {
  283.          if (DosInfo(lock,&theInfo,TYPE_FILE))
  284.             LSMessage("Disk: %ld Free %ld Used (%ld%%) %s",
  285.                theInfo->id_NumBlocks - theInfo->id_NumBlocksUsed,
  286.                theInfo->id_NumBlocksUsed,
  287.                theInfo->id_NumBlocksUsed * 100 / theInfo->id_NumBlocks,
  288.                (theInfo->id_DiskState == ID_WRITE_PROTECTED)? "Locked": "");  
  289.       } else {
  290.          if (DosExamine(lock,&Fib,TYPE_FILE))
  291.          {
  292.             if (Shifted)
  293.             {
  294.                if (Fib->fib_Comment[0])
  295.                   LSMessage(Fib->fib_Comment);
  296.                  else
  297.                   LSMessage("No FileNote for this File");
  298.             } else {
  299.                GetStrTime(&time,&(Fib->fib_Date));
  300.                strcpy(prot,"hsparwed");
  301.                for (i=3; i>=0; i--)
  302.                   if (Fib->fib_Protection & (1<<i)) prot[7-i] = '-';
  303.                for (i=7; i>3; i--)
  304.                   if ((Fib->fib_Protection & (1<<i)) == 0) prot[7-i] = '-';
  305.  
  306.                if (Fib->fib_DirEntryType < 0)
  307.                   LSMessage("%ld Byte%s (%ld Block%s) [%s] %s",
  308.                      Fib->fib_Size, (Fib->fib_Size != 1)? "s": "",
  309.                      Fib->fib_NumBlocks, (Fib->fib_NumBlocks != 1)? "s": "",
  310.                      prot, time);
  311.                  else
  312.                   LSMessage("Dir: [%s] %s",prot,time);
  313.             }
  314.          }
  315.       }
  316.       UnLock(lock);
  317.    }
  318. }
  319.  
  320.  
  321. /*
  322.  *  DoDelete()
  323.  *
  324.  *  If no file is named, give an error message,
  325.  *  Otherwise if the file can be deleted,
  326.  *    display the deletion message
  327.  *    find the file in the directory listing (if any)
  328.  *    remove the file entry from the list
  329.  *    clear the name string
  330.  *  Otherwise, give an error message
  331.  */
  332.  
  333. static void DoDelete()
  334. {
  335.    FILEINFO theFile;
  336.  
  337.    if (LSNameBuf[0] == 0)
  338.    {
  339.       LSMessage("Can't Delete File: None Specified");
  340.    } else if (DeleteFile(LSNameBuf)) {
  341.       LSMessage("'%s' Deleted",LSNameBuf);
  342.       theFile = FindFile(LSNameBuf);
  343.       if (theFile) RemoveFile(theFile);
  344.       SetStringInfo(&LSGADGET[LS_NAME],"");
  345.       RefreshRequest(&LSRequest,LS_NAME,NULL);
  346.    } else DosError("Delete","File");
  347. }
  348.  
  349.  
  350. /*
  351.  *  DoMakeDir()
  352.  *
  353.  *  If no name was given, display an error
  354.  *  Otherwise,
  355.  *    If the new directory can not be created, display a message
  356.  *    Otherwise,
  357.  *      CD to the new directory
  358.  *      get its complete path name,
  359.  *      clear the name gadget
  360.  *      look up the new directory contents
  361.  */
  362.  
  363. static void DoMakeDir()
  364. {
  365.    LOCK lock;
  366.  
  367.    if (LSNameBuf[0] == 0)
  368.    {
  369.       LSMessage("Can't Create Directory: No Name Specified");
  370.    } else {
  371.       if ((lock = CreateDir(LSNameBuf)) == 0)
  372.       {
  373.          DosError("Create","Directory");
  374.       } else {
  375.          UnLock(lock);
  376.          if (DosLock(&lock,LSNameBuf,TYPE_DIR))
  377.          {
  378.             UnLock(CurrentDir(lock));
  379.             GetProcessDir(DirName);
  380.             SetStringInfo(&LSGADGET[LS_NAME],"");
  381.             RefreshRequest(&LSRequest,LS_NAME,NULL);
  382.             NewDirectory(LOOKUPDIR);
  383.          }
  384.       }
  385.    }
  386. }
  387.  
  388.  
  389. /*
  390.  *  LSGadgetUp()
  391.  *
  392.  *  Handles GadgetUp events for the LoadSave file requester:
  393.  *  Clear any message in the message box
  394.  *  Clear the RE-WRITE button name if appropriate
  395.  *  For each gadget, do the right thing (try to make sure the name gadget
  396.  *    remains active):
  397.  *
  398.  *    LOAD, SAVE, REWRITE and NAME:  Open the specified file
  399.  *    DRIVE:    Get the next drive's information
  400.  *    INFO:     Get the file's information
  401.  *    DELETE:   Delete the file
  402.  *    MAKEDIR:  Make the new directory
  403.  *    CANCEL:   Cancel the requester and put things back in order
  404.  *
  405.  *    The Directory Name:  lookup directory list
  406.  *    Left Arrow:  Go to parent directory
  407.  *    The Slider:  update the list position
  408.  */
  409.  
  410. static void LSGadgetUp(theGadget,theMessage)
  411. struct Gadget *theGadget;
  412. struct IntuiMessage *theMessage;
  413. {
  414.    LSMessage(NULL);
  415.    if (theGadget->GadgetID != LS_REWRITE) UnsetReWrite();
  416.    switch(theGadget->GadgetID)
  417.    {
  418.       case LS_LOAD:
  419.       case LS_SAVE:
  420.       case LS_REWRITE:
  421.       case LS_NAME:
  422.          DoOpen(theGadget);
  423.          break;
  424.  
  425.       case LS_DRIVE:
  426.          DoDrive();
  427.          ActivateLSName();
  428.          break;
  429.  
  430.       case LS_INFO:
  431.          DoInfo(theMessage->Qualifier & SHIFTKEYS,
  432.                 theMessage->Qualifier & ALTKEYS);
  433.          ActivateLSName();
  434.          break;
  435.  
  436.       case LS_DELETE:
  437.          DoDelete();
  438.          ActivateLSName();
  439.          break;
  440.  
  441.       case LS_MAKEDIR:
  442.          DoMakeDir();
  443.          ActivateLSName();
  444.          break;
  445.  
  446.       case LS_DIR:
  447.          DoDirPressed(theMessage->Qualifier & SHIFTKEYS);
  448.          ActivateLSName();
  449.          break;
  450.  
  451.       case LS_DLARROW:
  452.          DoDirUpPressed(theMessage->Qualifier & SHIFTKEYS);
  453.          ActivateLSName();
  454.          break;
  455.  
  456.       case LS_CANCEL:
  457.          QuitInProgress = FALSE;
  458.          RemoveRequest(&LSRequest);
  459.          if (RequestID == LS_LOAD)
  460.             InvertGadget(&cGadget[ID_LOAD]);
  461.            else
  462.             InvertGadget(&cGadget[ID_SAVE]);
  463.          SetPointerColor(PenInUse);
  464.          break;
  465.  
  466.       case LS_SLIDE:
  467.          EndListSlider(theGadget->UserData);
  468.          break;
  469.    }
  470. }
  471.  
  472.  
  473. /*
  474.  *  LSGadgetDown()
  475.  *
  476.  *  Handles GadgetDown message for the LoadSave File Requester
  477.  *  Clear the message box if appropriate
  478.  *  Clear the RE-WRITE gadget name
  479.  *  For each gadget, do the right thing (try to make the name gadget active
  480.  *    as often as possible):
  481.  *
  482.  *    A File Name in the List:  if double clicked, try to open it
  483.  *    Up Arrow:    Scroll the list Up
  484.  *    Down Arrow:  Scroll the List Down
  485.  *    Slider:      Let the list manager know that the slider is active
  486.  *    Name Gadget: Unselect any selected names in the list
  487.  *    Message:     Get back the last message displayed
  488.  */
  489.  
  490. static void LSGadgetDown(theGadget,theMessage)
  491. struct Gadget *theGadget;
  492. struct IntuiMessage *theMessage;
  493. {
  494.    if (theGadget->GadgetID != LS_MESSAGE &&
  495.        theGadget->GadgetID != LS_NAME) LSMessage(NULL);
  496.    UnsetReWrite();
  497.    switch(theGadget->GadgetID)
  498.    {
  499.       case LS_NLIST:
  500.          if (DoListHit(theGadget->UserData,theMessage)) DoOpen(theGadget);
  501.          break;
  502.  
  503.       case LS_UARROW:
  504.          DoListScrollUp(theGadget->UserData,theGadget,theMessage);
  505.          break;
  506.  
  507.       case LS_DARROW:
  508.          DoListScrollDown(theGadget->UserData,theGadget,theMessage);
  509.          break;
  510.  
  511.       case LS_SLIDE:
  512.          StartListSlider(theGadget->UserData);
  513.          break;
  514.  
  515.       case LS_NAME:
  516.          if ((LSGADGET[LS_NLIST].Flags & GADGDISABLED) == 0)
  517.             UnsetListSelect(theGadget->UserData,TRUE);
  518.          break;
  519.  
  520.       case LS_CHECK:
  521.          ActivateLSName();
  522.          break;
  523.  
  524.       case LS_MESSAGE:
  525.          RecallLSMessage(theGadget);
  526.          ActivateLSName();
  527.          break;
  528.    }
  529. }
  530.  
  531.  
  532. /*
  533.  *  DoLoad()
  534.  *
  535.  *  If the requester is not already up
  536.  *    Clear the name buffer
  537.  *    Invert the LOAD gadget and set the pointer to its normal colors
  538.  *    Set up the requester title and gadget names
  539.  *    Open the requester
  540.  *    If unsuccessful, put the pointer and LOAD gadgets back the way they were
  541.  */
  542.  
  543. void DoLoad()
  544. {
  545.    extern void DoListMouse();
  546.  
  547.    if (ActiveRequest != &LSRequest)
  548.    {
  549.       LSNameBuf[0] = 0;
  550.       InvertGadget(&cGadget[ID_LOAD]);
  551.       RestorePointerColor();
  552.       SetLSTexts("Load Circuit from File:","Load",
  553.          "Load Library as Parts",LS_LOAD);
  554.       LSListInfo.Image->NextImage = NULL;
  555.       LSGADGET[LS_CHECK].Flags &= ~GADGDISABLED;
  556.       AddRequest(&LSRequest,LSGadgetDown,LSGadgetUp,DoListMouse);
  557.       if (ActiveRequest == NULL)
  558.       {
  559.          InvertGadget(&cGadget[ID_LOAD]);
  560.          SetPointerColor(PenInUse);
  561.       }
  562.    }
  563. }
  564.  
  565.  
  566. /*
  567.  *  DoSaveAs()
  568.  *
  569.  *  If the requester is not already active
  570.  *    Copy the current circuit file name to the name gadget
  571.  *    Invert the SAVE gadget and set the pointer to its normal colors
  572.  *    Set the requester title and gadget names
  573.  *    Disable PARTS gadget if necessary
  574.  *    Open the requester
  575.  *    If unsuccessful, put things back as they were
  576.  */
  577.  
  578. void DoSaveAs()
  579. {
  580.    extern void DoListMouse();
  581.  
  582.    if (ActiveRequest != &LSRequest)
  583.    {
  584.       strcpy(LSNameBuf,FileName);
  585.       InvertGadget(&cGadget[ID_SAVE]);
  586.       RestorePointerColor();
  587.       SetLSTexts((SelectType)? "Save Selection to File:":
  588.          "Save Circuit to File:","Save","Save as Library (Parts Only)",LS_SAVE);
  589.       if (SelectType || PartsList.FirstPart == NULL)
  590.          LSGADGET[LS_CHECK].Flags |= GADGDISABLED;
  591.         else
  592.          LSGADGET[LS_CHECK].Flags &= ~GADGDISABLED;
  593.       LSListInfo.Image->NextImage = NULL;
  594.       AddRequest(&LSRequest,LSGadgetDown,LSGadgetUp,DoListMouse);
  595.       if (ActiveRequest == NULL)
  596.       {
  597.          InvertGadget(&cGadget[ID_SAVE]);
  598.          SetPointerColor(PenInUse);
  599.       }
  600.    }
  601. }
  602.  
  603.  
  604. /*
  605.  *  DoSave()
  606.  *
  607.  *  If cells are selected, request a file for them to be saved into
  608.  *  Otherwise,
  609.  *    If changes have been made to the current circuit
  610.  *      If the circuit has no name yet
  611.  *        get a file name for the circuit
  612.  *      Otherwise
  613.  *        Invert the SAVE button during the save operation
  614.  *        and put the pointer colors back to normal
  615.  *        save the circuit to its file
  616.  *    Otherwise give a message that no saving is required
  617.  */
  618.  
  619. void DoSave()
  620. {
  621.    if (SelectType)
  622.    {
  623.       DoSaveAs();
  624.    } else {
  625.       if (Changed)
  626.       {
  627.          if (FileName[0] == 0)
  628.          {
  629.             DoSaveAs();
  630.          } else {
  631.             InvertGadget(&cGadget[ID_SAVE]);
  632.             RestorePointerColor();
  633.             WriteFile(FileName,0);
  634.          }
  635.       } else {
  636.          DoError("Circuit has not been Modified");
  637.       }
  638.    }
  639. }
  640.  
  641.  
  642. /*
  643.  *  DoNew()
  644.  *
  645.  *  Cancel any selection
  646.  *  If changes have been made
  647.  *    Ask whether changes should be discarded
  648.  *  If still going on with the NEW command,
  649.  *    Clear the library list
  650.  *    Clear the grid
  651.  *    Clear the UNDO and RESET grids
  652.  *    Clear the file name and the Changed flag
  653.  */
  654.  
  655. void DoNew()
  656. {
  657.    int OKtoDoNew = TRUE;
  658.  
  659.    if (SelectType) CancelSelect();
  660.    if (Changed)
  661.    {
  662.       InvertGadget(&cGadget[ID_LOAD]);
  663.       RestorePointerColor();
  664.       OKtoDoNew =
  665.          DoQuestion(" Changes have not been Saved. Discard Changes?      ");
  666.       SetPointerColor(PenInUse);
  667.       InvertGadget(&cGadget[ID_LOAD]);
  668.    }
  669.    if (OKtoDoNew)
  670.    {
  671.       ClearLibs();
  672.       DoClear();
  673.       ClearGrid(UndoArray);
  674.       ClearGrid(ResetArray);
  675.       Changed = FALSE;
  676.       FileName[0] = 0;
  677.    }
  678. }
  679.  
  680.  
  681. /*
  682.  *  DoDiskInseted()
  683.  *
  684.  *  If the file requester is active
  685.  *    Look up the currently mounted floppy drives
  686.  *    If a new disk was inserted, go to the root of that disk
  687.  */
  688.  
  689. void DoDiskInserted(theMessage)
  690. struct IntuiMessage *theMessage;
  691. {
  692.    int OldMounted = Mounted;
  693.  
  694.    if (ActiveRequest == &LSRequest)
  695.    {
  696.       Mounted = MountedDrives();
  697.       if (DosInsertedDrive(OldMounted,DirName))
  698.          NewDirectory(LOOKUPDIR);
  699.    }
  700. }
  701.  
  702.  
  703. /*
  704.  *  DoDiskRemoved()
  705.  *
  706.  *  Get the currently mounted disks, so we can tell what new disks
  707.  *  are inserted later.
  708.  */
  709.  
  710. void DoDiskRemoved(theMessage)
  711. struct IntuiMessage *theMessage;
  712. {
  713.    Mounted = MountedDrives();
  714. }
  715.