User: vg      
Date: 05/03/23 01:40:51

Modified:
 /dba/connectivity/source/drivers/hsqldb/
  HStorageAccess.cxx

Log:
 INTEGRATION: CWS dba26 (1.4.14); FILE MERGED
 2005/03/15 15:30:01 fs 1.4.14.2: reverted parts of the previous change - OJ's 
patch contained too much code :(
 2005/03/15 15:05:01 fs 1.4.14.1: #i44582# (patch provided by OJ) refined 
storage handling

File Changes:

Directory: /dba/connectivity/source/drivers/hsqldb/
===================================================

File [changed]: HStorageAccess.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HStorageAccess.cxx?r1=1.4&r2=1.5
Delta lines:  +92 -120
----------------------
--- HStorageAccess.cxx  16 Feb 2005 15:51:02 -0000      1.4
+++ HStorageAccess.cxx  23 Mar 2005 09:40:48 -0000      1.5
@@ -177,27 +177,28 @@
        OSL_ENSURE(xIn.is(),"Input stream is NULL!");
        if ( xIn.is() )
        {
-               sal_Bool bRead = sal_False;
-               Reference< XSeekable> xSeek = pHelper->getSeek();
-               if ( xSeek.is() )
+               Sequence< ::sal_Int8 > aData(1);
+        sal_Int32 nBytesRead = -1;
+        try
                {
-                       sal_Int64 nStreamLen = xSeek->getLength();
-                       sal_Int64 nPos = xSeek->getPosition();
-                       bRead = (nPos + 1) <= nStreamLen;
+                   nBytesRead = xIn->readBytes(aData,1);
                }
-               else
-                       bRead = xIn->available() > 0;
-               if ( bRead )
+        catch(Exception& e)
+           {
+            StorageContainer::throwJavaException(e,env);
+            return -1;
+                   
+           }
+               if (nBytesRead <= 0) 
                {
-                       Sequence< ::sal_Int8 > aData(1);
-                       sal_Int32 nBytesRead = xIn->readBytes(aData,1);
-                       if (nBytesRead <= 0) {
                                return (-1);
-                       } else {
+               } 
+        else 
+        {
                                sal_Int32 tmpInt = aData[0];
-                               if (tmpInt < 0 ){
+                       if (tmpInt < 0 )
                                        tmpInt = 256 +tmpInt;
-                               }
+
 #if OSL_DEBUG_LEVEL > 1
                                ::rtl::OUString sOrgName = 
StorageContainer::jstring2ustring(env,name);
                 if ( getStreams().find(sOrgName + 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".data"))) != getStreams().end() )
@@ -209,7 +210,6 @@
                                return(tmpInt);
                        }
                }
-       }
        return -1;
 }
 // 
-----------------------------------------------------------------------------
@@ -232,32 +232,24 @@
         {
             ThrowException(    env,
                                        "java/io/IOException",
-                                       "Stream is not valid");
+                                       "len is greater or equal to the buffer 
size");
                return -1;
         }
                sal_Int32 nBytesRead = -1;
-               Reference< XSeekable> xSeek = pHelper->getSeek();
-               if ( xSeek.is() )
+
+               Sequence< ::sal_Int8 > aData(nLen);
+        try
                {
-                       sal_Int64 nStreamLen = xSeek->getLength();
-                       sal_Int64 nPos = xSeek->getPosition();
-                       nBytesRead = ((nPos + len) <= nStreamLen) ? len : 
(nStreamLen - nPos);
+                       nBytesRead = xIn->readBytes(aData, len);
                }
-               else
+        catch(Exception& e)
                {
-                       sal_Int32 av = xIn->available();
-                       nBytesRead = len <= av ? len : av;
+            StorageContainer::throwJavaException(e,env);
+            return -1;             
                }
 
-               if ( nBytesRead > 0 )
-               {
-                       Sequence< ::sal_Int8 > aData(nBytesRead);
-                       nBytesRead = xIn->readBytes(aData, nBytesRead);
-               
                        if (nBytesRead <= 0)
                                return -1;
-                       OSL_ENSURE(nLen >= (off + nBytesRead),"Buffer is too 
small!");
-                       OSL_ENSURE(aData.getLength() >= nBytesRead,"Buffer is 
too small!");
                        
env->SetByteArrayRegion(buffer,off,nBytesRead,&aData[0]);
 
 #if OSL_DEBUG_LEVEL > 1
@@ -268,9 +260,6 @@
                 sOrgName += 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".input"));
                        
fwrite(&aData[0],sizeof(sal_Int8),nBytesRead,getStreams()[sOrgName]);
 #endif
-               }
-               else
-                       return -1;
                return nBytesRead;
        }
        ThrowException( env,
@@ -293,25 +282,22 @@
        OSL_ENSURE(xIn.is(),"Input stream is NULL!");
        if ( xIn.is() )
        {       
-               sal_Bool bRead = sal_False;
-               Reference< XSeekable> xSeek = pHelper->getSeek();
-               if ( xSeek.is() )
+               Sequence< ::sal_Int8 > aData(4);
+               sal_Int32 nBytesRead = -1;
+        try
                {
-                       sal_Int64 nStreamLen = xSeek->getLength();
-                       sal_Int64 nPos = xSeek->getPosition();
-                       bRead = (nPos + 4) <= nStreamLen;
+            nBytesRead = xIn->readBytes(aData, 4);
                }
-               else
-                       bRead = xIn->available() >= 4;
-               if ( bRead )
+        catch(Exception& e)
         {
-                   Sequence< ::sal_Int8 > aData(4);
-                   sal_Int32 nBytesRead = xIn->readBytes(aData, 4);
+            StorageContainer::throwJavaException(e,env);
+            return -1;             
+           }
 
-                   if (nBytesRead <= 0) {
+               if ( nBytesRead != 4 ) {
                            ThrowException(     env,
                                                            
"java/io/IOException",
-                                                           "Bytes read < 0");
+                                                       "Bytes read != 4");
                            return -1;
                    } 
            
@@ -341,8 +327,6 @@
 #endif
                    return nRet;
         }
-        return -1;
-       }
        ThrowException( env,
                                        "java/io/IOException",
                                        "No InputStream");
@@ -482,13 +466,7 @@
        catch(Exception& e)
        {
                OSL_ENSURE(0,"Exception catched! : write [BII)V");
-               if (JNI_FALSE != env->ExceptionCheck())
-                       env->ExceptionClear();
-               ::rtl::OString cstr( ::rtl::OUStringToOString(e.Message, 
RTL_TEXTENCODING_JAVA_UTF8 ) );
-               OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() 
);
-               ThrowException( env,
-                                               "java/io/IOException",
-                                               cstr.getStr());
+        StorageContainer::throwJavaException(e,env);
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -535,12 +513,6 @@
        catch(Exception& e)
        {
                OSL_ENSURE(0,"Exception catched! : writeBytes(aData);");
-               if (JNI_FALSE != env->ExceptionCheck())
-                       env->ExceptionClear();
-               ::rtl::OString cstr( ::rtl::OUStringToOString(e.Message, 
RTL_TEXTENCODING_JAVA_UTF8 ) );
-               OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() 
);
-               ThrowException( env,
-                                               "java/io/IOException",
-                                               cstr.getStr());
+        StorageContainer::throwJavaException(e,env);
        }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to