Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: SD.exists has no "exists(const String &filepath)" overload

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    18

    SD.exists has no "exists(const String &filepath)" overload

    Hi all,

    SD class overload "boolean exists(const String &filepath)" is missing.

    String s;

    #if defined(TEENSYDUINO)
    if (!SD.exists(s.c_str()))
    #else
    if (!SD.exists(s))
    #endif

  2. #2
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    537
    Quote Originally Posted by 0xABCD View Post
    Hi all,

    SD class overload "boolean exists(const String &filepath)" is missing.

    String s;

    #if defined(TEENSYDUINO)
    if (!SD.exists(s.c_str()))
    #else
    if (!SD.exists(s))
    #endif
    You can use SD.sdfs.exists(...); SD.h is now a thin wrapper for SdFat so to access SdFat specific functions that are not part of SD.h you can use SD.sdfs to access SdFat directly.
    What you are looking for is defined in "arduino-1.8.16/hardware/teensy/avr/libraries/SdFat/src/FatLib/FatVolume.h" Starting at line #253:
    Code:
       /**
       * Test for the existence of a file.
       *
       * \param[in] path Path of the file to be tested for.
       *
       * \return true if the file exists else false.
       */
      bool exists(const String& path) {
        return exists(path.c_str());
      }
    Do not know what version of Arduino or Teensyduino you are using but arduino-1.8.16 and Teensyduino 1.55 are the latest stable release.
    Is this what you are looking for?

  3. #3
    Junior Member
    Join Date
    Oct 2021
    Posts
    18
    Sorry, I missed the new SD card implementation for Teensy.
    https://forum.pjrc.com/threads/64136...t=SD.sdfs.open

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,077
    I've added String compatibility functions on github.

    https://github.com/PaulStoffregen/co...89e02fcb470d34

  5. #5
    Junior Member
    Join Date
    Oct 2021
    Posts
    18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •