Fixed issue #2327: Help button is broken in "SVN Commit Type" dialog
[TortoiseGit.git] / ext / hunspell / filemgr.cxx
blob1e98f40bc6994efef9ca2a37570b572c2fe58174
1 #include "license.hunspell"
2 #include "license.myspell"
4 #include <stdlib.h>
5 #include <string.h>
6 #include <stdio.h>
8 #include "filemgr.hxx"
10 int FileMgr::fail(const char * err, const char * par) {
11 fprintf(stderr, err, par);
12 return -1;
15 FileMgr::FileMgr(const char * file, const char * key) {
16 linenum = 0;
17 hin = NULL;
18 fin = fopen(file, "r");
19 if (!fin) {
20 // check hzipped file
21 char * st = (char *) malloc(strlen(file) + strlen(HZIP_EXTENSION) + 1);
22 if (st) {
23 strcpy(st, file);
24 strcat(st, HZIP_EXTENSION);
25 hin = new Hunzip(st, key);
26 free(st);
29 if (!fin && !hin) fail(MSG_OPEN, file);
32 FileMgr::~FileMgr()
34 if (fin) fclose(fin);
35 if (hin) delete hin;
38 char * FileMgr::getline() {
39 const char * l;
40 linenum++;
41 if (fin) return fgets(in, BUFSIZE - 1, fin);
42 if (hin && (l = hin->getline())) return strcpy(in, l);
43 linenum--;
44 return NULL;
47 int FileMgr::getlinenum() {
48 return linenum;