Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.5 KiB

  1. /*
  2. +-------------------------------------------------------------------------+
  3. | MDI Text File View - File open Functions |
  4. +-------------------------------------------------------------------------+
  5. | (c) Copyright 1994 |
  6. | Microsoft Corp. |
  7. | All rights reserved |
  8. | |
  9. | Program : [FVOpen.c] |
  10. | Programmer : Arthur Hanson |
  11. | Original Program Date : [Feb 11, 1994] |
  12. | Last Update : [Feb 11, 1994] |
  13. | |
  14. | Version: 0.10 |
  15. | |
  16. | Description: |
  17. | |
  18. | History: |
  19. | arth Jul 27, 1993 0.10 Original Version. |
  20. | |
  21. +-------------------------------------------------------------------------+
  22. */
  23. #include "LogView.h"
  24. #include <fcntl.h>
  25. #include <io.h>
  26. #include <string.h>
  27. #define MAXFILENAME 256
  28. CHAR szPropertyName [] = "FILENAME"; // Name of the File name property list item
  29. /////////////////////////////////////////////////////////////////////////
  30. BOOL
  31. FileExists(
  32. PSTR pch
  33. )
  34. /*++
  35. Routine Description:
  36. Arguments:
  37. Return Value:
  38. --*/
  39. {
  40. int fh;
  41. if ((fh = _open(pch, O_RDONLY)) < 0)
  42. return(FALSE);
  43. _lclose(fh);
  44. return(TRUE);
  45. } // FileExists
  46. /////////////////////////////////////////////////////////////////////////
  47. VOID APIENTRY
  48. GetFileName(
  49. HWND hwnd,
  50. PSTR pstr
  51. )
  52. /*++
  53. Routine Description:
  54. Arguments:
  55. Return Value:
  56. --*/
  57. {
  58. CHAR szFmt[128];
  59. OPENFILENAME ofn;
  60. CHAR szFilterSpec[128];
  61. CHAR szDefExt[10];
  62. CHAR szFileName[MAXFILENAME];
  63. CHAR szFileTitle[MAXFILENAME];
  64. strcpy(szFileName, ""); // these need be NULL
  65. strcpy(szFileTitle, "");
  66. memset(&ofn,0,sizeof(ofn)) ;
  67. memset(szFilterSpec,0,sizeof(szFilterSpec)) ;
  68. LoadString (hInst, (WORD)IDS_OPENTEXT,
  69. (LPSTR)szFmt, sizeof (szFmt));
  70. LoadString (hInst, (WORD)IDS_OPENFILTER,
  71. (LPSTR)szFilterSpec, sizeof (szFilterSpec));
  72. ofn.lStructSize = sizeof(OPENFILENAME);
  73. ofn.hwndOwner = hwnd;
  74. ofn.lpstrFilter = szFilterSpec;
  75. ofn.lpstrCustomFilter = NULL;
  76. ofn.nMaxCustFilter = 0;
  77. ofn.nFilterIndex = 0;
  78. ofn.lpstrFile = szFileName;
  79. ofn.nMaxFile = MAXFILENAME;
  80. ofn.lpstrInitialDir = NULL;
  81. ofn.lpstrFileTitle = szFileTitle;
  82. ofn.nMaxFileTitle = MAXFILENAME;
  83. ofn.lpstrTitle = szFmt;
  84. LoadString (hInst, (WORD)IDS_DEFEXT, (LPSTR)szDefExt, sizeof (szDefExt));
  85. ofn.lpstrDefExt = szDefExt;
  86. ofn.Flags = OFN_FILEMUSTEXIST;
  87. // Use standard open dialog
  88. if (!GetOpenFileName ((LPOPENFILENAME)&ofn)) {
  89. *pstr = 0;
  90. }
  91. else {
  92. strcpy(pstr, ofn.lpstrFile);
  93. }
  94. return;
  95. } // GetFileName