1
0
Fork 0

Changes for 1 global capture directory

Support for capturing raw midi
Support for capturing raw opl


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1863
This commit is contained in:
Sjoerd van der Berg 2004-07-04 21:02:22 +00:00
parent ba9a2cc546
commit b1cebeed4e
3 changed files with 54 additions and 18 deletions

View file

@ -20,14 +20,55 @@
This could do with a serious revision :)
*/
#include <dirent.h>
#include <string.h>
#include "dosbox.h"
#include "programs.h"
#include "hardware.h"
#include "setup.h"
#include "support.h"
static char * capturedir;
extern char * RunningProgram;
FILE * OpenCaptureFile(const char * type,const char * ext) {
Bitu last=0;
char file_name[CROSS_LEN];
char file_start[16];
DIR * dir;struct dirent * dir_ent;
/* Find a filename to open */
dir=opendir(capturedir);
if (!dir) {
LOG_MSG("Can't open dir %s for capturing %s",capturedir,type);
return 0;
}
strcpy(file_start,RunningProgram);
strcat(file_start,"_");
while ((dir_ent=readdir(dir))) {
char tempname[CROSS_LEN];
strcpy(tempname,dir_ent->d_name);
char * test=strstr(tempname,ext);
if (!test || strlen(test)!=strlen(ext)) continue;
*test=0;
if (strncasecmp(tempname,file_start,strlen(file_start))!=0) continue;
Bitu num=atoi(&tempname[strlen(file_start)]);
if (num>=last) last=num+1;
}
closedir(dir);
sprintf(file_name,"%s%c%s%03d%s",capturedir,CROSS_FILESPLIT,file_start,last,ext);
lowcase(file_name);
/* Open the actual file */
FILE * handle=fopen(file_name,"wb");
if (handle) {
LOG_MSG("Capturing %s to %s",type,file_name);
} else {
LOG_MSG("Failed to open %s for capturing %s",file_name,type);
}
return handle;
}
void HARDWARE_Init(Section * sec) {
Section_prop * section=static_cast<Section_prop *>(sec);
capturedir=(char *)section->Get_string("captures");
}