I found this:
//------------------------------------------------------------------------------
/** Get a file's name
*
* \param[out] name An array of 13 characters for the file's name.
*
* \return The value one, true, is returned for success and
* the value zero, false, is returned for failure.
*/
bool SdBaseFile::getFilename(char* name) {
dir_t* p;
if (!isOpen()) {
DBG_FAIL_MACRO;
goto fail;
}
if (isRoot()) {
name[0] = '/';
name[1] = '\0';
return true;
}
// cache entry
p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
if (!p) {
DBG_FAIL_MACRO;
goto fail;
}
// format name
dirName(*p, name);
return true;
fail:
return false;
}
However this is big boys code, and I cant understand what it means exactly, where the name of the file actually goes...
* \param[out] name An array of 13 characters for the file's name.
what is this param[out] exactly?
or is that wrong...
Is it if I start at the begining of the directory, and call that function, it will tell me yes/no if the file exists...
ie
boolean SongPresent = getFilename("0001.mp3");
?
I could possibly make that work, but ideally I want to start at the beginning of the root directory, and scan through all the files on the card, returning the name of the file, ideally just the name, saving it into an int array.
hmm. The search continues.
*EDIT* Actually, this would be better for that example
//------------------------------------------------------------------------------
/** Test for the existence of a file in a directory
*
* \param[in] name Name of the file to be tested for.
*
* The calling instance must be an open directory file.
*
* dirFile.exists("TOFIND.TXT") searches for "TOFIND.TXT" in the directory
* dirFile.
*
* \return true if the file exists else false.
*/
bool SdBaseFile::exists(const char* name) {
SdBaseFile file;
return file.open(this, name, O_READ);
Not really sure what the one above is for.