Not overwriting files during export, and instead adding a suffix to them.

Also greatly simplifying name sanitization.
This commit is contained in:
Rodrigo Damazio
2010-09-01 00:03:34 -03:00
parent b200b66612
commit f13c2455ea
4 changed files with 119 additions and 36 deletions
@@ -155,9 +155,14 @@ public class TrackWriter {
return false;
}
// Make sure the name will work on FAT
String fileName =
fileUtils.sanitizeName(track.getName() + "." + writer.getExtension());
// Make sure the file doesn't exist yet (possibly by changing the filename)
String fileName = fileUtils.buildUniqueFileName(
directory, track.getName(), writer.getExtension());
if (fileName == null) {
Log.e(MyTracksConstants.TAG, "Unable to get a unique filename for " + fileName);
return false;
}
Log.i(MyTracksConstants.TAG, "Writing track to: " + fileName);
try {
writer.prepare(track, newOutputStream(fileName));