From 37961915e744635f655f8fb6d5f3fe1d851ebb2a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 12 Sep 2013 20:49:10 +0000 Subject: [PATCH] Return the old file descriptor/pointer from wx(F)File::Detach(). Make Detach() more convenient to use. Closes #15494. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/ffile.h | 2 +- include/wx/file.h | 2 +- interface/wx/ffile.h | 5 ++++- interface/wx/file.h | 5 ++++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 17df9bf973..18b61b88ea 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -567,6 +567,7 @@ All: - Add wxFileName::SetPermissions() (Catalin Raceanu). - Fix build with wxUSE_FFILE==0 (jroemmler). - Add wxDEPRECATED_MSG() and use it in a few places. +- Return the old file descriptor/pointer from wx(F)File::Detach() (troelsk). All (GUI): diff --git a/include/wx/ffile.h b/include/wx/ffile.h index ae827dd785..91a7c28ed4 100644 --- a/include/wx/ffile.h +++ b/include/wx/ffile.h @@ -49,7 +49,7 @@ public: // assign an existing file descriptor and get it back from wxFFile object void Attach(FILE *lfp, const wxString& name = wxEmptyString) { Close(); m_fp = lfp; m_name = name; } - void Detach() { m_fp = NULL; } + FILE* Detach() { FILE* fpOld = m_fp; m_fp = NULL; return fpOld; } FILE *fp() const { return m_fp; } // read/write (unbuffered) diff --git a/include/wx/file.h b/include/wx/file.h index b2cd59eab0..00ac471abf 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -65,7 +65,7 @@ public: // assign an existing file descriptor and get it back from wxFile object void Attach(int lfd) { Close(); m_fd = lfd; m_lasterror = 0; } - void Detach() { m_fd = fd_invalid; } + int Detach() { int fdOld = m_fd; m_fd = fd_invalid; return fdOld; } int fd() const { return m_fd; } // read/write (unbuffered) diff --git a/interface/wx/ffile.h b/interface/wx/ffile.h index 5671e2e531..ada146d343 100644 --- a/interface/wx/ffile.h +++ b/interface/wx/ffile.h @@ -76,8 +76,11 @@ public: closing the file if this descriptor is opened. IsOpened() will return @false after call to Detach(). + + @return The FILE pointer (this is new since wxWidgets 3.0.0, in the + previous versions this method didn't return anything). */ - void Detach(); + FILE* Detach(); /** Returns @true if an attempt has been made to read @e past diff --git a/interface/wx/file.h b/interface/wx/file.h index 8eeab558c5..31ea6bdd4f 100644 --- a/interface/wx/file.h +++ b/interface/wx/file.h @@ -295,8 +295,11 @@ public: Get back a file descriptor from wxFile object - the caller is responsible for closing the file if this descriptor is opened. IsOpened() will return @false after call to Detach(). + + @return The file descriptor (this is new since wxWidgets 3.0.0, in the + previous versions this method didn't return anything). */ - void Detach(); + int Detach(); /** Returns @true if the end of the file has been reached. -- 2.45.2