diff --git a/CHANGELOG b/CHANGELOG index bdb19280eb..da99183c8d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ NEXT + - When using the running program to name screenshots and such, + filter out all invalid characters so that Windows users can + take snapshots even if junk characters are there (joncampbell123). - DOS FAT driver: If INT 13h reports disk change, adapt floppy disk geometry to new disk image according to media byte. This allows DS_BLISS to present it's 720K fake floppy even if the diff --git a/src/hardware/hardware.cpp b/src/hardware/hardware.cpp index 0aca9c5295..121441a85c 100644 --- a/src/hardware/hardware.cpp +++ b/src/hardware/hardware.cpp @@ -526,6 +526,11 @@ void ffmpeg_reopen_video(double fps,const int bpp) { } #endif +static char filtercapname(char c) { + if (c < 32 || c > 126 || c == '.' || c == '<' || c == '>' || c == '[' || c == ']' || c == '\\' || c == '/' || c == ':' || c == '\"' || c == '\'' || c == '?' || c == '*') return '_'; + return c; +} + std::string GetCaptureFilePath(const char * type,const char * ext) { if(capturedir.empty()) { LOG_MSG("Please specify a capture directory"); @@ -548,6 +553,7 @@ std::string GetCaptureFilePath(const char * type,const char * ext) { } strcpy(file_start,RunningProgram); lowcase(file_start); + for (char *s=(char*)file_start;*s;s++) *s = filtercapname(*s); strcat(file_start,"_"); bool is_directory; char tempname[CROSS_LEN], sname[15]; @@ -593,6 +599,7 @@ FILE * OpenCaptureFile(const char * type,const char * ext) { } strcpy(file_start,RunningProgram); lowcase(file_start); + for (char *s=(char*)file_start;*s;s++) *s = filtercapname(*s); strcat(file_start,"_"); bool is_directory; char tempname[CROSS_LEN], sname[15];