From d7b7c269fe296687513cbca5448fe68fbe7b8a15 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 28 Aug 2015 09:57:53 -0600 Subject: layers: Handle bad filename in APIDump settings file If APIDumpLogFilename requested in vk_layer_settings.txt file has a bad path or cannot be opened for some other reason, then APIDump will write out an ERROR message w/ the bad filename and notify user that STDOUT will be used instead. --- vk-layer-generate.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 8c3d63c2..018e3abf 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -701,6 +701,13 @@ class APIDumpSubcommand(Subcommand): header_txt.append('#include ') header_txt.append('#include ') header_txt.append('') + header_txt.append('#include "vk_loader_platform.h"') + header_txt.append('#include "vk_layer.h"') + header_txt.append('#include "vk_struct_string_helper_cpp.h"') + header_txt.append('#include "vk_layer_table.h"') + header_txt.append('#include "vk_layer_extension_utils.h"') + header_txt.append('#include ') + header_txt.append('') header_txt.append('static std::ofstream fileStream;') header_txt.append('static std::string fileName = "vk_apidump.txt";') header_txt.append('std::ostream* outputStream = NULL;') @@ -709,7 +716,12 @@ class APIDumpSubcommand(Subcommand): header_txt.append(' if(writeToFile)') header_txt.append(' {') header_txt.append(' fileStream.open(fileName);') - header_txt.append(' outputStream = &fileStream;') + header_txt.append(' if ((fileStream.rdstate() & fileStream.failbit) != 0) {') + header_txt.append(' outputStream = &std::cout;') + header_txt.append(' (*outputStream) << endl << "APIDump ERROR: Bad output filename specified: " << fileName << ". Writing to STDOUT instead" << endl << endl;') + header_txt.append(' }') + header_txt.append(' else') + header_txt.append(' outputStream = &fileStream;') header_txt.append(' }') header_txt.append(' else') header_txt.append(' {') @@ -727,13 +739,6 @@ class APIDumpSubcommand(Subcommand): header_txt.append('}') header_txt.append('') header_txt.append('%s' % self.lineinfo.get()) - header_txt.append('#include "vk_loader_platform.h"') - header_txt.append('#include "vk_layer.h"') - header_txt.append('#include "vk_struct_string_helper_cpp.h"') - header_txt.append('#include "vk_layer_table.h"') - header_txt.append('#include "vk_layer_extension_utils.h"') - header_txt.append('#include ') - header_txt.append('') header_txt.append('// The following is #included again to catch certain OS-specific functions being used:') header_txt.append('#include "vk_loader_platform.h"') header_txt.append('') -- cgit v1.2.3