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

0xABCD

Member
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
 
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?
 
Back
Top