From 2e3bba9a37cdc8e40e3482e72287881640a11744 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Fri, 26 Apr 2013 19:22:31 -0400 Subject: [PATCH] Support for multiple screen shot files using screenshot_###.bmp filenames. --- NEWS.txt | 10 ++++++++++ docs/refind/using.html | 2 +- install.sh | 2 +- libeg/image.c | 2 +- libeg/libeg.h | 1 + libeg/screen.c | 19 ++++++++++++++++--- refind/main.c | 2 +- 7 files changed, 31 insertions(+), 7 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index f813b2e..afadc18 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,3 +1,13 @@ +0.6.10 (?/??/2013): +------------------- + +- Replaced hexadecimal error code with description if an error is + encountered when saving a screen shot. + +- Enable multiple screen shots: Rather than naming all screen shots + "screenshot.bmp", the name is now "screenshot_###.bmp", where "###" is a + sequence number, starting with "001". + 0.6.9 (4/25/2013): ------------------ diff --git a/docs/refind/using.html b/docs/refind/using.html index 091e670..b7b6933 100644 --- a/docs/refind/using.html +++ b/docs/refind/using.html @@ -266,7 +266,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

F10 - Saves an image of the current screen in the file screenshot.bmp in the ESP's root directory + Saves an image of the current screen in the file screenshot_###.bmp, where ### is a sequence number starting with 001, in the ESP's root directory F12 or (on some keyboards) Eject diff --git a/install.sh b/install.sh index 66d3e9c..1d722e8 100755 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ # # Revision history: # -# 0.6.9 -- Install gptsync on Macs if evidence of Windows found +# 0.6.9 -- Install gptsync on Macs # 0.6.8 -- Bug fix: ESP scan now uses "uniq". # 0.6.6 -- Bug fix: Upgrade drivers when installed to EFI/BOOT. Also enable # copying shim.efi and MokManager.efi over themselves. diff --git a/libeg/image.c b/libeg/image.c index c529da9..8b6078d 100644 --- a/libeg/image.c +++ b/libeg/image.c @@ -175,7 +175,7 @@ EFI_STATUS egLoadFile(IN EFI_FILE* BaseDir, IN CHAR16 *FileName, OUT UINT8 **Fil static EFI_GUID ESPGuid = { 0xc12a7328, 0xf81f, 0x11d2, { 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b } }; -static EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir) +EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir) { EFI_STATUS Status; UINTN HandleCount = 0; diff --git a/libeg/libeg.h b/libeg/libeg.h index 0275410..80731e4 100644 --- a/libeg/libeg.h +++ b/libeg/libeg.h @@ -112,6 +112,7 @@ EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN UINTN Width, IN UINTN Height EFI_STATUS egLoadFile(IN EFI_FILE* BaseDir, IN CHAR16 *FileName, OUT UINT8 **FileData, OUT UINTN *FileDataLength); +EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir); EFI_STATUS egSaveFile(IN EFI_FILE* BaseDir OPTIONAL, IN CHAR16 *FileName, IN UINT8 *FileData, IN UINTN FileDataLength); diff --git a/libeg/screen.c b/libeg/screen.c index 9049d85..4b9c580 100644 --- a/libeg/screen.c +++ b/libeg/screen.c @@ -46,6 +46,7 @@ #include "../refind/screen.h" #include "../refind/lib.h" #include "../include/refit_call_wrapper.h" +#include "libeg.h" #include #include @@ -477,6 +478,9 @@ VOID egScreenShot(VOID) UINT8 *FileData; UINTN FileDataLength; UINTN Index; + UINTN ssNum; + CHAR16 Filename[80]; + EFI_FILE* BaseDir; Image = egCopyScreen(); if (Image == NULL) { @@ -492,11 +496,20 @@ VOID egScreenShot(VOID) goto bailout_wait; } + Status = egFindESP(&BaseDir); + if (EFI_ERROR(Status)) + return; + + // Search for existing screen shot files; increment number to an unused value... + ssNum = 001; + do { + SPrint(Filename, 80, L"screenshot_%03d.bmp", ssNum++); + } while (FileExists(BaseDir, Filename)); + // save to file on the ESP - Status = egSaveFile(NULL, L"screenshot.bmp", FileData, FileDataLength); + Status = egSaveFile(BaseDir, Filename, FileData, FileDataLength); FreePool(FileData); - if (EFI_ERROR(Status)) { - Print(L"Error egSaveFile: %x\n", Status); + if (CheckError(Status, L"in egSaveFile()")) { goto bailout_wait; } diff --git a/refind/main.c b/refind/main.c index f0803a5..cca2d18 100644 --- a/refind/main.c +++ b/refind/main.c @@ -135,7 +135,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.9"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.6.9.1"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2013 Roderick W. Smith"); -- 2.39.2