FsApiConstants.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Copyright (c) 2011-2022 Bill Greiman
  3. * This file is part of the SdFat library for SD memory cards.
  4. *
  5. * MIT License
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef FsApiConstants_h
  26. #define FsApiConstants_h
  27. #include "SysCall.h"
  28. #if USE_FCNTL_H
  29. #include <fcntl.h>
  30. /* values for GNU Arm Embedded Toolchain.
  31. * O_RDONLY: 0x0
  32. * O_WRONLY: 0x1
  33. * O_RDWR: 0x2
  34. * O_ACCMODE: 0x3
  35. * O_APPEND: 0x8
  36. * O_CREAT: 0x200
  37. * O_TRUNC: 0x400
  38. * O_EXCL: 0x800
  39. * O_SYNC: 0x2000
  40. * O_NONBLOCK: 0x4000
  41. */
  42. /** Use O_NONBLOCK for open at EOF */
  43. #define O_AT_END O_NONBLOCK ///< Open at EOF.
  44. typedef int oflag_t;
  45. #else // USE_FCNTL_H
  46. #define O_RDONLY 0X00 ///< Open for reading only.
  47. #define O_WRONLY 0X01 ///< Open for writing only.
  48. #define O_RDWR 0X02 ///< Open for reading and writing.
  49. #define O_AT_END 0X04 ///< Open at EOF.
  50. #define O_APPEND 0X08 ///< Set append mode.
  51. #define O_CREAT 0x10 ///< Create file if it does not exist.
  52. #define O_TRUNC 0x20 ///< Truncate file to zero length.
  53. #define O_EXCL 0x40 ///< Fail if the file exists.
  54. #define O_SYNC 0x80 ///< Synchronized write I/O operations.
  55. #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) ///< Mask for access mode.
  56. typedef uint8_t oflag_t;
  57. #endif // USE_FCNTL_H
  58. #define O_READ O_RDONLY
  59. #define O_WRITE O_WRONLY
  60. inline bool isWriteMode(oflag_t oflag) {
  61. oflag &= O_ACCMODE;
  62. return oflag == O_WRONLY || oflag == O_RDWR;
  63. }
  64. // flags for ls()
  65. /** ls() flag for list all files including hidden. */
  66. const uint8_t LS_A = 1;
  67. /** ls() flag to print modify. date */
  68. const uint8_t LS_DATE = 2;
  69. /** ls() flag to print file size. */
  70. const uint8_t LS_SIZE = 4;
  71. /** ls() flag for recursive list of subdirectories */
  72. const uint8_t LS_R = 8;
  73. // flags for time-stamp
  74. /** set the file's last access date */
  75. const uint8_t T_ACCESS = 1;
  76. /** set the file's creation date and time */
  77. const uint8_t T_CREATE = 2;
  78. /** Set the file's write date and time */
  79. const uint8_t T_WRITE = 4;
  80. #endif // FsApiConstants_h