My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

SdFile.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * sd/SdFile.cpp
  24. *
  25. * Arduino SdFat Library
  26. * Copyright (c) 2009 by William Greiman
  27. *
  28. * This file is part of the Arduino Sd2Card Library
  29. */
  30. #include "../inc/MarlinConfig.h"
  31. #if ENABLED(SDSUPPORT)
  32. #include "SdFile.h"
  33. /**
  34. * Create a file object and open it in the current working directory.
  35. *
  36. * \param[in] path A path with a valid 8.3 DOS name for a file to be opened.
  37. *
  38. * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive
  39. * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t).
  40. */
  41. SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) { }
  42. /**
  43. * Write data to an open file.
  44. *
  45. * \note Data is moved to the cache but may not be written to the
  46. * storage device until sync() is called.
  47. *
  48. * \param[in] buf Pointer to the location of the data to be written.
  49. *
  50. * \param[in] nbyte Number of bytes to write.
  51. *
  52. * \return For success write() returns the number of bytes written, always
  53. * \a nbyte. If an error occurs, write() returns -1. Possible errors
  54. * include write() is called before a file has been opened, write is called
  55. * for a read-only file, device is full, a corrupt file system or an I/O error.
  56. */
  57. int16_t SdFile::write(const void* buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); }
  58. /**
  59. * Write a byte to a file. Required by the Arduino Print class.
  60. * \param[in] b the byte to be written.
  61. * Use writeError to check for errors.
  62. */
  63. #if ARDUINO >= 100
  64. size_t SdFile::write(uint8_t b) { return SdBaseFile::write(&b, 1); }
  65. #else
  66. void SdFile::write(uint8_t b) { SdBaseFile::write(&b, 1); }
  67. #endif
  68. /**
  69. * Write a string to a file. Used by the Arduino Print class.
  70. * \param[in] str Pointer to the string.
  71. * Use writeError to check for errors.
  72. */
  73. void SdFile::write(const char* str) { SdBaseFile::write(str, strlen(str)); }
  74. /**
  75. * Write a PROGMEM string to a file.
  76. * \param[in] str Pointer to the PROGMEM string.
  77. * Use writeError to check for errors.
  78. */
  79. void SdFile::write_P(PGM_P str) {
  80. for (uint8_t c; (c = pgm_read_byte(str)); str++) write(c);
  81. }
  82. /**
  83. * Write a PROGMEM string followed by CR/LF to a file.
  84. * \param[in] str Pointer to the PROGMEM string.
  85. * Use writeError to check for errors.
  86. */
  87. void SdFile::writeln_P(PGM_P str) {
  88. write_P(str);
  89. write_P(PSTR("\r\n"));
  90. }
  91. #endif // SDSUPPORT