summaryrefslogtreecommitdiff
path: root/ACE/ACEXML
diff options
context:
space:
mode:
authorstanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-02-05 21:11:03 +0000
committerstanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-02-05 21:11:03 +0000
commit5e030faf84086ab02059fcbcc3faed224bd57b95 (patch)
tree3a62df45ac6ccf599fb07cf6a03d672456ce2e3d /ACE/ACEXML
parent9d296f7fa51116ff7040ecb2ad18612cd94b5fd1 (diff)
downloadATCD-5e030faf84086ab02059fcbcc3faed224bd57b95.tar.gz
Merge in OCI_Reliability_Enhancements branch.
Diffstat (limited to 'ACE/ACEXML')
-rw-r--r--ACE/ACEXML/common/FileCharStream.cpp29
-rw-r--r--ACE/ACEXML/common/FileCharStream.h10
2 files changed, 35 insertions, 4 deletions
diff --git a/ACE/ACEXML/common/FileCharStream.cpp b/ACE/ACEXML/common/FileCharStream.cpp
index 68178850707..f6ed10308d4 100644
--- a/ACE/ACEXML/common/FileCharStream.cpp
+++ b/ACE/ACEXML/common/FileCharStream.cpp
@@ -12,7 +12,8 @@
#endif /* ACE_USES_WCHAR */
ACEXML_FileCharStream::ACEXML_FileCharStream (void)
- : filename_ (0), encoding_ (0), size_ (0), infile_ (0), peek_ (0)
+ : filename_ (0), encoding_ (0), size_ (0), infile_ (0),
+ close_infile_ (true), peek_ (0)
{
}
@@ -22,7 +23,7 @@ ACEXML_FileCharStream::~ACEXML_FileCharStream (void)
}
int
-ACEXML_FileCharStream::open (const ACEXML_Char *name)
+ACEXML_FileCharStream::use_stream_i (FILE* open_file, const ACEXML_Char *name)
{
delete[] this->filename_;
this->filename_ = 0;
@@ -30,7 +31,7 @@ ACEXML_FileCharStream::open (const ACEXML_Char *name)
delete[] this->encoding_;
this->encoding_ = 0;
- this->infile_ = ACE_OS::fopen (name, ACE_TEXT ("r"));
+ this->infile_ = open_file;
if (this->infile_ == 0)
return -1;
@@ -44,6 +45,23 @@ ACEXML_FileCharStream::open (const ACEXML_Char *name)
}
int
+ACEXML_FileCharStream::use_stream (FILE* open_file, const ACEXML_Char *name)
+{
+ if (open_file != 0)
+ ACE_OS::rewind(open_file);
+
+ this->close_infile_ = false;
+ return use_stream_i(open_file, name);
+}
+
+int
+ACEXML_FileCharStream::open (const ACEXML_Char *name)
+{
+ this->close_infile_ = true;
+ return use_stream_i(ACE_OS::fopen (name, ACE_TEXT ("r")), name);
+}
+
+int
ACEXML_FileCharStream::determine_encoding (void)
{
if (this->infile_ == 0)
@@ -114,7 +132,10 @@ ACEXML_FileCharStream::close (void)
{
if (this->infile_ != 0)
{
- ACE_OS::fclose (this->infile_);
+ if (this->close_infile_)
+ {
+ ACE_OS::fclose (this->infile_);
+ }
this->infile_ = 0;
}
delete[] this->filename_;
diff --git a/ACE/ACEXML/common/FileCharStream.h b/ACE/ACEXML/common/FileCharStream.h
index 1f208e0f8fe..129b169e34e 100644
--- a/ACE/ACEXML/common/FileCharStream.h
+++ b/ACE/ACEXML/common/FileCharStream.h
@@ -41,6 +41,12 @@ public:
int open (const ACEXML_Char *name);
/**
+ * Accept an already opened file. The stream does not
+ * assume ownership of open_file.
+ */
+ int use_stream (FILE* open_file, const ACEXML_Char *name);
+
+ /**
* Returns the available ACEXML_Char in the buffer. -1
* if the object is not initialized properly.
*/
@@ -113,10 +119,14 @@ private:
#endif /* ACE_USES_WCHAR */
+ /// internal accept an already opened file.
+ int use_stream_i (FILE* open_file, const ACEXML_Char *name);
+
ACEXML_Char* filename_;
ACEXML_Char* encoding_;
ACE_OFF_T size_;
FILE* infile_;
+ bool close_infile_;
// This is needed to ensure that we can implement a peek operation on a
// UTF-16 encoded file. It is a bit hackish, but there is no other way of
// implementing a peek() as the standard I/O FILE* guarantees only one