Skip to content

Commit

Permalink
Filter name fully when choosing the capture file [joncampbell123#5125]
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Jul 19, 2024
1 parent ec9b0f2 commit 27cd855
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/hardware/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 27cd855

Please sign in to comment.