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.

103 lines
3.6 KiB

  1. /*
  2. * $Log: V:/Flite/archives/TrueFFS5/Src/FLPARSE.C_V $
  3. *
  4. * Rev 1.2 Jan 29 2002 20:09:04 oris
  5. * Added NAMING_CONVENTION prefix to flParsePath public routines.
  6. *
  7. * Rev 1.1 Apr 01 2001 07:59:42 oris
  8. * copywrite notice.
  9. *
  10. * Rev 1.0 Feb 04 2001 11:40:12 oris
  11. * Initial revision.
  12. *
  13. */
  14. /***********************************************************************************/
  15. /* M-Systems Confidential */
  16. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
  17. /* All Rights Reserved */
  18. /***********************************************************************************/
  19. /* NOTICE OF M-SYSTEMS OEM */
  20. /* SOFTWARE LICENSE AGREEMENT */
  21. /* */
  22. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  23. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  24. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
  25. /* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
  26. /* E-MAIL = [email protected] */
  27. /***********************************************************************************/
  28. #include "fatlite.h"
  29. #ifdef PARSE_PATH
  30. /*----------------------------------------------------------------------*/
  31. /* f l P a r s e P a t h */
  32. /* */
  33. /* Converts a DOS-like path string to a simple-path array. */
  34. /* */
  35. /* Note: Array length received in irPath must be greater than the */
  36. /* number of path components in the path to convert. */
  37. /* */
  38. /* Parameters: */
  39. /* ioreq->irData : address of path string to convert */
  40. /* ioreq->irPath : address of array to receive parsed-path */
  41. /* */
  42. /* Returns: */
  43. /* FLStatus : 0 on success, otherwise failed */
  44. /*----------------------------------------------------------------------*/
  45. FLStatus NAMING_CONVENTION flParsePath(IOreq FAR2 *ioreq)
  46. {
  47. char FAR1 *dosPath;
  48. FLSimplePath FAR1 *sPath = ioreq->irPath;
  49. unsigned offset = 0, dots = 0, chars = 0;
  50. FLBoolean isExt = FALSE;
  51. for (dosPath = (char FAR1 *) ioreq->irData; ; dosPath++) {
  52. if (*dosPath == '\\' || *dosPath == 0) {
  53. if (offset != 0) {
  54. while (offset < sizeof(FLSimplePath))
  55. sPath->name[offset++] = ' ';
  56. if (chars == 0) {
  57. if (dots == 2)
  58. sPath--;
  59. }
  60. else
  61. sPath++;
  62. offset = dots = chars = 0;
  63. isExt = FALSE;
  64. }
  65. sPath->name[offset] = 0;
  66. if (*dosPath == 0)
  67. break;
  68. }
  69. else if (*dosPath == '.') {
  70. dots++;
  71. while (offset < sizeof sPath->name)
  72. sPath->name[offset++] = ' ';
  73. isExt = TRUE;
  74. }
  75. else if (offset < sizeof(FLSimplePath) &&
  76. (isExt || offset < sizeof sPath->name)) {
  77. chars++;
  78. if (*dosPath == '*') {
  79. while (offset < (isExt ? sizeof(FLSimplePath) : sizeof sPath->name))
  80. sPath->name[offset++] = '?';
  81. }
  82. else if (*dosPath >= 'a' && *dosPath <= 'z')
  83. sPath->name[offset++] = *dosPath - ('a' - 'A');
  84. else
  85. sPath->name[offset++] = *dosPath;
  86. }
  87. }
  88. return flOK;
  89. }
  90. #endif /* PARSE_PATH */