- int sz;
- char *buff, *lineptr;
- char linebuf[300];
-
- wxString title = _("noname"),
- safetitle,
- start = wxEmptyString,
- contents = wxEmptyString, index = wxEmptyString;
-
- if (wxIsAbsolutePath(book)) bookFull = book;
- else bookFull = wxGetCwd() + "/" + book;
-
- fi = fsys.OpenFile(bookFull);
- if (fi == NULL) return FALSE;
- fsys.ChangePathTo(bookFull);
- s = fi -> GetStream();
- sz = s -> GetSize();
- buff = new char[sz + 1];
- buff[sz] = 0;
- s -> Read(buff, sz);
- lineptr = buff;
- delete fi;
-
- do {
- lineptr = ReadLine(lineptr, linebuf);
-
- if (strstr(linebuf, "Title=") == linebuf)
- title = linebuf + strlen("Title=");
- if (strstr(linebuf, "Default topic=") == linebuf)
- start = linebuf + strlen("Default topic=");
- if (strstr(linebuf, "Index file=") == linebuf)
- index = linebuf + strlen("Index file=");
- if (strstr(linebuf, "Contents file=") == linebuf)
- contents = linebuf + strlen("Contents file=");
- } while (lineptr != NULL);
- delete[] buff;
-
- return AddBookParam(title, contents, index, start, fsys.GetPath());
+ return rt;
+ }
+ else
+ {
+ wxFSFile *fi;
+ wxFileSystem fsys;
+ wxInputStream *s;
+ wxString bookFull;
+
+ wxString title = _("noname"),
+ safetitle,
+ start = wxEmptyString,
+ contents = wxEmptyString,
+ index = wxEmptyString,
+ charset = wxEmptyString;
+
+#if defined(__WXMAC__) && !defined(__DARWIN__)
+ if (wxIsAbsolutePath(book)) bookFull = book;
+ else bookFull = wxGetCwd() + book; // no slash or dot
+ wxFileName fn( bookFull );
+ bookFull = fn.GetFullPath( wxPATH_UNIX );
+#else
+ if (wxIsAbsolutePath(book)) bookFull = book;
+ else bookFull = wxGetCwd() + "/" + book;
+#endif
+
+ fi = fsys.OpenFile(bookFull);
+ if (fi == NULL)
+ {
+ wxLogError(_("Cannot open HTML help book: %s"), bookFull.c_str());
+ return FALSE;
+ }
+ fsys.ChangePathTo(bookFull);
+ s = fi->GetStream();
+
+ int sz;
+ char *buff, *lineptr;
+ char linebuf[300];
+
+ sz = s->GetSize();
+ buff = new char[sz + 1];
+ buff[sz] = 0;
+ s->Read(buff, sz);
+ lineptr = buff;
+
+ do
+ {
+ lineptr = ReadLine(lineptr, linebuf, 300);
+
+ for (char *ch = linebuf; *ch != '\0' && *ch != '='; ch++)
+ *ch = tolower(*ch);
+
+ if (strstr(linebuf, "title=") == linebuf)
+ title = linebuf + strlen("title=");
+ if (strstr(linebuf, "default topic=") == linebuf)
+ start = linebuf + strlen("default topic=");
+ if (strstr(linebuf, "index file=") == linebuf)
+ index = linebuf + strlen("index file=");
+ if (strstr(linebuf, "contents file=") == linebuf)
+ contents = linebuf + strlen("contents file=");
+ if (strstr(linebuf, "charset=") == linebuf)
+ charset = linebuf + strlen("charset=");
+ } while (lineptr != NULL);
+ delete[] buff;
+
+ wxFontEncoding enc;
+ if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
+ else enc = wxTheFontMapper->CharsetToEncoding(charset);
+ bool rtval = AddBookParam(*fi, enc,
+ title, contents, index, start, fsys.GetPath());
+ delete fi;
+ return rtval;
+ }