]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/chm.cpp
Move code that does not need realized GdkWinow out of realize handler
[wxWidgets.git] / src / html / chm.cpp
index 6eb0e21dac1b5dc601b6514db8dda8efa50a4f4d..cf3e04925e4e00b57f7c1bc470c5029af35b6c8e 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     CHM (Help) support for wxHTML
 // Author:      Markus Sinner
 // Copyright:   (c) 2003 Herd Software Development
-// CVS-ID:      $Id$
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
@@ -563,7 +562,6 @@ void
 wxChmInputStream::CreateHHPStream()
 {
     wxFileName file;
-    bool topic = false;
     bool hhc = false;
     bool hhk = false;
     wxInputStream *i;
@@ -619,8 +617,11 @@ wxChmInputStream::CreateHHPStream()
             switch (code)
             {
                 case 0: // CONTENTS_FILE
-                    tmp = "Contents file=";
-                    hhc=true;
+                    if (len)
+                    {
+                        tmp = "Contents file=";
+                        hhc=true;
+                    }
                     break;
                 case 1: // INDEX_FILE
                     tmp = "Index file=";
@@ -628,7 +629,6 @@ wxChmInputStream::CreateHHPStream()
                     break;
                 case 2: // DEFAULT_TOPIC
                     tmp = "Default Topic=";
-                    topic = true;
                     break;
                 case 3: // TITLE
                     tmp = "Title=";
@@ -649,9 +649,10 @@ wxChmInputStream::CreateHHPStream()
                         // LCID at position 0
                         wxUint32 dummy = *((wxUint32 *)(structptr+0)) ;
                         wxUint32 lcid = wxUINT32_SWAP_ON_BE( dummy ) ;
-                        wxString msg ;
-                        msg.Printf(wxT("Language=0x%X\r\n"),lcid) ;
-                        out->Write(msg.c_str() , msg.length() ) ;
+                        char msg[64];
+                        int len = sprintf(msg, "Language=0x%X\r\n", lcid) ;
+                        if (len > 0)
+                            out->Write(msg, len) ;
                     }
                     break ;
                 default:
@@ -838,6 +839,8 @@ wxFSFile* wxChmFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
     }
 
     wxFileName leftFilename = wxFileSystem::URLToFileName(left);
+    if (!leftFilename.FileExists())
+        return NULL;
 
     // Open a stream to read the content of the chm-file
     s = new wxChmInputStream(leftFilename.GetFullPath(), right, true);
@@ -848,7 +851,7 @@ wxFSFile* wxChmFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
                             left + wxT("#chm:") + right,
                             wxEmptyString,
                             GetAnchor(location),
-                            wxDateTime(wxFileModificationTime(left)));
+                            wxDateTime(leftFilename.GetModificationTime()));
     }
 
     delete s;