X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0f587c50021f6171df01682bd1059cf93866882..e8741ccae85928bf378081f6f0fb814c1b724356:/src/common/textfile.cpp diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index 3ab5dc94c3..89a8e94033 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -80,6 +80,10 @@ wxString wxTextFile::Translate(const wxString& text, wxTextFileType type) if ( type == wxTextFileType_None ) return text; + // GRG: don't do anything either if it is empty + if ( text.IsEmpty() ) + return text; + wxString eol = GetEOL(type), result; // optimization: we know that the length of the new string will be about @@ -155,6 +159,32 @@ bool wxTextFile::Exists() const return wxFile::Exists(m_strFile); } +bool wxTextFile::Create(const wxString& strFile) +{ + m_strFile = strFile; + + return Create(); +} + +bool wxTextFile::Create() +{ + // file name must be either given in ctor or in Create(const wxString&) + wxASSERT( !m_strFile.IsEmpty() ); + + // if the file already exists do nothing + if ( Exists() ) return FALSE; + + if ( m_file.Open(m_strFile, wxFile::write) ) + { + m_file.Close(); + return TRUE; + } + else + { + return FALSE; + } +} + bool wxTextFile::Open(const wxString& strFile) { m_strFile = strFile;