Skip to content

Commit

Permalink
New meta folder removal. No more MacOS garbage files!
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanHockey5 committed Aug 5, 2019
1 parent 5da70cc commit 0c45ea9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Schematic/YM2612_MIDI_SMD/bom/ibom.html

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Default AVRDUDE command is:
avrdude -c arduino -p usb1286 -P COM16 -b 19200 -U flash:w:"LOCATION_OF_YOUR_PROJECT_FOLDER\.pioenvs\teensy20pp\firmware.hex":a -U lfuse:w:0x5E:m -U hfuse:w:0xDF:m -U efuse:w:0xF3:m
*/

#define FW_VERSION "1.2.6"
#define FW_VERSION "1.2.7"



Expand Down Expand Up @@ -135,7 +135,7 @@ void ClearLCDLine(byte line);
bool LoadFile(String req);
void PutFavoriteIntoEEPROM(Voice v, uint16_t index);
void SetVoice(Voice v);
void removeSVI();
void removeMeta();
void ReadVoiceData();
void HandleSerialIn();
void DumpVoiceData(Voice v);
Expand Down Expand Up @@ -224,8 +224,8 @@ void setup()
Serial.println("SD Mount failed!");
SDReadFailure();
}
removeMeta();
attachInterrupt(digitalPinToInterrupt(ENC_BTN), HandleRotaryButtonDown, FALLING);
removeSVI();
LoadFile(FIRST_FILE);
ReadVoiceData();
ym2612.SetVoice(voices[0]);
Expand Down Expand Up @@ -439,20 +439,31 @@ bool LoadFile(String req) //Request a file (string) to load
return true;
}

void removeSVI() //Sometimes, Windows likes to place invisible files in our SD card without asking... GTFO!
void removeMeta() //Remove useless meta files
{
File nextFile;
nextFile.openNext(SD.vwd(), O_READ);
char name[MAX_FILE_NAME_SIZE];
nextFile.getName(name, MAX_FILE_NAME_SIZE);
String n = String(name);
if(n == "System Volume Information")
File countFile;

while ( countFile.openNext( SD.vwd(), O_READ ))
{
if(!nextFile.rmRfStar())
Serial.println("Failed to remove SVI file");
memset(fileName, 0x00, MAX_FILE_NAME_SIZE);
countFile.getName(fileName, MAX_FILE_NAME_SIZE);
if(fileName[0]=='.')
{
if(!SD.remove(fileName))
if(!countFile.rmRfStar())
{
Serial.print("FAILED TO DELETE META FILE"); Serial.println(fileName);
}
}
if(String(fileName) == "System Volume Information")
{
if(!countFile.rmRfStar())
Serial.println("FAILED TO REMOVE SVI");
}
countFile.close();
}
countFile.close();
SD.vwd()->rewind();
nextFile.close();
}

void HandleRotaryButtonDown()
Expand Down

0 comments on commit 0c45ea9

Please sign in to comment.