Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/hardware/hardware.cpp')
-rw-r--r--src/hardware/hardware.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/hardware/hardware.cpp b/src/hardware/hardware.cpp
index 5ee309a13..db8b9ec0f 100644
--- a/src/hardware/hardware.cpp
+++ b/src/hardware/hardware.cpp
@@ -92,30 +92,33 @@ static struct {
} capture = {};
-FILE * OpenCaptureFile(const char * type,const char * ext) {
- if(capturedir.empty()) {
+std::string CAPTURE_GetScreenshotFilename(const char *type, const char *ext)
+{
+ if (capturedir.empty()) {
LOG_MSG("Please specify a capture directory");
return 0;
}
+ char file_start[16];
+ dir_information *dir;
/* Find a filename to open */
- dir_information *dir = open_directory(capturedir.c_str());
+ dir = open_directory(capturedir.c_str());
if (!dir) {
// Try creating it first
if (create_dir(capturedir.c_str(), 0700, OK_IF_EXISTS) != 0) {
- LOG_MSG("ERROR: Can't create dir '%s': %s",
- capturedir.c_str(), safe_strerror(errno).c_str());
+ LOG_WARNING("Can't create dir '%s' for capturing: %s",
+ capturedir.c_str(),
+ safe_strerror(errno).c_str());
+ return 0;
}
-
dir = open_directory(capturedir.c_str());
if (!dir) {
- LOG_MSG("ERROR: Can't open dir '%s' for capturing %s",
- capturedir.c_str(), type);
+ LOG_MSG("Can't open dir %s for capturing %s",
+ capturedir.c_str(),
+ type);
return 0;
}
}
-
- char file_start[16];
safe_strcpy(file_start, RunningProgram);
lowcase(file_start);
strcat(file_start,"_");
@@ -137,12 +140,17 @@ FILE * OpenCaptureFile(const char * type,const char * ext) {
char file_name[CROSS_LEN];
sprintf(file_name, "%s%c%s%03d%s",
capturedir.c_str(), CROSS_FILESPLIT, file_start, last, ext);
- /* Open the actual file */
- FILE * handle=fopen(file_name,"wb");
+ return file_name;
+}
+
+FILE *OpenCaptureFile(const char *type, const char *ext)
+{
+ const auto file_name = CAPTURE_GetScreenshotFilename(type, ext);
+ FILE *handle = fopen(file_name.c_str(), "wb");
if (handle) {
- LOG_MSG("Capturing %s to %s",type,file_name);
+ LOG_MSG("Capturing %s to %s", type, file_name.c_str());
} else {
- LOG_MSG("Failed to open %s for capturing %s",file_name,type);
+ LOG_MSG("Failed to open %s for capturing %s", file_name.c_str(), type);
}
return handle;
}