summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@novell.com>2011-08-19 17:50:40 +0300
committerTor Lillqvist <tlillqvist@novell.com>2011-08-19 17:59:03 +0300
commita72c7acad90f9431c3b800327734ea00458dc3a0 (patch)
treea3794808ac2ba2250cb3f5759c6665f0e3e5de0f /i18npool
parentbb58d59e6479b8f2548574a561c64a17601b15a1 (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')
-rw-r--r--i18npool/source/breakiterator/gendict.cxx8
-rw-r--r--i18npool/source/collator/gencoll_rule.cxx11
-rw-r--r--i18npool/source/indexentry/genindex_data.cxx8
-rw-r--r--i18npool/source/textconversion/genconv_dict.cxx8
4 files changed, 18 insertions, 17 deletions
diff --git a/i18npool/source/breakiterator/gendict.cxx b/i18npool/source/breakiterator/gendict.cxx
index ab181be73836..369d4f8eff56 100644
--- a/i18npool/source/breakiterator/gendict.cxx
+++ b/i18npool/source/breakiterator/gendict.cxx
@@ -209,8 +209,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
dictionary_fp = fopen(argv[1], "rb"); // open the source file for read;
if (dictionary_fp == NULL)
{
- printf("Open the dictionary source file failed.");
- return -1;
+ fprintf(stderr, "Opening the dictionary source file %s for reading failed: %s\n", argv[1], strerror(errno));
+ exit(1);
}
if(argc == 2)
@@ -221,8 +221,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
source_fp = fopen(argv[2], "wb");
if (source_fp == NULL) {
fclose(dictionary_fp);
- printf("Can't create the C source file.");
- return -1;
+ fprintf(stderr, "Opening %s for writing failed: %s\n", argv[2], strerror(errno));
+ exit(1);
}
}
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;
diff --git a/i18npool/source/indexentry/genindex_data.cxx b/i18npool/source/indexentry/genindex_data.cxx
index 48ae02576a87..85424536a29d 100644
--- a/i18npool/source/indexentry/genindex_data.cxx
+++ b/i18npool/source/indexentry/genindex_data.cxx
@@ -51,8 +51,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
fp = fopen(argv[1], "rb"); // open the source file for read;
if (fp == NULL) {
- printf("Open the rule source file failed.");
- return 1;
+ fprintf(stderr, "Opening the rule source file %s for reading failed: %s\n", argv[1], strerror(errno));
+ exit(1);
}
@@ -97,8 +97,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
fp = fopen(argv[2], "wb");
if (fp == NULL) {
- printf("Can't create the C source file.");
- return 1;
+ fprintf(stderr, "Opening %s for writing failed: %s\n", argv[2], strerror(errno));
+ exit(1);
}
fprintf(fp, "/*\n");
diff --git a/i18npool/source/textconversion/genconv_dict.cxx b/i18npool/source/textconversion/genconv_dict.cxx
index 50c9fcffbe32..3882f60b6eaa 100644
--- a/i18npool/source/textconversion/genconv_dict.cxx
+++ b/i18npool/source/textconversion/genconv_dict.cxx
@@ -57,16 +57,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
sfp = fopen(argv[2], "rb"); // open the source file for read;
if (sfp == NULL)
{
- printf("Open the dictionary source file failed.");
- return -1;
+ fprintf(stderr, "Opening the dictionary source file %s for reading failed: %s\n", argv[1], strerror(errno));
+ exit(1);
}
// create the C source file to write
cfp = fopen(argv[3], "wb");
if (cfp == NULL) {
fclose(sfp);
- printf("Can't create the C source file.");
- return -1;
+ fprintf(stderr, "Opening %s for writing failed: %s\n", argv[3], strerror(errno));
+ exit(1);
}
fprintf(cfp, "/*\n");