[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-filesystem-cvs
Subject:    [Filesystem-cvs] local/mini minifileobj.cpp, 1.39,
From:       dushyantvipradas () helixcommunity ! org
Date:       2009-10-15 20:38:20
Message-ID: 200910152149.n9FLnCnn009013 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/filesystem/local/mini
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv28907

Modified Files:
	minifileobj.cpp minifileobj.h 
Log Message:
"Nokia submits this code under the terms of a commercial contribution agreement with \
RealNetworks, and I am authorized to contribute this code under said agreement."  
Modified by:   ext-dushyant.vipradas@nokia.com
 
Reviewed by: 
 
Date:  10 /   12   /2009
 
Project: SymbianMmf_wm 
 
CR: SUB-ID:   417-42482 
 
Synopsis:   64 bit support for helix
 
Overview:   64 bit support is added in file object and datasource along with \
asynchronous support for file operations. All the changes are done under a helix \
feather flag 'HELIX_FEATURE_64_BIT_FILE_SUPPORT'.     
Files Added: None.
 
Files Modified: 
 \build\umakepf\helix-client-s60-52-common.pfi
      \clientapps\symbianmmf\common\hxmmfbasectrl.cpp
      \common\fileio\platform\symbian\hxdatasource_ccontent.cpp
      \common\fileio\pub\platform\symbian\hxdatasource_ccontent.h
      \common\include\hxfiles.h
      \common\include\hxpiids.h 
      \common\include\ihxmmfdatasource.h
      \filesystem\local\mini\minifileobj.cpp
      \filesystem\local\mini\minifileobj.h
 
Image Size and Heap Use impact: minor
 
Module Release testing (STIF)   :   yes .
 
Test case(s) Added  :  No.
 
Memory leak check performed : Yes. No new leaks introduced 
 
Platforms and Profiles Build Verified: helix-client-s60-52-mmf-mdf-dsp
 
Platforms and Profiles Functionality verified:  armv5, winscw 
 
Branch: 210CayS, HEAD


Index: minifileobj.cpp
===================================================================
RCS file: /cvsroot/filesystem/local/mini/minifileobj.cpp,v
retrieving revision 1.39
diff -w -u -b -r1.39 minifileobj.cpp
--- minifileobj.cpp	8 Jul 2008 19:49:40 -0000	1.39
+++ minifileobj.cpp	15 Oct 2009 20:35:12 -0000
@@ -80,6 +80,7 @@
 #include "ihxmmfdatasource.h"
 #endif
 
+#define MAX_READ_SIZE 0x000FFFFF
 #define D_MINI_FO 0x1000000
 
 // CHXMiniFileObject Class Methods
@@ -109,6 +110,9 @@
       ,m_pPendingReadBuf     (NULL)
       ,m_pContext            (pContext)
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+      ,m_pDataSource2        (NULL)
+#endif
       ,m_pDataSource         (NULL)
       ,m_bAsyncReadSupported (FALSE)
       ,m_pPendingReadBufAsync (NULL)
@@ -164,6 +168,9 @@
         m_pClassFactory = NULL;
     }
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    HX_RELEASE(m_pDataSource2);
+#endif
     HX_RELEASE(m_pDataSource);
     HX_RELEASE(m_pPendingReadBuf);
     if(m_bAsyncReadSupported)
@@ -192,6 +199,11 @@
     {
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
         IHXMMFDataSource *pDataSource = NULL;
+        
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        IHXMMFDataSource2 *pDataSource2 = NULL;  
+#endif
+
         if(m_pRequest)
         {
             IHXRequestContext *pRequestContext = NULL;
@@ -205,23 +217,47 @@
                 {
                     pRequester->QueryInterface(IID_IHXMMFDataSource, 
                                                (void**)&pDataSource);
+                                               
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT                    
+                    pRequester->QueryInterface(IID_IHXMMFDataSource2, 
+                                               (void**)&pDataSource2);
+#endif                                               
+                    
                     HX_RELEASE(pRequester);
                 }
                 HX_RELEASE(pRequestContext);
             }
         }
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT                    
+        if(pDataSource2)
+        {
+           // This Request supports data source API. Set this to m_pDataSource2.
+           // m_pDataSource2 will be used for all operations.
+           HX_RELEASE(pDataSource);
+		   pDataSource = NULL;
+           HX_RELEASE(m_pDataSource2);
+           m_pDataSource2 = pDataSource2;
+           pDataSource2 = NULL;
+           m_bAsyncReadSupported = m_pDataSource2->AsyncReadSupported();
+           result = m_pDataSource2->Open2(m_pRequest, modeStr, this, this);
+        }
+        else
+#endif                                               
+       
         if(pDataSource)
         {
            // This Request supports data source API. Set this to m_pDataSource.
-           // m_pDataSource will be used for all file operations.
+           // m_pDataSource will be used for all file operations only when 64 bit 
+           // feature is not available.
            HX_RELEASE(m_pDataSource);
            m_pDataSource = pDataSource;
            pDataSource = NULL;
-           m_bAsyncReadSupported = m_pDataSource->AsyncReadSupported();
            result = m_pDataSource->Open2(m_pRequest, modeStr, this, this);
+           m_bAsyncReadSupported = m_pDataSource->AsyncReadSupported();
         }
         else
-#endif
+#endif // HELIX_FEATURE_MMF_DATASOURCE
         {
             // Open the file with the proper access mode
             m_pFile = fopen(m_pFilename, modeStr);
@@ -445,26 +481,56 @@
     }
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-    if(m_pRequest && m_pDataSource)
+    if(m_pRequest 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    && (m_pDataSource2 || m_pDataSource)
+#else
+     && m_pDataSource
+#endif 
+    )
     {
         // Has requested access mode changed?
         if ((fileAccessMode == m_FileAccessMode) ||
             (fileAccessMode == 0))
         {
             // reset to start of file
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        		if (m_pDataSource2)
+              {
+                HX_RESULT result = m_pDataSource2->Seek(0,SEEK_SET,this,TRUE);
+              }
+         		else
+#endif
+         		if(m_pDataSource) // Ccontent does not exist 
+              {
             m_pDataSource->Seek2(0, SEEK_SET, this);
+              }
+                        
+          
             // notify that file is ready
             m_pFileResponse->InitDone(HXR_OK);
             return HXR_OK;
         }
         else // Access mode has changed
         {
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        		if (m_pDataSource2)
+              {
+                m_pDataSource2->Close2( this );
+                HX_RELEASE(m_pDataSource2);
+              }
+        		else
+#endif          
+        		if(m_pDataSource)
+            	{
             m_pDataSource->Close2( this );
             HX_RELEASE(m_pDataSource);
         }
     }
-    else 
-#endif
+      }  
+    else // if no m_pDataSource && m_pDataSource2
+#endif   // if not HELIX_FEATURE_MMF_DATASOURCE defined
+
     if (m_pFile != NULL) // File is already open
     {
     /*
@@ -532,7 +598,7 @@
 
 /****************************************************************************
  *  IHXFileObject::Read
- *
+ *  Async 32 bit read
  *  This routine reads a block of data of the specified length from the file.
  *  When reading has completed, the caller is asynchronously notified via the
  *  File Response object associated with this File Object. This method is
@@ -546,7 +612,7 @@
 
     if (m_pPendingReadBuf == NULL)
     {
-        if (byteCount > 0x000FFFFF)
+        if (byteCount > MAX_READ_SIZE)
         {
             m_bInReadDone = FALSE;
             m_pFileResponse->ReadDone(HXR_FAILED, NULL);
@@ -670,6 +736,7 @@
         {
             // Notify the caller that the read is done
             HX_RESULT readResult = actualCount > 0 ? HXR_OK : HXR_READ_ERROR;
+           
             result = DoReadDone(readResult, pBuffer);
         }
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)		
@@ -735,7 +802,37 @@
     }
 }
 
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+/****************************************************************************
+ *  IHXMMFDataSourceObserver2::ReadDone
+ *
+ *  This routine is called by DataSource whenever there is a request for 
+ *  data from file object and requested amount of data available at Data
+ *  source level.
+ */
+ 
+void CHXMiniFileObject::ReadDone(IHXBuffer* pBuffer, UINT64 byteCount)
+{
+    ReadDone(pBuffer,(UINT32)byteCount);
+}
+
+void CHXMiniFileObject::SeekDone(HX_RESULT result)
+{
+    // Notify the caller that the seek is done
+    HX_RESULT retVal = m_pFileResponse->SeekDone(result);
+    
+}
+
+void CHXMiniFileObject::WriteDone(HX_RESULT result)
+{
+    m_pFileResponse->WriteDone(result);
+}
 #endif
+
+#endif // HELIX_FEATURE_MMF_DATASOURCE
+
+
 /****************************************************************************
  *  IHXFileObject::DoRead
  *
@@ -747,12 +844,20 @@
     UINT32 actualCount = 0;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-    if(m_pDataSource)
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
     {
-        actualCount = m_pDataSource->Read2(pBuffer, this);
+    	actualCount = m_pDataSource2->Read(pBuffer, this);  // ASync read on datasource
     }
     else
 #endif
+     if(m_pDataSource)
+     {    
+    	actualCount = m_pDataSource->Read2(pBuffer, this);  // Sync read on datasource
+     }
+    else
+#endif  // HELIX_FEATURE_MMF_DATASOURCE
     {
         // Read from the file directly into the buffer object
         actualCount = fread(pBuffer->GetBuffer(),
@@ -821,6 +926,13 @@
     HXBOOL bError = FALSE;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2 && FAILED(m_pDataSource2->GetLastError2(this)) )
+      {
+        bError = TRUE;
+      }
+    else
+#endif   
     if(m_pDataSource && FAILED(m_pDataSource->GetLastError2(this)) )
 #else
     if (m_pFile && ferror(m_pFile)) 
@@ -848,10 +960,20 @@
     UINT32 actualCount = 0;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+   
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if (m_pDataSource2)
+    {								// currently not implmented by data source
+      actualCount = m_pDataSource2->Write(pDataToWrite, 
+      																			sizeof(UCHAR), byteCount, this);	
+    }
+   else
+#endif
     if(m_pDataSource)
     {
         actualCount = m_pDataSource->Write2(pDataToWrite->GetBuffer(), 
                                              sizeof(UCHAR), byteCount, this);
+                                            
     }
     else
 #endif
@@ -859,17 +981,25 @@
         actualCount = fwrite(pDataToWrite->GetBuffer(), sizeof(UCHAR), byteCount, \
m_pFile);  }
 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+    {
+    		// Do nothing	
+    }
+    else
+#endif
+    {
     // Notify the caller that the write is done
     HX_RESULT writeResult = (actualCount == byteCount) ? HXR_OK : HXR_FAILED;
     m_pFileResponse->WriteDone(writeResult);
-
+    }
     return HXR_OK;
 }
 
 
 /****************************************************************************
  *  IHXFileObject::Seek
- *
+ *  Async 32 bit seek.
  *  This routine moves to a given position in the file. The move can be
  *  either from the beginning of the file (absolute), or relative to the
  *  current file position. When seeking has completed, the caller is
@@ -903,27 +1033,42 @@
 
     int seekResult = HXR_FAIL;
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+        seekResult = m_pDataSource2->Seek(offset, fromWhere, this);
+    else
+#endif
     if(m_pDataSource)
     {
         seekResult = m_pDataSource->Seek2(offset, fromWhere, this);
     }
     else
-#endif
-    {
+#endif  // HELIX_FEATURE_MMF_DATASOURCE
     if (m_pFile)
+    {
         seekResult = fseek(m_pFile, offset, fromWhere);
     }
 
     // Notify the caller that the seek is done
     HX_RESULT result = !seekResult ? HXR_OK : HXR_FAILED;
-    HX_RESULT retVal = m_pFileResponse->SeekDone(result);
+  
+    HX_RESULT retVal; 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+    {
+    		 retVal = result;
+    }
+    else
+#endif
+    {
+    		retVal = m_pFileResponse->SeekDone(result); // Sync seekdone on fileobject
     // Memory allocations can be attempted in the execution of SeekDone, and we
     // want to catch these if they fail.
     if( retVal != HXR_OUTOFMEMORY )
     {
         retVal = result;
     }
-
+    }
     return (retVal);
 }
 
@@ -961,13 +1106,20 @@
 {
     DPRINTF(D_MINI_FO, ("CHXMiniFO::Close()\n"));
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+    {   m_pDataSource2->Close2( this );
+        HX_RELEASE(m_pDataSource2);
+    }
+    else
+#endif
     if(m_pDataSource)
     {
         m_pDataSource->Close2( this );
 		HX_RELEASE(m_pDataSource);
     }
-    else
-#endif
+    
+#endif // HELIX_FEATURE_MMF_DATASOURCE
 
     if (m_pFile != NULL)
     {
@@ -1005,7 +1157,359 @@
     return HXR_OK;
 }
 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
 
+// IHXFileObject2 Interface Methods
+
+/****************************************************************************
+ *  IHXFileObject2::InitSync
+ *
+ *  This routine checks the validity of the file by actually opening it. This is a 
+ *  synchronous call. 
+ */
+
+STDMETHODIMP CHXMiniFileObject::InitSync(ULONG32 fileAccessMode)
+{
+     DPRINTF(D_MINI_FO, ("CHXMiniFO::InitSync()\n"));
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pRequest && m_pDataSource2)
+    {
+        // Has requested access mode changed?
+        if ((fileAccessMode == m_FileAccessMode) ||
+            (fileAccessMode == 0))
+        {
+            // reset to start of file
+            m_pDataSource2->Seek2(0, SEEK_SET, this);  // TO DO: Call sync 32 bit \
seek +            return HXR_OK;
+        }
+        else // Access mode has changed
+        {
+            m_pDataSource2->Close2( this );
+            HX_RELEASE(m_pDataSource2);
+        }
+    }
+    else 
+#endif
+    if (m_pFile != NULL) // File is already open
+    {
+        // Has requested access mode changed?
+        if ((fileAccessMode == m_FileAccessMode) ||
+            (fileAccessMode == 0))
+        {
+            // reset to start of file
+            fseek(m_pFile, 0, SEEK_SET);
+            return HXR_OK;
+        }
+        else // Access mode has changed
+        {
+            fclose(m_pFile);
+            m_pFile = NULL;
+        }
+    }
+    m_FileAccessMode = fileAccessMode;
+
+    HX_RESULT fileOpenResult = OpenFile(fileAccessMode);
+    return fileOpenResult;
+}
+
+
+/****************************************************************************
+ *  IHXFileObject::CloseSync
+ *
+ *	This is synchronous close. It closes the file resource and releases all resources
+ *  associated with the object. This routine is crucial and must be called
+ *  before the File Object is destroyed.
+ */
+STDMETHODIMP CHXMiniFileObject::CloseSync(void)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Close()\n"));
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pDataSource2)
+    {
+        m_pDataSource2->Close2( this );
+		HX_RELEASE(m_pDataSource2);
+    }
+    else
+#endif
+
+    if (m_pFile != NULL)
+    {
+        fclose(m_pFile);
+        m_pFile = NULL;
+    }
+
+    if (m_pRequest != NULL)
+    {
+        m_pRequest->Release();
+        m_pRequest = NULL;
+    }
+
+#if defined (_WINDOWS ) && defined (_WIN32)
+    if (m_hFileHandle)
+    {
+        ::FindClose( m_hFileHandle );
+        m_hFileHandle = 0;
+    }
+#endif
+
+    return HXR_OK;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 32 bit synchronus read operation.
+ *  It performs the actual read() operation and returns the 
+ *  count of the actual bytes read along with the data block in the buffer which 
+ *  is supplied to it. 
+ */
+STDMETHODIMP CHXMiniFileObject::Read(IHXBuffer*& pBuffer, UINT32 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));
+    UINT32 actualCount = 0;
+
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pDataSource2)
+    {
+        actualCount = m_pDataSource2->Read2(pBuffer, this);  
+    }
+    else
+#endif
+    {
+        // Read from the file directly into the buffer object
+        actualCount = fread(pBuffer->GetBuffer(),
+                            sizeof(UCHAR),
+                            pBuffer->GetSize(), m_pFile);
+    }
+
+    if((actualCount>0)&& (actualCount < byteCount))
+    {
+				pBuffer->SetSize(actualCount);
+    }
+    return (actualCount>0)?HXR_OK : HXR_FAIL;
+}
+
+
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 64 bit ASYNCHRONOUS read operation. 
+ *  Currently it is not implemented in true sense as it simply checks if the actual 
+ *  data block to be read is less than max 32 bit data or not. If yes, it calls the 
+ *  32 bit asynchronus read operation otherwise returns Not_Implemented.  
+ */
+STDMETHODIMP CHXMiniFileObject::Read(UINT64 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));
+    HX_RESULT result=HXR_NOTIMPL;
+    if(byteCount <= MAX_READ_SIZE)
+    {
+    	result = Read((UINT32)byteCount);
+    }
+    return result;	
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 64 bit SYNCHRONOUS read operation. 
+ */
+STDMETHODIMP CHXMiniFileObject::Read(IHXBuffer*& pBuffer, UINT64 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));    
+    UINT32 actualCount = 0;
+    if(byteCount <= MAX_READ_SIZE)
+    {
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+        if(m_pDataSource2)
+        {							// 64 bit synchronous call
+            actualCount = m_pDataSource2->Read(pBuffer, this, TRUE);  
+        }
+        else
+#endif
+        {
+            // Read from the file directly into the buffer object
+            actualCount = fread(pBuffer->GetBuffer(),
+                            sizeof(UCHAR),
+                            pBuffer->GetSize(), m_pFile);
+        }
+
+        if((actualCount>0)&& (actualCount < byteCount))
+        {
+	          HX_RESULT result = pBuffer->SetSize(actualCount);
+        }
+    }
+    return (actualCount>0)?HXR_OK : HXR_FAIL;
+}
+
+
+/****************************************************************************
+ *  IHXFileObject2::Write
+ *
+ *  This routine performs SYNCHRONOUS Write operation.
+ *  It writes a block of data to the file. This method called by the File
+ *  Format plug-in when it needs to synchronously write to the file.
+ *  This routine does not support writing 64 bit (sync/async) datablock.  
+ */
+STDMETHODIMP CHXMiniFileObject::Write(IHXBuffer*& pDataToWrite, HXBOOL bSync)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Write()\n"));
+    HX_RESULT result=HXR_NOTIMPL;
+    UINT32 byteCount =  pDataToWrite->GetSize();
+    UINT32 actualCount = 0;
+    
+    if(byteCount <= MAX_READ_SIZE)
+    {
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    	    if(m_pDataSource2)
+    	    {		
+        			actualCount = m_pDataSource2->Write(pDataToWrite, 	
+                                             sizeof(UCHAR), byteCount, this, bSync);
+    	    }
+    	    else
+#endif
+    	    {
+	        		actualCount = fwrite(pDataToWrite->GetBuffer(), sizeof(UCHAR), byteCount, \
m_pFile); + 		     	    result = (actualCount == byteCount) ? HXR_OK : HXR_FAILED;
+	        		if(bSync == FALSE)
+    					{
+    							m_pFileResponse->WriteDone(result);
+     					}
+    	    }
+    }
+    return HXR_OK;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Seek
+ *
+ *  This routine is intended for 32 bit SYNCHRONOUS seek operation. 
+ */
+STDMETHODIMP CHXMiniFileObject::Seek(UINT32 ulOffset, HXBOOL bIsRelative, HXBOOL \
bSync) +{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Seek()\n"));
+    HX_RESULT retVal = HXR_OK;
+    if(bSync == TRUE)	
+    {
+    		int fromWhere = SEEK_SET; // absolute
+    		if (bIsRelative == TRUE)
+    		{
+        		fromWhere = SEEK_CUR; // relative
+    		}
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    		if(m_pDataSource2)
+    		{
+            retVal = m_pDataSource2->Seek2(ulOffset, fromWhere,this); 
+    		}
+    		else
+#endif
+    		{
+   				if (m_pFile)
+   				{
+        				retVal = fseek(m_pFile, ulOffset, fromWhere);
+        		}
+    		}
+    }
+    else
+    {	// 32 bit seek and bSync is FALSE == 32 bit async call
+			retVal= Seek(ulOffset, bIsRelative);            
+    }
+    return retVal;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Seek
+ *
+ *  This routine performs 64 bit SYNCHRONOUS and ASYNCHRONOUS seek operation.
+ *  It moves to a given position in the file and the move can be
+ *  either from the beginning of the file (absolute), or relative to the
+ *  current file position. For asynchronus case, when seeking has completed, the 
+ *  caller is asynchronously notified via the File Response object associated with 
+ *  this File Object. This method called by the File Format plug-in when it needs
+ *  to seek to a location within the file.
+ */
+STDMETHODIMP CHXMiniFileObject::Seek(UINT64 offset64, HXBOOL bIsRelative , HXBOOL \
bSync) +{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Seek()\n"));
+       
+    HX_RESULT result;
+    HX_RESULT retVal;
+    HX_RESULT seekResult = HXR_FAIL;
+    int fromWhere = SEEK_SET; // absolute
+    if (bIsRelative == TRUE)
+    {
+        fromWhere = SEEK_CUR; // relative
+    }
+
+    if(bSync == FALSE)
+    {
+        // cancel pending reads
+        HX_RELEASE(m_pPendingReadBuf);
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)	
+    	  if(m_bAsyncReadSupported && m_pPendingReadBufAsync)
+    	    {
+                //if the File format has ReadDone Pending cancel it here
+                if (!m_bInReadDone)
+                {
+            	      m_pFileResponse->ReadDone(HXR_CANCELLED, NULL);
+                }
+                m_pPendingReadBufAsync = NULL;
+          }
+#endif          
+    }
+    
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)	    
+    if(m_pDataSource2)
+    {
+        seekResult = m_pDataSource2->Seek(offset64, fromWhere, this, bSync); 
+    }
+    else
+#endif
+    if (m_pFile && (offset64 <= MAX_READ_SIZE) )
+    {
+     		seekResult = fseek(m_pFile, (UINT32)offset64, fromWhere);
+    
+    		// Notify the caller that the seek is done
+    		result = !seekResult ? HXR_OK : HXR_FAILED;
+
+    		if(bSync == FALSE)
+    		{
+		 				retVal = m_pFileResponse->SeekDone(result); 
+		   				// Memory allocations can be attempted in the execution of SeekDone, and we
+     					// want to catch these if they fail.		
+  		  		if( retVal != HXR_OUTOFMEMORY )
+  					{
+     						seekResult = result;
+  					}
+  					else
+  					{
+  							seekResult = retVal;
+  					}
+  			}
+  	}		
+    return seekResult;
+}
+
+UINT64 CHXMiniFileObject::GetFilePosition(void)
+{
+ 		UINT64 ulPosition=0;
+ 		if(m_pDataSource2)
+ 		{
+ 				 ulPosition = m_pDataSource2->GetPosition64(this);
+ 		}
+ 		return ulPosition;
+}	
+ 
+UINT64 CHXMiniFileObject::GetFileSize64(void)
+{
+ 		UINT64 ulSize=0;
+ 		if(m_pDataSource2)
+    		{
+				m_pDataSource2->GetSize64(ulSize);
+			}
+ 		return ulSize;
+}
+#endif
 
 
 // IHXRequestHandler Interface Methods
@@ -1184,6 +1688,34 @@
  */
 STDMETHODIMP CHXMiniFileObject::QueryInterface(REFIID interfaceID, void** \
ppInterfaceObj)  {
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT 
+#if defined (_SYMBIAN )
+ 	if (IsEqualIID(interfaceID, IID_IHXFileObject2))
+    {								// IHXFileObject2 is available only when IHXMMFDataSource2 is available
+        if(m_pDataSource2)													// on Symbian Platform
+        {
+        		AddRef();
+        		*ppInterfaceObj = (IHXFileObject2*)this;
+        		return HXR_OK;
+        }
+        else
+        {
+        		*ppInterfaceObj = NULL;
+    				return HXR_NOINTERFACE;
+        }
+    }
+#else
+ 	if (IsEqualIID(interfaceID, IID_IHXFileObject2))
+    {								
+        AddRef();
+        *ppInterfaceObj = (IHXFileObject2*)this;
+        return HXR_OK;
+    }
+#endif    
+  else  
+#endif
+	{  		
     QInterfaceList qiList[] =
     {
 	{ GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXFileObject*)this },
@@ -1195,10 +1727,14 @@
 	{ GET_IIDHANDLE(IID_IHXGetFileFromSamePool), (IHXGetFileFromSamePool*) this },
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
 	{ GET_IIDHANDLE(IID_IHXMMFDataSourceObserver), (IHXMMFDataSourceObserver*) this },
+#if defined(HELIX_FEATURE_64_BIT_FILE_SUPPORT)
+			{ GET_IIDHANDLE(IID_IHXMMFDataSourceObserver2), (IHXMMFDataSourceObserver2*) this \
}, +#endif	
 #endif
     };
     return ::QIFind(qiList, QILISTSIZE(qiList), interfaceID, ppInterfaceObj);
 }
+}
 
 /************************************************************************
  * Method:
Index: minifileobj.h
===================================================================
RCS file: /cvsroot/filesystem/local/mini/minifileobj.h,v
retrieving revision 1.11
diff -w -u -b -r1.11 minifileobj.h
--- minifileobj.h	14 Mar 2008 18:27:13 -0000	1.11
+++ minifileobj.h	15 Oct 2009 20:35:12 -0000
@@ -74,15 +74,25 @@
  *  inherits COM's IUnknown interface to handle reference counting and
  *  interface query.
  */
-class CHXMiniFileObject :  public IHXFileObject,
+class CHXMiniFileObject :  
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+			   public IHXFileObject2,
+#else				
+			   public IHXFileObject,
+#endif
 			   public IHXDirHandler,
 			   public IHXRequestHandler,
 			   public IHXFileExists,
 			   public IHXFileStat,
 			   public IHXGetFileFromSamePool
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)			   
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+			  ,public IHXMMFDataSourceObserver2
+#else				
 			  ,public IHXMMFDataSourceObserver
 #endif			   
+			  
+#endif			   
 {
 public:
 
@@ -102,6 +112,21 @@
     STDMETHOD(Advise     ) (THIS_ UINT32 useage);
     STDMETHOD(Close      ) (THIS);
 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    /************************************************************************
+     *  IHXFileObject2 Interface Methods
+     */
+    STDMETHOD(InitSync	 ) (THIS_ ULONG32 ulFlags);
+    STDMETHOD(CloseSync	 ) (THIS);                        
+    STDMETHOD(Read	 ) (THIS_ REF(IHXBuffer*) pBuffer, UINT32 ulCount);
+    STDMETHOD(Read	 ) (THIS_ UINT64 byteCount);
+    STDMETHOD(Read	 ) (THIS_ REF(IHXBuffer*) pBuffer, UINT64 ulCount);
+    STDMETHOD(Write	 ) (THIS_ REF(IHXBuffer*) pBuffer, HXBOOL bSync); 
+    STDMETHOD(Seek	 ) (THIS_ UINT32 ulOffset, HXBOOL bRelative, HXBOOL bSync);
+    STDMETHOD(Seek	 ) (THIS_ UINT64 ulOffset, HXBOOL bRelative, HXBOOL bSync);
+    STDMETHOD_(UINT64,GetFilePosition	)    (THIS);
+    STDMETHOD_(UINT64,GetFileSize64		)	   (THIS);
+#endif
 
     /************************************************************************
      *  IHXRequestHandler Interface Methods
@@ -159,6 +184,18 @@
      *  IHXMMFDataSourceObserver Interface Methods
      */
      void ReadDone(THIS_ IHXBuffer * pBuffer, ULONG32 ulCount);
+     
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    /************************************************************************
+     *  IHXMMFDataSourceObserver2 Interface Methods
+     */
+     STDMETHOD_(void,ReadDone)	(IHXBuffer* pBuffer, UINT64 byteCount);
+ 
+ 	 STDMETHOD_(void,SeekDone)	(HX_RESULT result);
+ 
+ 	 STDMETHOD_(void,WriteDone) (HX_RESULT result);
+#endif     
+
 #endif
 
 protected:
@@ -182,6 +219,9 @@
     IHXBuffer*              m_pPendingReadBuf;
     IUnknown*               m_pContext;
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    IHXMMFDataSource2*      m_pDataSource2;
+#endif
     IHXMMFDataSource*       m_pDataSource;
     HXBOOL                  m_bAsyncReadSupported;
 #endif


Index: minifileobj.cpp
===================================================================
RCS file: /cvsroot/filesystem/local/mini/minifileobj.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- minifileobj.cpp	8 Jul 2008 19:49:40 -0000	1.39
+++ minifileobj.cpp	15 Oct 2009 20:38:17 -0000	1.40
@@ -80,7 +80,8 @@
 #include "ihxmmfdatasource.h"
 #endif
 
-#define D_MINI_FO 0x1000000
+#define MAX_READ_SIZE 0x000FFFFF
+#define D_MINI_FO 		0x1000000
 
 // CHXMiniFileObject Class Methods
 
@@ -109,6 +110,9 @@
       ,m_pPendingReadBuf     (NULL)
       ,m_pContext            (pContext)
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+      ,m_pDataSource2        (NULL)
+#endif
       ,m_pDataSource         (NULL)
       ,m_bAsyncReadSupported (FALSE)
       ,m_pPendingReadBufAsync (NULL)
@@ -164,6 +168,9 @@
         m_pClassFactory = NULL;
     }
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    HX_RELEASE(m_pDataSource2);
+#endif
     HX_RELEASE(m_pDataSource);
     HX_RELEASE(m_pPendingReadBuf);
     if(m_bAsyncReadSupported)
@@ -191,7 +198,12 @@
     if (result == HXR_OK)
     {
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-        IHXMMFDataSource *pDataSource = NULL;
+        IHXMMFDataSource *pDataSource = NULL;  
+        
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        IHXMMFDataSource2 *pDataSource2 = NULL;  
+#endif
+
         if(m_pRequest)
         {
             IHXRequestContext *pRequestContext = NULL;
@@ -205,23 +217,47 @@
                 {
                     pRequester->QueryInterface(IID_IHXMMFDataSource, 
                                                (void**)&pDataSource);
+                                               
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT                    
+                    pRequester->QueryInterface(IID_IHXMMFDataSource2, 
+                                               (void**)&pDataSource2);
+#endif                                               
+                    
                     HX_RELEASE(pRequester);
                 }
                 HX_RELEASE(pRequestContext);
             }
         }
-        if(pDataSource)
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT                    
+        if(pDataSource2)
+        {
+           // This Request supports data source API. Set this to m_pDataSource2.
+           // m_pDataSource2 will be used for all operations.
+           HX_RELEASE(pDataSource);
+		   pDataSource = NULL;
+           HX_RELEASE(m_pDataSource2);
+           m_pDataSource2 = pDataSource2;
+           pDataSource2 = NULL;
+           m_bAsyncReadSupported = m_pDataSource2->AsyncReadSupported();
+           result = m_pDataSource2->Open2(m_pRequest, modeStr, this, this);
+        }
+        else
+#endif                                               
+       
+       if(pDataSource)
         {
            // This Request supports data source API. Set this to m_pDataSource.
-           // m_pDataSource will be used for all file operations.
+           // m_pDataSource will be used for all file operations only when 64 bit 
+           // feature is not available.
            HX_RELEASE(m_pDataSource);
            m_pDataSource = pDataSource;
            pDataSource = NULL;
-           m_bAsyncReadSupported = m_pDataSource->AsyncReadSupported();
            result = m_pDataSource->Open2(m_pRequest, modeStr, this, this);
-        }
-        else
-#endif
+           m_bAsyncReadSupported = m_pDataSource->AsyncReadSupported();
+          }
+       else
+#endif // HELIX_FEATURE_MMF_DATASOURCE
         {
             // Open the file with the proper access mode
             m_pFile = fopen(m_pFilename, modeStr);
@@ -445,26 +481,56 @@
     }
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-    if(m_pRequest && m_pDataSource)
+    if(m_pRequest 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    && (m_pDataSource2 || m_pDataSource)
+#else
+     && m_pDataSource
+#endif 
+    )
     {
         // Has requested access mode changed?
         if ((fileAccessMode == m_FileAccessMode) ||
             (fileAccessMode == 0))
         {
             // reset to start of file
-            m_pDataSource->Seek2(0, SEEK_SET, this);
-            // notify that file is ready
-            m_pFileResponse->InitDone(HXR_OK);
-            return HXR_OK;
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        		if (m_pDataSource2)
+              {
+                HX_RESULT result = m_pDataSource2->Seek(0,SEEK_SET,this,TRUE);
+              }
+         		else
+#endif
+         		if(m_pDataSource) // Ccontent does not exist 
+              {
+                m_pDataSource->Seek2(0, SEEK_SET, this);
+              }
+                        
+          
+            	// notify that file is ready
+            	m_pFileResponse->InitDone(HXR_OK);
+            	return HXR_OK;
         }
         else // Access mode has changed
         {
-            m_pDataSource->Close2( this );
-            HX_RELEASE(m_pDataSource);
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+        		if (m_pDataSource2)
+              {
+                m_pDataSource2->Close2( this );
+                HX_RELEASE(m_pDataSource2);
+              }
+        		else
+#endif          
+        		if(m_pDataSource)
+            	{
+             		m_pDataSource->Close2( this );
+              	HX_RELEASE(m_pDataSource);
+            	}
         }
-    }
-    else 
-#endif
+      }  
+    else // if no m_pDataSource && m_pDataSource2
+#endif   // if not HELIX_FEATURE_MMF_DATASOURCE defined
+
     if (m_pFile != NULL) // File is already open
     {
     /*
@@ -532,7 +598,7 @@
 
 /****************************************************************************
  *  IHXFileObject::Read
- *
+ *  Async 32 bit read
  *  This routine reads a block of data of the specified length from the file.
  *  When reading has completed, the caller is asynchronously notified via the
  *  File Response object associated with this File Object. This method is
@@ -546,7 +612,7 @@
 
     if (m_pPendingReadBuf == NULL)
     {
-        if (byteCount > 0x000FFFFF)
+        if (byteCount > MAX_READ_SIZE)
         {
             m_bInReadDone = FALSE;
             m_pFileResponse->ReadDone(HXR_FAILED, NULL);
@@ -670,7 +736,8 @@
         {
             // Notify the caller that the read is done
             HX_RESULT readResult = actualCount > 0 ? HXR_OK : HXR_READ_ERROR;
-            result = DoReadDone(readResult, pBuffer);
+           
+           result = DoReadDone(readResult, pBuffer);
         }
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)		
     }
@@ -735,7 +802,37 @@
     }
 }
 
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+/****************************************************************************
+ *  IHXMMFDataSourceObserver2::ReadDone
+ *
+ *  This routine is called by DataSource whenever there is a request for 
+ *  data from file object and requested amount of data available at Data
+ *  source level.
+ */
+ 
+void CHXMiniFileObject::ReadDone(IHXBuffer* pBuffer, UINT64 byteCount)
+{
+    ReadDone(pBuffer,(UINT32)byteCount);
+}
+
+void CHXMiniFileObject::SeekDone(HX_RESULT result)
+{
+    // Notify the caller that the seek is done
+    HX_RESULT retVal = m_pFileResponse->SeekDone(result);
+    
+}
+
+void CHXMiniFileObject::WriteDone(HX_RESULT result)
+{
+    m_pFileResponse->WriteDone(result);
+}
 #endif
+
+#endif // HELIX_FEATURE_MMF_DATASOURCE
+
+
 /****************************************************************************
  *  IHXFileObject::DoRead
  *
@@ -747,12 +844,20 @@
     UINT32 actualCount = 0;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-    if(m_pDataSource)
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
     {
-        actualCount = m_pDataSource->Read2(pBuffer, this);
+    	actualCount = m_pDataSource2->Read(pBuffer, this);  // ASync read on datasource
     }
     else
 #endif
+     if(m_pDataSource)
+     {    
+    	actualCount = m_pDataSource->Read2(pBuffer, this);  // Sync read on datasource
+     }
+    else
+#endif  // HELIX_FEATURE_MMF_DATASOURCE
     {
         // Read from the file directly into the buffer object
         actualCount = fread(pBuffer->GetBuffer(),
@@ -777,7 +882,7 @@
 {
     HX_RESULT result = HXR_OK;
 
-    m_bInReadDone = TRUE;
+    m_bInReadDone = TRUE; 
     // If heap gets low, memory allocations for new file read
     // buffers is one of the first places we notice it, and
     // if we're not careful to report this error, we can get
@@ -821,6 +926,13 @@
     HXBOOL bError = FALSE;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2 && FAILED(m_pDataSource2->GetLastError2(this)) )
+      {
+        bError = TRUE;
+      }
+    else
+#endif   
     if(m_pDataSource && FAILED(m_pDataSource->GetLastError2(this)) )
 #else
     if (m_pFile && ferror(m_pFile)) 
@@ -848,28 +960,46 @@
     UINT32 actualCount = 0;
 
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-    if(m_pDataSource)
+   
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if (m_pDataSource2)
+    {								// currently not implmented by data source
+      actualCount = m_pDataSource2->Write(pDataToWrite, 
+      																			sizeof(UCHAR), byteCount, this);	
+    }
+   else
+#endif
+   if(m_pDataSource)
     {
         actualCount = m_pDataSource->Write2(pDataToWrite->GetBuffer(), 
-                                             sizeof(UCHAR), byteCount, this);
+                                            sizeof(UCHAR), byteCount, this);
+                                            
     }
-    else
+   else
 #endif
     {
         actualCount = fwrite(pDataToWrite->GetBuffer(), sizeof(UCHAR), byteCount, \
m_pFile);  }
 
-    // Notify the caller that the write is done
-    HX_RESULT writeResult = (actualCount == byteCount) ? HXR_OK : HXR_FAILED;
-    m_pFileResponse->WriteDone(writeResult);
-
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+    {
+    		// Do nothing	
+    }
+    else
+#endif
+    {
+    		// Notify the caller that the write is done
+    		HX_RESULT writeResult = (actualCount == byteCount) ? HXR_OK : HXR_FAILED;
+    		m_pFileResponse->WriteDone(writeResult);
+    }
     return HXR_OK;
 }
 
 
 /****************************************************************************
  *  IHXFileObject::Seek
- *
+ *  Async 32 bit seek.
  *  This routine moves to a given position in the file. The move can be
  *  either from the beginning of the file (absolute), or relative to the
  *  current file position. When seeking has completed, the caller is
@@ -903,27 +1033,42 @@
 
     int seekResult = HXR_FAIL;
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+        seekResult = m_pDataSource2->Seek(offset, fromWhere, this);
+    else
+#endif
     if(m_pDataSource)
-    {
-        seekResult = m_pDataSource->Seek2(offset, fromWhere, this);
+    {    
+    	seekResult = m_pDataSource->Seek2(offset, fromWhere, this);
     }
     else
-#endif
-    {
+#endif  // HELIX_FEATURE_MMF_DATASOURCE
     if (m_pFile)
+    {
         seekResult = fseek(m_pFile, offset, fromWhere);
     }
 
     // Notify the caller that the seek is done
     HX_RESULT result = !seekResult ? HXR_OK : HXR_FAILED;
-    HX_RESULT retVal = m_pFileResponse->SeekDone(result);
-    // Memory allocations can be attempted in the execution of SeekDone, and we
-    // want to catch these if they fail.
-    if( retVal != HXR_OUTOFMEMORY )
+  
+    HX_RESULT retVal; 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
     {
-        retVal = result;
+    		 retVal = result;
+    }
+    else
+#endif
+    {
+    		retVal = m_pFileResponse->SeekDone(result); // Sync seekdone on fileobject
+    		// Memory allocations can be attempted in the execution of SeekDone, and we
+    		// want to catch these if they fail.		
+    		if( retVal != HXR_OUTOFMEMORY )
+    		{
+        		retVal = result;
+    		}
     }
-
     return (retVal);
 }
 
@@ -961,13 +1106,20 @@
 {
     DPRINTF(D_MINI_FO, ("CHXMiniFO::Close()\n"));
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    if(m_pDataSource2)
+    {   m_pDataSource2->Close2( this );
+        HX_RELEASE(m_pDataSource2);
+    }
+    else
+#endif
     if(m_pDataSource)
     {
         m_pDataSource->Close2( this );
-		HX_RELEASE(m_pDataSource);
+	     	HX_RELEASE(m_pDataSource);
     }
-    else
-#endif
+    
+#endif // HELIX_FEATURE_MMF_DATASOURCE
 
     if (m_pFile != NULL)
     {
@@ -1005,8 +1157,360 @@
     return HXR_OK;
 }
 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+
+// IHXFileObject2 Interface Methods
+
+/****************************************************************************
+ *  IHXFileObject2::InitSync
+ *
+ *  This routine checks the validity of the file by actually opening it. This is a 
+ *  synchronous call. 
+ */
+
+STDMETHODIMP CHXMiniFileObject::InitSync(ULONG32 fileAccessMode)
+{
+     DPRINTF(D_MINI_FO, ("CHXMiniFO::InitSync()\n"));
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pRequest && m_pDataSource2)
+    {
+        // Has requested access mode changed?
+        if ((fileAccessMode == m_FileAccessMode) ||
+            (fileAccessMode == 0))
+        {
+            // reset to start of file
+            m_pDataSource2->Seek2(0, SEEK_SET, this);  // TO DO: Call sync 32 bit \
seek +            return HXR_OK;
+        }
+        else // Access mode has changed
+        {
+            m_pDataSource2->Close2( this );
+            HX_RELEASE(m_pDataSource2);
+        }
+    }
+    else 
+#endif
+    if (m_pFile != NULL) // File is already open
+    {
+        // Has requested access mode changed?
+        if ((fileAccessMode == m_FileAccessMode) ||
+            (fileAccessMode == 0))
+        {
+            // reset to start of file
+            fseek(m_pFile, 0, SEEK_SET);
+            return HXR_OK;
+        }
+        else // Access mode has changed
+        {
+            fclose(m_pFile);
+            m_pFile = NULL;
+        }
+    }
+    m_FileAccessMode = fileAccessMode;
+
+    HX_RESULT fileOpenResult = OpenFile(fileAccessMode);
+    return fileOpenResult;
+}
+
+
+/****************************************************************************
+ *  IHXFileObject::CloseSync
+ *
+ *	This is synchronous close. It closes the file resource and releases all resources
+ *  associated with the object. This routine is crucial and must be called
+ *  before the File Object is destroyed.
+ */
+STDMETHODIMP CHXMiniFileObject::CloseSync(void)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Close()\n"));
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pDataSource2)
+    {
+        m_pDataSource2->Close2( this );
+		HX_RELEASE(m_pDataSource2);
+    }
+    else
+#endif
+
+    if (m_pFile != NULL)
+    {
+        fclose(m_pFile);
+        m_pFile = NULL;
+    }
+
+    if (m_pRequest != NULL)
+    {
+        m_pRequest->Release();
+        m_pRequest = NULL;
+    }
+
+#if defined (_WINDOWS ) && defined (_WIN32)
+    if (m_hFileHandle)
+    {
+        ::FindClose( m_hFileHandle );
+        m_hFileHandle = 0;
+    }
+#endif
+
+    return HXR_OK;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 32 bit synchronus read operation.
+ *  It performs the actual read() operation and returns the 
+ *  count of the actual bytes read along with the data block in the buffer which 
+ *  is supplied to it. 
+ */
+STDMETHODIMP CHXMiniFileObject::Read(IHXBuffer*& pBuffer, UINT32 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));
+    UINT32 actualCount = 0;
+
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    if(m_pDataSource2)
+    {
+        actualCount = m_pDataSource2->Read2(pBuffer, this);  
+    }
+    else
+#endif
+    {
+        // Read from the file directly into the buffer object
+        actualCount = fread(pBuffer->GetBuffer(),
+                            sizeof(UCHAR),
+                            pBuffer->GetSize(), m_pFile);
+    }
+
+    if((actualCount>0)&& (actualCount < byteCount))
+    {
+				pBuffer->SetSize(actualCount);
+    }
+    return (actualCount>0)?HXR_OK : HXR_FAIL;
+}
 
 
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 64 bit ASYNCHRONOUS read operation. 
+ *  Currently it is not implemented in true sense as it simply checks if the actual 
+ *  data block to be read is less than max 32 bit data or not. If yes, it calls the 
+ *  32 bit asynchronus read operation otherwise returns Not_Implemented.  
+ */
+STDMETHODIMP CHXMiniFileObject::Read(UINT64 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));
+    HX_RESULT result=HXR_NOTIMPL;
+    if(byteCount <= MAX_READ_SIZE)
+    {
+    	result = Read((UINT32)byteCount);
+    }
+    return result;	
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Read
+ *
+ *  This routine performs 64 bit SYNCHRONOUS read operation. 
+ */
+STDMETHODIMP CHXMiniFileObject::Read(IHXBuffer*& pBuffer, UINT64 byteCount)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Read()\n"));    
+    UINT32 actualCount = 0;
+    if(byteCount <= MAX_READ_SIZE)
+    {
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+        if(m_pDataSource2)
+        {							// 64 bit synchronous call
+            actualCount = m_pDataSource2->Read(pBuffer, this, TRUE);  
+        }
+        else
+#endif
+        {
+            // Read from the file directly into the buffer object
+            actualCount = fread(pBuffer->GetBuffer(),
+                            sizeof(UCHAR),
+                            pBuffer->GetSize(), m_pFile);
+        }
+
+        if((actualCount>0)&& (actualCount < byteCount))
+        {
+	          HX_RESULT result = pBuffer->SetSize(actualCount);
+        }
+    }
+    return (actualCount>0)?HXR_OK : HXR_FAIL;
+}
+
+
+/****************************************************************************
+ *  IHXFileObject2::Write
+ *
+ *  This routine performs SYNCHRONOUS Write operation.
+ *  It writes a block of data to the file. This method called by the File
+ *  Format plug-in when it needs to synchronously write to the file.
+ *  This routine does not support writing 64 bit (sync/async) datablock.  
+ */
+STDMETHODIMP CHXMiniFileObject::Write(IHXBuffer*& pDataToWrite, HXBOOL bSync)
+{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Write()\n"));
+    HX_RESULT result=HXR_NOTIMPL;
+    UINT32 byteCount =  pDataToWrite->GetSize();
+    UINT32 actualCount = 0;
+    
+    if(byteCount <= MAX_READ_SIZE)
+    {
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    	    if(m_pDataSource2)
+    	    {		
+        			actualCount = m_pDataSource2->Write(pDataToWrite, 	
+                                             sizeof(UCHAR), byteCount, this, bSync);
+    	    }
+    	    else
+#endif
+    	    {
+	        		actualCount = fwrite(pDataToWrite->GetBuffer(), sizeof(UCHAR), byteCount, \
m_pFile); + 		     	    result = (actualCount == byteCount) ? HXR_OK : HXR_FAILED;
+	        		if(bSync == FALSE)
+    					{
+    							m_pFileResponse->WriteDone(result);
+     					}
+    	    }
+    }
+    return HXR_OK;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Seek
+ *
+ *  This routine is intended for 32 bit SYNCHRONOUS seek operation. 
+ */
+STDMETHODIMP CHXMiniFileObject::Seek(UINT32 ulOffset, HXBOOL bIsRelative, HXBOOL \
bSync) +{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Seek()\n"));
+    HX_RESULT retVal = HXR_OK;
+    if(bSync == TRUE)	
+    {
+    		int fromWhere = SEEK_SET; // absolute
+    		if (bIsRelative == TRUE)
+    		{
+        		fromWhere = SEEK_CUR; // relative
+    		}
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)
+    		if(m_pDataSource2)
+    		{
+            retVal = m_pDataSource2->Seek2(ulOffset, fromWhere,this); 
+    		}
+    		else
+#endif
+    		{
+   				if (m_pFile)
+   				{
+        				retVal = fseek(m_pFile, ulOffset, fromWhere);
+        		}
+    		}
+    }
+    else
+    {	// 32 bit seek and bSync is FALSE == 32 bit async call
+			retVal= Seek(ulOffset, bIsRelative);            
+    }
+    return retVal;
+}
+
+/****************************************************************************
+ *  IHXFileObject2::Seek
+ *
+ *  This routine performs 64 bit SYNCHRONOUS and ASYNCHRONOUS seek operation.
+ *  It moves to a given position in the file and the move can be
+ *  either from the beginning of the file (absolute), or relative to the
+ *  current file position. For asynchronus case, when seeking has completed, the 
+ *  caller is asynchronously notified via the File Response object associated with 
+ *  this File Object. This method called by the File Format plug-in when it needs
+ *  to seek to a location within the file.
+ */
+STDMETHODIMP CHXMiniFileObject::Seek(UINT64 offset64, HXBOOL bIsRelative , HXBOOL \
bSync) +{
+    DPRINTF(D_MINI_FO, ("CHXMiniFO::Seek()\n"));
+       
+    HX_RESULT result;
+    HX_RESULT retVal;
+    HX_RESULT seekResult = HXR_FAIL;
+    int fromWhere = SEEK_SET; // absolute
+    if (bIsRelative == TRUE)
+    {
+        fromWhere = SEEK_CUR; // relative
+    }
+
+    if(bSync == FALSE)
+    {
+        // cancel pending reads
+        HX_RELEASE(m_pPendingReadBuf);
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)	
+    	  if(m_bAsyncReadSupported && m_pPendingReadBufAsync)
+    	    {
+                //if the File format has ReadDone Pending cancel it here
+                if (!m_bInReadDone)
+                {
+            	      m_pFileResponse->ReadDone(HXR_CANCELLED, NULL);
+                }
+                m_pPendingReadBufAsync = NULL;
+          }
+#endif          
+    }
+    
+#if defined(HELIX_FEATURE_MMF_DATASOURCE)	    
+    if(m_pDataSource2)
+    {
+        seekResult = m_pDataSource2->Seek(offset64, fromWhere, this, bSync); 
+    }
+    else
+#endif
+    if (m_pFile && (offset64 <= MAX_READ_SIZE) )
+    {
+     		seekResult = fseek(m_pFile, (UINT32)offset64, fromWhere);
+    
+    		// Notify the caller that the seek is done
+    		result = !seekResult ? HXR_OK : HXR_FAILED;
+
+    		if(bSync == FALSE)
+    		{
+		 				retVal = m_pFileResponse->SeekDone(result); 
+		   				// Memory allocations can be attempted in the execution of SeekDone, and we
+     					// want to catch these if they fail.		
+  		  		if( retVal != HXR_OUTOFMEMORY )
+  					{
+     						seekResult = result;
+  					}
+  					else
+  					{
+  							seekResult = retVal;
+  					}
+  			}
+  	}		
+    return seekResult;
+}
+
+UINT64 CHXMiniFileObject::GetFilePosition(void)
+{
+ 		UINT64 ulPosition=0;
+ 		if(m_pDataSource2)
+ 		{
+ 				 ulPosition = m_pDataSource2->GetPosition64(this);
+ 		}
+ 		return ulPosition;
+}	
+ 
+UINT64 CHXMiniFileObject::GetFileSize64(void)
+{
+ 		UINT64 ulSize=0;
+ 		if(m_pDataSource2)
+    		{
+				m_pDataSource2->GetSize64(ulSize);
+			}
+ 		return ulSize;
+}
+#endif
+
 
 // IHXRequestHandler Interface Methods
 
@@ -1184,20 +1688,52 @@
  */
 STDMETHODIMP CHXMiniFileObject::QueryInterface(REFIID interfaceID, void** \
ppInterfaceObj)  {
-    QInterfaceList qiList[] =
-    {
-	{ GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXFileObject*)this },
-	{ GET_IIDHANDLE(IID_IHXFileObject), (IHXFileObject*) this },
-	{ GET_IIDHANDLE(IID_IHXDirHandler), (IHXDirHandler*) this },
-	{ GET_IIDHANDLE(IID_IHXRequestHandler), (IHXRequestHandler*) this },
-	{ GET_IIDHANDLE(IID_IHXFileExists), (IHXFileExists*) this },
-	{ GET_IIDHANDLE(IID_IHXFileStat), (IHXFileStat*) this },
-	{ GET_IIDHANDLE(IID_IHXGetFileFromSamePool), (IHXGetFileFromSamePool*) this },
+
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT 
+#if defined (_SYMBIAN )
+ 	if (IsEqualIID(interfaceID, IID_IHXFileObject2))
+    {								// IHXFileObject2 is available only when IHXMMFDataSource2 is available
+        if(m_pDataSource2)													// on Symbian Platform
+        {
+        		AddRef();
+        		*ppInterfaceObj = (IHXFileObject2*)this;
+        		return HXR_OK;
+        }
+        else
+        {
+        		*ppInterfaceObj = NULL;
+    				return HXR_NOINTERFACE;
+        }
+    }
+#else
+ 	if (IsEqualIID(interfaceID, IID_IHXFileObject2))
+    {								
+        AddRef();
+        *ppInterfaceObj = (IHXFileObject2*)this;
+        return HXR_OK;
+    }
+#endif    
+  else  
+#endif
+	{  		
+		    QInterfaceList qiList[] =
+		    {
+			{ GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXFileObject*)this },
+			{ GET_IIDHANDLE(IID_IHXFileObject), (IHXFileObject*) this },
+			{ GET_IIDHANDLE(IID_IHXDirHandler), (IHXDirHandler*) this },
+			{ GET_IIDHANDLE(IID_IHXRequestHandler), (IHXRequestHandler*) this },
+			{ GET_IIDHANDLE(IID_IHXFileExists), (IHXFileExists*) this },
+			{ GET_IIDHANDLE(IID_IHXFileStat), (IHXFileStat*) this },
+			{ GET_IIDHANDLE(IID_IHXGetFileFromSamePool), (IHXGetFileFromSamePool*) this },
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
-	{ GET_IIDHANDLE(IID_IHXMMFDataSourceObserver), (IHXMMFDataSourceObserver*) this },
+			{ GET_IIDHANDLE(IID_IHXMMFDataSourceObserver), (IHXMMFDataSourceObserver*) this \
}, +#if defined(HELIX_FEATURE_64_BIT_FILE_SUPPORT)
+			{ GET_IIDHANDLE(IID_IHXMMFDataSourceObserver2), (IHXMMFDataSourceObserver2*) this \
}, +#endif	
 #endif
-    };
-    return ::QIFind(qiList, QILISTSIZE(qiList), interfaceID, ppInterfaceObj);
+		    };
+		    return ::QIFind(qiList, QILISTSIZE(qiList), interfaceID, ppInterfaceObj);
+	}
 }
 
 /************************************************************************

Index: minifileobj.h
===================================================================
RCS file: /cvsroot/filesystem/local/mini/minifileobj.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- minifileobj.h	14 Mar 2008 18:27:13 -0000	1.11
+++ minifileobj.h	15 Oct 2009 20:38:17 -0000	1.12
@@ -74,14 +74,24 @@
  *  inherits COM's IUnknown interface to handle reference counting and
  *  interface query.
  */
-class CHXMiniFileObject :  public IHXFileObject,
+class CHXMiniFileObject :  
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+			   public IHXFileObject2,
+#else				
+			   public IHXFileObject,
+#endif
 			   public IHXDirHandler,
 			   public IHXRequestHandler,
 			   public IHXFileExists,
 			   public IHXFileStat,
 			   public IHXGetFileFromSamePool
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)			   
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+			  ,public IHXMMFDataSourceObserver2
+#else				
 			  ,public IHXMMFDataSourceObserver
+#endif
+			  
 #endif			   
 {
 public:
@@ -102,6 +112,21 @@
     STDMETHOD(Advise     ) (THIS_ UINT32 useage);
     STDMETHOD(Close      ) (THIS);
 
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    /************************************************************************
+     *  IHXFileObject2 Interface Methods
+     */
+    STDMETHOD(InitSync	 ) (THIS_ ULONG32 ulFlags);
+    STDMETHOD(CloseSync	 ) (THIS);                        
+    STDMETHOD(Read	 ) (THIS_ REF(IHXBuffer*) pBuffer, UINT32 ulCount);
+    STDMETHOD(Read	 ) (THIS_ UINT64 byteCount);
+    STDMETHOD(Read	 ) (THIS_ REF(IHXBuffer*) pBuffer, UINT64 ulCount);
+    STDMETHOD(Write	 ) (THIS_ REF(IHXBuffer*) pBuffer, HXBOOL bSync); 
+    STDMETHOD(Seek	 ) (THIS_ UINT32 ulOffset, HXBOOL bRelative, HXBOOL bSync);
+    STDMETHOD(Seek	 ) (THIS_ UINT64 ulOffset, HXBOOL bRelative, HXBOOL bSync);
+    STDMETHOD_(UINT64,GetFilePosition	)    (THIS);
+    STDMETHOD_(UINT64,GetFileSize64		)	   (THIS);
+#endif
 
     /************************************************************************
      *  IHXRequestHandler Interface Methods
@@ -159,6 +184,18 @@
      *  IHXMMFDataSourceObserver Interface Methods
      */
      void ReadDone(THIS_ IHXBuffer * pBuffer, ULONG32 ulCount);
+     
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    /************************************************************************
+     *  IHXMMFDataSourceObserver2 Interface Methods
+     */
+     STDMETHOD_(void,ReadDone)	(IHXBuffer* pBuffer, UINT64 byteCount);
+ 
+ 	 STDMETHOD_(void,SeekDone)	(HX_RESULT result);
+ 
+ 	 STDMETHOD_(void,WriteDone) (HX_RESULT result);
+#endif     
+
 #endif
 
 protected:
@@ -182,6 +219,9 @@
     IHXBuffer*              m_pPendingReadBuf;
     IUnknown*               m_pContext;
 #if defined(HELIX_FEATURE_MMF_DATASOURCE)
+#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
+    IHXMMFDataSource2*      m_pDataSource2;
+#endif
     IHXMMFDataSource*       m_pDataSource;
     HXBOOL                  m_bAsyncReadSupported;
 #endif


_______________________________________________
Filesystem-cvs mailing list
Filesystem-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/filesystem-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic