本文整理汇总了C++中SdFile::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFile::getName方法的具体用法?C++ SdFile::getName怎么用?C++ SdFile::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdFile
的用法示例。
在下文中一共展示了SdFile::getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enumerateGIFFiles
// Enumerate and possibly display the animated GIF filenames in GIFS directory
int enumerateGIFFiles(const char *directoryName, boolean displayFilenames) {
numberOfFiles = 0;
// Set the current working directory
if (! sd.chdir(directoryName, true)) {
sd.errorHalt("Could not change to gifs directory");
}
sd.vwd()->rewind();
char fn[13];
while (file.openNext(sd.vwd(), O_READ)) {
file.getName(fn, 13);
// If filename not deleted, count it
if (fn[0] != '_') {
numberOfFiles++;
if (displayFilenames) {
Serial.println(fn);
delay(20);
}
}
file.close();
}
// Set the current working directory
if (! sd.chdir("/", true)) {
sd.errorHalt("Could not change to root directory");
}
return numberOfFiles;
}
示例2: getGIFFilenameByIndex
// Get the full path/filename of the GIF file with specified index
void getGIFFilenameByIndex(const char *directoryName, int index, char *pnBuffer) {
char filename[13];
// Make sure index is in range
if ((index >= 0) && (index < numberOfFiles)) {
// Set the current working directory
if (! sd.chdir(directoryName, true)) {
sd.errorHalt("Could not change to gifs directory");
}
// Make sure file is closed before starting
file.close();
// Rewind the directory to the beginning
sd.vwd()->rewind();
while ((file.openNext(sd.vwd(), O_READ)) && (index >= 0)) {
file.getName(filename, 13);
// If filename is not marked as deleted, count it
if ((filename[0] != '_') && (filename[0] != '~')) {
index--;
}
file.close();
}
// Set the current working directory back to root
if (! sd.chdir("/", true)) {
sd.errorHalt("Could not change to root directory");
}
// Copy the directory name into the pathname buffer
strcpy(pnBuffer, directoryName);
// Append the filename to the pathname
strcat(pnBuffer, filename);
}
}
示例3: if
void MP3Player::PlayTrack(const char* dirName,int track_no,const char* track_name)
{
if(!PLAY)
{
finishSearch = false;
int count=0;
//if(track_no>0)
//counter = track_no;
if(!isPlayAll)
{
char temp[20];
isPlayAll = true;
sd.chdir();delayMicroseconds(100000);
sd.chdir(dirName,true);
sd.vwd()->rewind();
sd.vwd()->getName(temp,20);
currentDir = temp;
counter = 0;
}
while(true)
{
if(myFile.openNext(myFile.cwd(), O_READ))
{
char FileName[80];
myFile.getName(FileName,80);
#if DEBUG
//myFile.printName(&Serial);
Serial.print(FileName);
if (myFile.isDir())
{
// Indicate a directory.
Serial.write('/');
}
Serial.println();
#endif
if (!(myFile.isDir()||(String(FileName).indexOf(".mp3")==-1&&String(FileName).indexOf(".MP3")==-1)))
{
counter++;
if(ls_flag)
{
Serial.print(counter);
Serial.print(". ");
Serial.print(FileName);
Serial.print(" ");
Serial.print(myFile.fileSize());
Serial.println(" bytes");
myFile.close();
continue;
}
//Play(FileName);
if(!String(track_name).equals(""))
{
//counter++;
if(String(track_name).equals(FileName))
{
Play(FileName);
//name = track_name;
isPlayAll = false;
break;
}
}
else if(track_no==0)
{
//counter++;
Play(FileName);
break;
}
else if(track_no>0)
{
count++;
if(count==track_no)
{
counter = track_no;
Play(FileName);
isPlayAll = false;
break;
}
}
}
}
else
{
isPlayAll = false;
finishSearch = true;
ls_flag = false;
break;
}
//myFile.getFilename(FileName);
myFile.close();
}
//.........这里部分代码省略.........