コード例 #1
0
        strm2str(Reader inReader, int limit)
        {
            char[]        cb = new char[8192];
            StringBuilder sb = new StringBuilder();
            int           len;

            try
            {
                while ((limit < 0 || sb.Length < limit) &&
                       (len = inReader.read(cb, 0, cb.Length)) >= 0)
                {
                    if (limit >= 0)
                    {
                        len = Math.Min(len, limit - sb.Length);
                    }
                    if (len > 0)
                    {
                        sb.Append(cb, 0, len);
                    }
                }
            }
            catch (IOException)
            {
                throw SqlEx.get(ERR_GC4007_BLOB_IO);
            }
            finally
            {
                try { inReader.close(); }
                catch (IOException) {}
            }

            return(sb.ToString());
        } // strm2str
コード例 #2
0
        copyRdr2Wtr(Reader rdr, Writer wtr)
        {
            if (cbuff == null)
            {
                lock (this)
                {
                    { if (cbuff == null)
                      {
                          cbuff = new char[4096];
                      }
                    }
                }
            }

            try
            {
                lock (cbuff)
                {
                    for (int len = rdr.read(cbuff); len >= 0; len = rdr.read(cbuff))
                    {
                        wtr.write(cbuff, 0, len);
                    }
                }

                rdr.close();
                wtr.flush();
            }
            catch (Exception ex)
            {
                try { rdr.close(); }
                catch (Exception /* ignore */) { }
                try { wtr.flush(); }
                catch (Exception /* ignore */) { }
                throw SqlEx.get(ERR_GC4007_BLOB_IO, ex);
            }

            return;
        }         // copyRdr2Wtr
コード例 #3
0
ファイル: sqllongnchar.cs プロジェクト: JordanChin/Ingres
        /*
        ** Name: strm2str
        **
        ** Description:
        **	Read a character input stream and convert to a string object.
        **	The stream is closed.
        **
        ** Input:
        **	in	Character input stream.
        **	limit	Maximum size of result, negative for no limit
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	String	The stream as a string.
        **
        ** History:
        **	12-Sep-03 (gordy)
        **	    Created.
        */
        private static String strm2str( Reader inReader, int limit )
        {
            char[]           cb = new char[ 8192 ];
            StringBuilder    sb = new StringBuilder();
            int              len;

            try
            {
                while( (limit < 0  ||  sb.Length < limit)  &&
                    (len = inReader.read( cb, 0, cb.Length )) >= 0 )
                {
                    if ( limit >= 0 )  len = Math.Min( len, limit - sb.Length );
                    if ( len > 0 )  sb.Append( cb, 0, len );
                }
            }
            catch( IOException )
            {
                throw SqlEx.get( ERR_GC4007_BLOB_IO );
            }
            finally
            {
                try { inReader.close(); }
                catch( IOException ) {}
            }

            return( sb.ToString() );
        }
コード例 #4
0
 close()
 {
     rdr.close();
     eoi_flags |= EOI; // Force end-of-input state.
     return;
 }                     // close
コード例 #5
0
ファイル: sqlstream.cs プロジェクト: JordanChin/Ingres
        /*
        ** Name: coyRdr2Wtr
        **
        ** Description:
        **	Writes the contents of a Reader stream to a Writer stream.
        **	The Reader stream is closed.  The Writer stream is flushed
        **	but not closed.
        **
        ** Input:
        **	rdr	Reader stream.
        **	wtr	Writer stream.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	void.
        **
        ** History:
        **	 1-Dec-03 (gordy)
        **	    Created.
        */
        protected void copyRdr2Wtr(Reader rdr, Writer wtr)
        {
            if (cbuff == null)
                lock (this)
                {
                    { if (cbuff == null)  cbuff = new char[4096]; }
                }

            try
            {
                lock (cbuff)
                {
                    for (int len = rdr.read(cbuff); len >= 0; len = rdr.read(cbuff))
                        wtr.write(cbuff, 0, len);
                }

                rdr.close();
                wtr.flush();
            }
            catch (Exception ex)
            {
                try { rdr.close(); }
                catch (Exception /* ignore */ ) { }
                try { wtr.flush(); }
                catch (Exception /* ignore */ ) { }
                throw SqlEx.get(ERR_GC4007_BLOB_IO, ex);
            }

            return;
        }