diff options
| author | Tobin Ehlis <tobin@lunarg.com> | 2015-08-28 09:57:53 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobin@lunarg.com> | 2015-08-28 10:30:07 -0600 |
| commit | d7b7c269fe296687513cbca5448fe68fbe7b8a15 (patch) | |
| tree | 147313d7fe29fc4a7c3a4b437041fe844690462b | |
| parent | 74f400bb35120d405f78b9aaab28dcc1de374ccf (diff) | |
| download | usermoji-d7b7c269fe296687513cbca5448fe68fbe7b8a15.tar.xz | |
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.
| -rwxr-xr-x | vk-layer-generate.py | 21 |
1 files 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 <string>') header_txt.append('#include <string.h>') 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 <unordered_map>') + 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 <unordered_map>') - 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('') |
