wxGetWorkingDirectory() deprecated. Fixed #1338966.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-11-07 13:27:09 +00:00
parent f3e874756b
commit ce045aed58
7 changed files with 322 additions and 288 deletions

View File

@@ -8,6 +8,7 @@ wxWidgets Change Log - For more verbose changes, see the manual
All: All:
- wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag - wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag
- wxGetWorkingDirectory() deprecated. Use wxGetCwd() instead.
All (GUI): All (GUI):

View File

@@ -1,3 +1,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: function.tex
%% Purpose: Functions and macros
%% Author: wxWidgets Team
%% Modified by:
%% Created:
%% RCS-ID: $Id$
%% Copyright: (c) wxWidgets Team
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Functions}\label{functions} \chapter{Functions}\label{functions}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage} \setfooter{\thepage}{}{}{}{}{\thepage}
@@ -1122,7 +1133,7 @@ Returns a string containing the current (or working) directory.
\func{wxString}{wxGetWorkingDirectory}{\param{char *}{buf=NULL}, \param{int }{sz=1000}} \func{wxString}{wxGetWorkingDirectory}{\param{char *}{buf=NULL}, \param{int }{sz=1000}}
{\bf NB:} This function is obsolete: use \helpref{wxGetCwd}{wxgetcwd} instead. {\bf NB:} This function is deprecated: use \helpref{wxGetCwd}{wxgetcwd} instead.
Copies the current working directory into the buffer if supplied, or Copies the current working directory into the buffer if supplied, or
copies the working directory into new storage (which you {\emph must} delete copies the working directory into new storage (which you {\emph must} delete
@@ -4472,4 +4483,3 @@ Removes the variable {\it var} from the environment.
function. function.
Returns \true on success. Returns \true on success.

View File

@@ -1,3 +1,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: image.tex
%% Purpose: wxImage documentation
%% Author: wxWidgets Team
%% Modified by:
%% Created:
%% RCS-ID: $Id$
%% Copyright: (c) wxWidgets Team
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxImage}}\label{wximage} \section{\class{wxImage}}\label{wximage}
This class encapsulates a platform-independent image. An image can be created This class encapsulates a platform-independent image. An image can be created
@@ -410,7 +421,7 @@ It is usually a good idea to prepend a description before passing the result to
Example: Example:
\begin{verbatim} \begin{verbatim}
wxFileDialog FileDlg( this, "Choose Image", ::wxGetWorkingDirectory(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN ); wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN );
\end{verbatim} \end{verbatim}
\wxheading{See also} \wxheading{See also}
@@ -1436,4 +1447,3 @@ Sets the handler type.
\wxheading{Parameters} \wxheading{Parameters}
\docparam{name}{Handler type.} \docparam{name}{Handler type.}

View File

@@ -438,13 +438,15 @@ WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2); WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2);
// Get current working directory. // Get current working directory.
#if WXWIN_COMPATIBILITY_2_6
// If buf is NULL, allocates space using new, else // If buf is NULL, allocates space using new, else
// copies into buf. // copies into buf.
// IMPORTANT NOTE getcwd is know not to work under some releases // IMPORTANT NOTE getcwd is know not to work under some releases
// of Win32s 1.3, according to MS release notes! // of Win32s 1.3, according to MS release notes!
WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000); wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000) );
// new and preferred version of wxGetWorkingDirectory // new and preferred version of wxGetWorkingDirectory
// NB: can't have the same name because of overloading ambiguity // NB: can't have the same name because of overloading ambiguity
#endif // WXWIN_COMPATIBILITY_2_6
WXDLLIMPEXP_BASE wxString wxGetCwd(); WXDLLIMPEXP_BASE wxString wxGetCwd();
// Set working directory // Set working directory

View File

@@ -276,8 +276,7 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file)
if ( f.empty() || wxIsAbsolutePath(f) ) if ( f.empty() || wxIsAbsolutePath(f) )
return f; return f;
wxString buf; wxString buf = ::wxGetCwd();
wxGetWorkingDirectory(wxStringBuffer(buf, _MAXPATHLEN), _MAXPATHLEN);
if ( !wxEndsWithPathSeparator(buf) ) if ( !wxEndsWithPathSeparator(buf) )
{ {
@@ -365,8 +364,8 @@ void wxStripExtension(wxChar *buffer)
void wxStripExtension(wxString& buffer) void wxStripExtension(wxString& buffer)
{ {
//RN: Be careful about the handling the case where //RN: Be careful about the handling the case where
//buffer.Length() == 0 //buffer.length() == 0
for(size_t i = buffer.Length() - 1; i != wxString::npos; --i) for(size_t i = buffer.length() - 1; i != wxString::npos; --i)
{ {
if (buffer.GetChar(i) == wxT('.')) if (buffer.GetChar(i) == wxT('.'))
{ {
@@ -432,28 +431,38 @@ wxChar *wxRealPath (wxChar *path)
return path; return path;
} }
wxString wxRealPath(const wxString& path)
{
wxChar *buf1=MYcopystring(path);
wxChar *buf2=wxRealPath(buf1);
wxString buf(buf2);
delete [] buf1;
return buf;
}
// Must be destroyed // Must be destroyed
wxChar *wxCopyAbsolutePath(const wxString& filename) wxChar *wxCopyAbsolutePath(const wxString& filename)
{ {
if (filename.empty()) if (filename.empty())
return (wxChar *) NULL; return (wxChar *) NULL;
if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer, filename))) { if (! wxIsAbsolutePath(wxExpandPath(wxFileFunctionsBuffer, filename)))
wxChar buf[_MAXPATHLEN]; {
buf[0] = wxT('\0'); wxString buf = ::wxGetCwd();
wxGetWorkingDirectory(buf, WXSIZEOF(buf)); wxChar ch = buf.Last();
wxChar ch = buf[wxStrlen(buf) - 1];
#ifdef __WXMSW__ #ifdef __WXMSW__
if (ch != wxT('\\') && ch != wxT('/')) if (ch != wxT('\\') && ch != wxT('/'))
wxStrcat(buf, wxT("\\")); buf << wxT("\\");
#else #else
if (ch != wxT('/')) if (ch != wxT('/'))
wxStrcat(buf, wxT("/")); buf << wxT("/");
#endif #endif
wxStrcat(buf, wxFileFunctionsBuffer); buf << wxFileFunctionsBuffer;
return MYcopystring( wxRealPath(buf) ); buf = wxRealPath( buf );
} return MYcopystring( buf );
return MYcopystring( wxFileFunctionsBuffer ); }
return MYcopystring( wxFileFunctionsBuffer );
} }
/*- /*-
@@ -790,7 +799,7 @@ wxString wxPathOnly (const wxString& path)
// Local copy // Local copy
wxStrcpy (buf, WXSTRINGCAST path); wxStrcpy (buf, WXSTRINGCAST path);
int l = path.Length(); int l = path.length();
int i = l - 1; int i = l - 1;
// Search backward for a backward or forward slash // Search backward for a backward or forward slash
@@ -1331,17 +1340,21 @@ wxString wxFindNextFile()
// Get current working directory. // Get current working directory.
// If buf is NULL, allocates space using new, else // If buf is NULL, allocates space using new, else copies into buf.
// copies into buf. // wxGetWorkingDirectory() is obsolete, use wxGetCwd()
wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) // wxDoGetCwd() is their common core to be moved
// to wxGetCwd() once wxGetWorkingDirectory() will be removed.
// Do not expose wxDoGetCwd in headers!
wxChar *wxDoGetCwd(wxChar *buf, int sz)
{ {
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
// TODO ? // TODO
if(buf && sz>0) buf[0] = _T('\0');
return NULL; return NULL;
#elif defined(__WXWINCE__) #elif defined(__WXWINCE__)
// TODO // TODO
wxUnusedVar(buf); if(buf && sz>0) buf[0] = _T('\0');
wxUnusedVar(sz);
return NULL; return NULL;
#else #else
if ( !buf ) if ( !buf )
@@ -1464,13 +1477,17 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
// __WXWINCE__ // __WXWINCE__
} }
#if WXWIN_COMPATIBILITY_2_6
wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
{
return wxDoGetCwd(buf,sz);
}
#endif // WXWIN_COMPATIBILITY_2_6
wxString wxGetCwd() wxString wxGetCwd()
{ {
wxChar *buffer = new wxChar[_MAXPATHLEN]; wxString str;
wxGetWorkingDirectory(buffer, _MAXPATHLEN); wxDoGetCwd(wxStringBuffer(str, _MAXPATHLEN), _MAXPATHLEN);
wxString str( buffer );
delete [] buffer;
return str; return str;
} }

View File

@@ -238,9 +238,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile)
file = ifile; file = ifile;
if(! wxIsAbsolutePath(file)) if(! wxIsAbsolutePath(file))
{ {
wxChar* f = wxGetWorkingDirectory(); file = wxGetCwd();
file = f;
delete[] f; // wxGetWorkingDirectory returns new memory
#ifdef __WXMAC__ #ifdef __WXMAC__
file << ifile; file << ifile;
#else #else
@@ -348,7 +346,7 @@ wxExtHelpController::DisplayContents()
file << m_MapFile << WXEXTHELP_SEPARATOR << contents; file << m_MapFile << WXEXTHELP_SEPARATOR << contents;
if(file.Contains(wxT('#'))) if(file.Contains(wxT('#')))
file = file.BeforeLast(wxT('#')); file = file.BeforeLast(wxT('#'));
if(contents.Length() && wxFileExists(file)) if(contents.length() && wxFileExists(file))
rc = DisplaySection(CONTENTS_ID); rc = DisplaySection(CONTENTS_ID);
// if not found, open homemade toc: // if not found, open homemade toc:
@@ -466,4 +464,3 @@ void wxExtHelpController::OnQuit()
#endif // wxUSE_HELP #endif // wxUSE_HELP

View File

@@ -5146,200 +5146,197 @@ bool RTFOnArgument(int macroId, int arg_no, bool start)
bool RTFGo(void) bool RTFGo(void)
{ {
if (stopRunning)
return false;
// Reset variables
indentLevel = 0;
forbidParindent = 0;
contentsLineSection = NULL;
contentsLineValue = NULL;
descriptionItemArg = NULL;
inTabular = false;
inTable = false;
inFigure = false;
startRows = false;
tableVerticalLineLeft = false;
tableVerticalLineRight = false;
noColumns = 0;
startedSections = false;
inVerbatim = false;
browseId = 0;
if (!InputFile.empty() && !OutputFile.empty())
{
// Do some RTF-specific transformations on all the strings,
// recursively
Text2RTF(GetTopLevelChunk());
Contents = wxFopen(TmpContentsName, _T("w"));
Chapters = wxFopen(_T("chapters.rtf"), _T("w"));
if (winHelp)
{
Sections = wxFopen(_T("sections.rtf"), _T("w"));
Subsections = wxFopen(_T("subsections.rtf"), _T("w"));
Subsubsections = wxFopen(_T("subsubsections.rtf"), _T("w"));
Popups = wxFopen(_T("popups.rtf"), _T("w"));
if (winHelpContents)
{
WinHelpContentsFile = wxFopen(WinHelpContentsFileName, _T("w"));
if (WinHelpContentsFile)
wxFprintf(WinHelpContentsFile, _T(":Base %s.hlp\n"), wxFileNameFromPath(FileRoot));
}
if (!Sections || !Subsections || !Subsubsections || !Popups || (winHelpContents && !WinHelpContentsFile))
{
OnError(_T("Ouch! Could not open temporary file(s) for writing."));
return false;
}
}
if (!Contents || !Chapters)
{
OnError(_T("Ouch! Could not open temporary file(s) for writing."));
return false;
}
if (winHelp)
{
wxFprintf(Chapters, _T("\n#{\\footnote Contents}\n"));
wxFprintf(Chapters, _T("${\\footnote Contents}\n"));
wxFprintf(Chapters, _T("+{\\footnote %s}\n"), GetBrowseString());
wxFprintf(Chapters, _T("K{\\footnote {K} %s}\n"), ContentsNameString);
wxFprintf(Chapters, _T("!{\\footnote DisableButton(\"Up\")}\n"));
}
if (!winHelp)
{
wxFprintf(Chapters, _T("\\titlepg\n"));
wxFprintf(Contents, _T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
}
// In WinHelp, Contents title takes font of title.
// In linear RTF, same as chapter headings.
wxFprintf(Contents, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"),
(winHelp ? titleFont : chapterFont)*2, ContentsNameString);
// By default, Swiss, 11 point.
wxFprintf(Chapters, _T("\\f2\\fs22\n"));
PushEnvironmentStyle(_T("\\f2\\fs22\\sa200"));
SetCurrentOutput(Chapters);
if (stopRunning) if (stopRunning)
return false; return false;
OnInform(_T("Converting...")); // Reset variables
indentLevel = 0;
forbidParindent = 0;
contentsLineSection = NULL;
contentsLineValue = NULL;
descriptionItemArg = NULL;
inTabular = false;
inTable = false;
inFigure = false;
startRows = false;
tableVerticalLineLeft = false;
tableVerticalLineRight = false;
noColumns = 0;
startedSections = false;
inVerbatim = false;
browseId = 0;
TraverseDocument(); if (!InputFile.empty() && !OutputFile.empty())
FILE *Header = wxFopen(_T("header.rtf"), _T("w"));
if (!Header)
{ {
OnError(_T("Ouch! Could not open temporary file header.rtf for writing.")); // Do some RTF-specific transformations on all the strings,
return false; // recursively
Text2RTF(GetTopLevelChunk());
Contents = wxFopen(TmpContentsName, _T("w"));
Chapters = wxFopen(_T("chapters.rtf"), _T("w"));
if (winHelp)
{
Sections = wxFopen(_T("sections.rtf"), _T("w"));
Subsections = wxFopen(_T("subsections.rtf"), _T("w"));
Subsubsections = wxFopen(_T("subsubsections.rtf"), _T("w"));
Popups = wxFopen(_T("popups.rtf"), _T("w"));
if (winHelpContents)
{
WinHelpContentsFile = wxFopen(WinHelpContentsFileName, _T("w"));
if (WinHelpContentsFile)
wxFprintf(WinHelpContentsFile, _T(":Base %s.hlp\n"), wxFileNameFromPath(FileRoot));
}
if (!Sections || !Subsections || !Subsubsections || !Popups || (winHelpContents && !WinHelpContentsFile))
{
OnError(_T("Ouch! Could not open temporary file(s) for writing."));
return false;
}
}
if (!Contents || !Chapters)
{
OnError(_T("Ouch! Could not open temporary file(s) for writing."));
return false;
}
if (winHelp)
{
wxFprintf(Chapters, _T("\n#{\\footnote Contents}\n"));
wxFprintf(Chapters, _T("${\\footnote Contents}\n"));
wxFprintf(Chapters, _T("+{\\footnote %s}\n"), GetBrowseString());
wxFprintf(Chapters, _T("K{\\footnote {K} %s}\n"), ContentsNameString);
wxFprintf(Chapters, _T("!{\\footnote DisableButton(\"Up\")}\n"));
}
if (!winHelp)
{
wxFprintf(Chapters, _T("\\titlepg\n"));
wxFprintf(Contents, _T("\\par\\pard\\pgnrestart\\sect\\titlepg"));
}
// In WinHelp, Contents title takes font of title.
// In linear RTF, same as chapter headings.
wxFprintf(Contents, _T("{\\b\\fs%d %s}\\par\\par\\pard\n\n"),
(winHelp ? titleFont : chapterFont)*2, ContentsNameString);
// By default, Swiss, 11 point.
wxFprintf(Chapters, _T("\\f2\\fs22\n"));
PushEnvironmentStyle(_T("\\f2\\fs22\\sa200"));
SetCurrentOutput(Chapters);
if (stopRunning)
return false;
OnInform(_T("Converting..."));
TraverseDocument();
FILE *Header = wxFopen(_T("header.rtf"), _T("w"));
if (!Header)
{
OnError(_T("Ouch! Could not open temporary file header.rtf for writing."));
return false;
}
WriteRTFHeader(Header);
fclose(Header);
PopEnvironmentStyle();
Tex2RTFYield(true);
if (winHelp)
{
// wxFprintf(Contents, _T("\\page\n"));
wxFprintf(Chapters, _T("\\page\n"));
wxFprintf(Sections, _T("\\page\n"));
wxFprintf(Subsections, _T("\\page\n"));
wxFprintf(Subsubsections, _T("\\page\n\n"));
wxFprintf(Popups, _T("\\page\n}\n"));
}
// TexOutput(_T("\n\\info{\\doccomm Document created by Julian Smart's Tex2RTF.}\n"));
if (!winHelp)
TexOutput(_T("}\n"));
fclose(Contents); Contents = NULL;
fclose(Chapters); Chapters = NULL;
if (winHelp)
{
fclose(Sections); Sections = NULL;
fclose(Subsections); Subsections = NULL;
fclose(Subsubsections); Subsubsections = NULL;
fclose(Popups); Popups = NULL;
if (winHelpContents)
{
fclose(WinHelpContentsFile); WinHelpContentsFile = NULL;
}
}
if (winHelp)
{
wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp1.rtf"), _T("sections.rtf"), _T("tmp2.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp2.rtf"), _T("subsections.rtf"), _T("tmp3.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp3.rtf"), _T("subsubsections.rtf"), _T("tmp4.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp4.rtf"), _T("popups.rtf"), OutputFile);
Tex2RTFYield(true);
wxRemoveFile(_T("tmp1.rtf"));
wxRemoveFile(_T("tmp2.rtf"));
wxRemoveFile(_T("tmp3.rtf"));
wxRemoveFile(_T("tmp4.rtf"));
}
else
{
wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
Tex2RTFYield(true);
if (wxFileExists(OutputFile))
wxRemoveFile(OutputFile);
wxString cwdStr = wxGetCwd();
wxString 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 ((outputDirStr.empty()) || // no path specified on output file
(cwdStr != outputDirStr)) // paths do not match
{
wxRenameFile(_T("tmp1.rtf"), OutputFile);
}
else
{
wxCopyFile(_T("tmp1.rtf"), OutputFile);
}
Tex2RTFYield(true);
wxRemoveFile(_T("tmp1.rtf"));
}
if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName);
if (!wxRenameFile(TmpContentsName, ContentsName))
{
wxCopyFile(TmpContentsName, ContentsName);
wxRemoveFile(TmpContentsName);
}
wxRemoveFile(_T("chapters.rtf"));
wxRemoveFile(_T("header.rtf"));
if (winHelp)
{
wxRemoveFile(_T("sections.rtf"));
wxRemoveFile(_T("subsections.rtf"));
wxRemoveFile(_T("subsubsections.rtf"));
wxRemoveFile(_T("popups.rtf"));
}
if (winHelp && generateHPJ)
WriteHPJ(OutputFile);
return true;
} }
WriteRTFHeader(Header); return false;
fclose(Header);
PopEnvironmentStyle();
Tex2RTFYield(true);
if (winHelp)
{
// wxFprintf(Contents, _T("\\page\n"));
wxFprintf(Chapters, _T("\\page\n"));
wxFprintf(Sections, _T("\\page\n"));
wxFprintf(Subsections, _T("\\page\n"));
wxFprintf(Subsubsections, _T("\\page\n\n"));
wxFprintf(Popups, _T("\\page\n}\n"));
}
// TexOutput(_T("\n\\info{\\doccomm Document created by Julian Smart's Tex2RTF.}\n"));
if (!winHelp)
TexOutput(_T("}\n"));
fclose(Contents); Contents = NULL;
fclose(Chapters); Chapters = NULL;
if (winHelp)
{
fclose(Sections); Sections = NULL;
fclose(Subsections); Subsections = NULL;
fclose(Subsubsections); Subsubsections = NULL;
fclose(Popups); Popups = NULL;
if (winHelpContents)
{
fclose(WinHelpContentsFile); WinHelpContentsFile = NULL;
}
}
if (winHelp)
{
wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp1.rtf"), _T("sections.rtf"), _T("tmp2.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp2.rtf"), _T("subsections.rtf"), _T("tmp3.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp3.rtf"), _T("subsubsections.rtf"), _T("tmp4.rtf"));
Tex2RTFYield(true);
wxConcatFiles(_T("tmp4.rtf"), _T("popups.rtf"), OutputFile);
Tex2RTFYield(true);
wxRemoveFile(_T("tmp1.rtf"));
wxRemoveFile(_T("tmp2.rtf"));
wxRemoveFile(_T("tmp3.rtf"));
wxRemoveFile(_T("tmp4.rtf"));
}
else
{
wxConcatFiles(_T("header.rtf"), _T("chapters.rtf"), _T("tmp1.rtf"));
Tex2RTFYield(true);
if (wxFileExists(OutputFile))
wxRemoveFile(OutputFile);
wxChar *cwdStr;
cwdStr = wxGetWorkingDirectory();
wxString outputDirStr;
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(outputDirStr.c_str(),_T("")) == 0) || // no path specified on output file
(wxStrcmp(cwdStr,outputDirStr.c_str()) == 0)) // paths do not match
{
wxRenameFile(_T("tmp1.rtf"), OutputFile);
}
else
{
wxCopyFile(_T("tmp1.rtf"), OutputFile);
}
delete [] cwdStr;
Tex2RTFYield(true);
wxRemoveFile(_T("tmp1.rtf"));
}
if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName);
if (!wxRenameFile(TmpContentsName, ContentsName))
{
wxCopyFile(TmpContentsName, ContentsName);
wxRemoveFile(TmpContentsName);
}
wxRemoveFile(_T("chapters.rtf"));
wxRemoveFile(_T("header.rtf"));
if (winHelp)
{
wxRemoveFile(_T("sections.rtf"));
wxRemoveFile(_T("subsections.rtf"));
wxRemoveFile(_T("subsubsections.rtf"));
wxRemoveFile(_T("popups.rtf"));
}
if (winHelp && generateHPJ)
WriteHPJ(OutputFile);
return true;
}
return false;
} }