dosname.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* File names on MS-DOS/Windows systems.
  2. Copyright (C) 2000-2001, 2004-2006, 2009-2017 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. From Paul Eggert and Jim Meyering. */
  14. #ifndef _DOSNAME_H
  15. #define _DOSNAME_H
  16. #if (defined _WIN32 || defined __WIN32__ || \
  17. defined __MSDOS__ || defined __CYGWIN__ || \
  18. defined __EMX__ || defined __DJGPP__)
  19. /* This internal macro assumes ASCII, but all hosts that support drive
  20. letters use ASCII. */
  21. # define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
  22. <= 'z' - 'a')
  23. # define FILE_SYSTEM_PREFIX_LEN(Filename) \
  24. (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
  25. # ifndef __CYGWIN__
  26. # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
  27. # endif
  28. # define ISSLASH(C) ((C) == '/' || (C) == '\\')
  29. #else
  30. # define FILE_SYSTEM_PREFIX_LEN(Filename) 0
  31. # define ISSLASH(C) ((C) == '/')
  32. #endif
  33. #ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
  34. # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
  35. #endif
  36. #if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
  37. # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
  38. # else
  39. # define IS_ABSOLUTE_FILE_NAME(F) \
  40. (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
  41. #endif
  42. #define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
  43. #endif /* DOSNAME_H_ */