home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / tdoslyn4.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  2.7 KB  |  100 lines

  1. //    Copyright (c) 1994, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TDosLynx
  4. //    Include File:    tdoslynx.h
  5. //    Purpose:    Application object implementation
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        01-19-94
  9. #define Uses_TFileDialog
  10. #define Uses_TDeskTop
  11. #include"tdoslynx.h"
  12. #include"trace.h"
  13. #include"globals.h"
  14. #include"urltodos.h"
  15. #include"turlwind.h"
  16. #include<ctype.h>
  17.  
  18. void TDosLynx::OpenLocal(const char *cp_path)    {
  19. //    Purpose:    Open a local file.
  20. //    Arguments:    cp_path    the file to open if specified.
  21. //    Return Value:    void
  22. //    Remarks/Portability/Dependencies/Restrictions:
  23. //        Once a suitable file name has been extracted from the user,
  24. //        it will be turned into a url.  This function looks a lot like
  25. //        OpenURL.
  26. //    Revision History:
  27. //        01-19-94    created
  28. //        04-07-94    Added functionality to include a filename
  29. //                in the call to OpenLocal.  If not specified,
  30. //                the user will be promted for one.
  31.  
  32. #ifndef RELEASE
  33.     trace("Opening local file.");
  34. #endif // RELEASE
  35.  
  36.     if(cp_path == NULL)    {
  37.         //    Create the input dialog
  38.         TFileDialog *TFD = (TFileDialog *)validView(new TFileDialog("*.*",
  39.             "Open Local", "File", fdOpenButton, usi_OpenLocalHist));
  40.  
  41.         //    If the dialog was allocated and was successfully executed
  42.         //    without the user cancelling.
  43.         if(TFD != NULL && deskTop->execView(TFD) != cmCancel)    {
  44.             //    Small buffer to hold file name
  45.             auto char ca_buffer[usi_TILURLSize];
  46.  
  47.             //    Get the information from the Dialog
  48.             TFD->getFileName(ca_buffer);
  49.  
  50.             //    Remove whitespace from the front of the line.
  51.             if(isspace(ca_buffer[0]))    {
  52.                 char *cp_temp = ca_buffer + 1;
  53.  
  54.                 while(isspace(*cp_temp))
  55.                     cp_temp++;
  56.  
  57.                 int i_traverse;
  58.                 for(i_traverse = 0; *cp_temp != '\0'; i_traverse++)
  59.                     ca_buffer[i_traverse] = *cp_temp++;
  60.  
  61.                 ca_buffer[i_traverse] = '\0';
  62.             }
  63.  
  64.             //    Only if we actually received a file name
  65.             if(ca_buffer[0] != '\0')    {
  66.                 //    Convert the DOS file path to a url.
  67.                 char ca_dos2url[usi_TILURLSize];
  68.                 dostourl(ca_dos2url, ca_buffer);
  69.  
  70.                 //    Create a new valid window
  71.                 TView *TV_new = validView((TView *)new
  72.                     TURLWindow(ca_dos2url));
  73.                 //    if not created, don't insert to desktop.
  74.                 if(TV_new != NULL)    {
  75.                     deskTop->insert(TV_new);
  76.                 }
  77.             }
  78.         }
  79.  
  80.         //    Done with the dialog.
  81.         if(TFD != NULL)    {
  82.             destroy(TFD);
  83.         }
  84.     }
  85.     else    {
  86.         //    local filename already specified.  Load it.
  87.  
  88.         //    Convert the DOS file path to a url.
  89.         char ca_dos2url2[usi_TILURLSize];
  90.         dostourl(ca_dos2url2, cp_path);
  91.  
  92.         //    Create a new valid window
  93.         TView *TV_new2 = validView((TView *)new
  94.             TURLWindow(ca_dos2url2));
  95.         //    if not created, don't insert to desktop.
  96.         if(TV_new2 != NULL)    {
  97.             deskTop->insert(TV_new2);
  98.         }
  99.     }
  100. }