auto generated filename can be specified in options.txt with:

AutoBaseName = autoname
This commit is contained in:
penfold42 2018-07-20 12:30:20 +10:00
parent 1142e7ff45
commit 876f417edd
5 changed files with 25 additions and 11 deletions

View file

@ -34,6 +34,8 @@ extern "C"
#include "iec_commands.h" #include "iec_commands.h"
extern IEC_Commands m_IEC_Commands; extern IEC_Commands m_IEC_Commands;
extern Options options;
#define PNG_WIDTH 320 #define PNG_WIDTH 320
#define PNG_HEIGHT 200 #define PNG_HEIGHT 200
@ -898,8 +900,8 @@ void FileBrowser::UpdateInputFolders()
else if (inputMappings->BrowseNewD64()) else if (inputMappings->BrowseNewD64())
{ {
char newFileName[64]; char newFileName[64];
int num = folder.FindNextAutoName("testfile"); strncpy (newFileName, options.GetAutoBaseName(), 63);
snprintf(newFileName, 64, "testfile%03d.d64", num); int num = folder.FindNextAutoName( newFileName );
m_IEC_Commands.CreateD64(newFileName, "42"); m_IEC_Commands.CreateD64(newFileName, "42");
FolderChanged(); FolderChanged();
} }
@ -1253,16 +1255,17 @@ void FileBrowser::AutoSelectImage(const char* image)
} }
} }
int FileBrowser::BrowsableList::FindNextAutoName(const char* basename) int FileBrowser::BrowsableList::FindNextAutoName(char* filename)
{ {
int index; int index;
int len = (int)entries.size(); int len = (int)entries.size();
int baselen = strlen(basename);
int lastNumber = 0;
char matchname[64];
strcpy (matchname, basename); int inputlen = strlen(filename);
strncat (matchname, "%d",2); int lastNumber = 0;
char scanfname[64];
strncpy (scanfname, filename, 54);
strncat (scanfname, "%d",2);
int foundnumber; int foundnumber;
@ -1270,13 +1273,14 @@ int FileBrowser::BrowsableList::FindNextAutoName(const char* basename)
{ {
Entry* entry = &entries[index]; Entry* entry = &entries[index];
if ( !(entry->filImage.fattrib & AM_DIR) if ( !(entry->filImage.fattrib & AM_DIR)
&& strncasecmp(basename, entry->filImage.fname, baselen) == 0 && strncasecmp(filename, entry->filImage.fname, inputlen) == 0
&& sscanf(entry->filImage.fname, matchname, &foundnumber) == 1 && sscanf(entry->filImage.fname, scanfname, &foundnumber) == 1
) )
{ {
if (foundnumber > lastNumber) if (foundnumber > lastNumber)
lastNumber = foundnumber; lastNumber = foundnumber;
} }
} }
snprintf(filename + inputlen, 54, "%03d.d64", lastNumber+1);
return lastNumber+1; return lastNumber+1;
} }

View file

@ -151,7 +151,7 @@ public:
}; };
Entry* FindEntry(const char* name); Entry* FindEntry(const char* name);
int FindNextAutoName(const char* basename); int FindNextAutoName(char* basename);
void RefreshViews(); void RefreshViews();
void RefreshViewsHighlightScroll(); void RefreshViewsHighlightScroll();

View file

@ -1129,6 +1129,8 @@ void DisplayOptions(int y_pos)
screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "LcdLogoName = %s\r\n", options.GetLcdLogoName()); snprintf(tempBuffer, tempBufferSize, "LcdLogoName = %s\r\n", options.GetLcdLogoName());
screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "AutoBaseName = %s\r\n", options.GetAutoBaseName());
screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
} }
void DisplayI2CScan(int y_pos) void DisplayI2CScan(int y_pos)

View file

@ -152,6 +152,7 @@ Options::Options(void)
autoMountImageName[0] = 0; autoMountImageName[0] = 0;
strcpy(ROMFontName, "chargen"); strcpy(ROMFontName, "chargen");
strcpy(LcdLogoName, "1541ii"); strcpy(LcdLogoName, "1541ii");
strcpy(autoBaseName, "autoname");
starFileName[0] = 0; starFileName[0] = 0;
ROMName[0] = 0; ROMName[0] = 0;
ROMNameSlot2[0] = 0; ROMNameSlot2[0] = 0;
@ -224,6 +225,10 @@ void Options::Process(char* buffer)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimTime) ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimTime)
ELSE_CHECK_FLOAT_OPTION(scrollHighlightRate) ELSE_CHECK_FLOAT_OPTION(scrollHighlightRate)
ELSE_CHECK_DECIMAL_OPTION(keyboardBrowseLCDScreen) ELSE_CHECK_DECIMAL_OPTION(keyboardBrowseLCDScreen)
else if ((strcasecmp(pOption, "AutoBaseName") == 0))
{
strncpy(autoBaseName, pValue, 255);
}
else if ((strcasecmp(pOption, "StarFileName") == 0)) else if ((strcasecmp(pOption, "StarFileName") == 0))
{ {
strncpy(starFileName, pValue, 255); strncpy(starFileName, pValue, 255);

View file

@ -89,6 +89,8 @@ public:
const char* GetLCDName() const { return LCDName; } const char* GetLCDName() const { return LCDName; }
const char* GetAutoBaseName() const { return autoBaseName; }
static unsigned GetDecimal(char* pString); static unsigned GetDecimal(char* pString);
static float GetFloat(char* pString); static float GetFloat(char* pString);
@ -128,6 +130,7 @@ private:
unsigned int keyboardBrowseLCDScreen; unsigned int keyboardBrowseLCDScreen;
char starFileName[256]; char starFileName[256];
char autoBaseName[256];
char LCDName[256]; char LCDName[256];
char LcdLogoName[256]; char LcdLogoName[256];