diff options
author | Tor Lillqvist <tlillqvist@novell.com> | 2011-08-19 17:50:40 +0300 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@novell.com> | 2011-08-19 17:59:03 +0300 |
commit | a72c7acad90f9431c3b800327734ea00458dc3a0 (patch) | |
tree | a3794808ac2ba2250cb3f5759c6665f0e3e5de0f /i18npool/source/collator | |
parent | bb58d59e6479b8f2548574a561c64a17601b15a1 (diff) |
Improve input and output file open error handling
Tell file name and actual error in error message. Print error message
to stderr. Always exit with failure when not able to open an input or
output file.
Diffstat (limited to 'i18npool/source/collator')
-rw-r--r-- | i18npool/source/collator/gencoll_rule.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx index c678230b0f1d..9f0ae9e06041 100644 --- a/i18npool/source/collator/gencoll_rule.cxx +++ b/i18npool/source/collator/gencoll_rule.cxx @@ -48,8 +48,8 @@ void data_write(char* file, char* name, sal_uInt8 *data, sal_Int32 len) { FILE *fp = fopen(file, "wb"); if (fp == NULL) { - printf("Can't create the C source file."); - return; + fprintf(stderr, "Opening %s for writing failed: %s\n", file, strerror(errno)); + exit(1); } fprintf(fp, "/*\n"); @@ -87,9 +87,10 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) if (argc < 4) exit(-1); fp = fopen(argv[1], "rb"); // open the source file for read; - if (fp == NULL) - printf("Open the rule source file failed."); - + if (fp == NULL){ + fprintf(stderr, "Opening the rule source file %s for reading failed: %s\n", argv[1], strerror(errno)); + exit(1); + } sal_Char str[1024]; OUStringBuffer Obuf; |