]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/tex2rtf/src/rtfutils.cpp
added QueryRawValue() to wxRegKey and test code for it in the sample
[wxWidgets.git] / utils / tex2rtf / src / rtfutils.cpp
index d58191aa95069fcc63cf9ec819c1ad554aafb14e..735745b2c4f3579a61cdf8002be9a907682a28d6 100644 (file)
@@ -210,7 +210,7 @@ void OutputSectionKeyword(FILE *fd)
 {
   OutputCurrentSectionToString(wxBuffer);
   
-  int i;
+  unsigned int i;
   for (i = 0; i < strlen(wxBuffer); i++)
     if (wxBuffer[i] == ':')
       wxBuffer[i] = ' ';
@@ -349,7 +349,7 @@ void GenerateKeywordsForTopic(char *topic)
       SplitIndexEntry(s, buf1, buf2);
       
       // Check for ':' which messes up index
-      int i;
+      unsigned int i;
       for (i = 0; i < strlen(buf1) ; i++)
         if (buf1[i] == ':')
           buf1[i] = ' ';
@@ -536,11 +536,11 @@ bool WriteHPJ(char *filename)
   if (!helpTitle)
     helpTitle = "Untitled";
     
-  char *thePath = wxPathOnly(InputFile);
-  if (!thePath)
+  wxString thePath = wxPathOnly(InputFile);
+  if (thePath.IsEmpty())
     thePath = ".";
   fprintf(fd, "[OPTIONS]\n");
-  fprintf(fd, "BMROOT=%s ; Assume that bitmaps are where the source is\n", thePath);
+  fprintf(fd, "BMROOT=%s ; Assume that bitmaps are where the source is\n", thePath.c_str());
   fprintf(fd, "TITLE=%s\n", helpTitle);
   fprintf(fd, "CONTENTS=Contents\n");
 
@@ -5219,7 +5219,21 @@ bool RTFGo(void)
       wxConcatFiles("header.rtf", "chapters.rtf", "tmp1.rtf");
       Tex2RTFYield(TRUE);
       if (FileExists(OutputFile)) wxRemoveFile(OutputFile);
-      wxCopyFile("tmp1.rtf", OutputFile);
+      wxString cwdStr, outputDirStr;
+      cwdStr = wxGetWorkingDirectory();
+      outputDirStr = wxPathOnly(OutputFile);
+      // Determine if the temp file and the output file are in the same directory,
+      // and if they are, then just rename the temp file rather than copying
+      // it, as this is much faster when working with large (multi-megabyte files)
+      if ((wxStrcmp(wxPathOnly(OutputFile),"") == 0) ||  // no path specified on output file
+          (wxStrcmp(wxGetWorkingDirectory(),wxPathOnly(OutputFile)) == 0)) // paths do not match
+      {
+        wxRenameFile("tmp1.rtf", OutputFile);
+      }
+      else
+      {
+        wxCopyFile("tmp1.rtf", OutputFile);
+      }
       Tex2RTFYield(TRUE);
       wxRemoveFile("tmp1.rtf");
     }