mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
branchRCL_3
changeset 6 ef55b168cedb
parent 4 60a94a45d437
child 15 f85613f12947
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp	Wed Apr 14 16:49:36 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp	Tue Apr 27 17:30:23 2010 +0300
@@ -20,9 +20,9 @@
 
 #include <f32file.h>
 #include <bautils.h>
+#include <e32const.h>
 
 #include <mtp/mmtpdataproviderframework.h>
-
 #include <mtp/cmtpobjectmetadata.h>
 #include <mtp/cmtptypefile.h>
 #include <mtp/cmtptypeobjectinfo.h>
@@ -322,7 +322,11 @@
             {
             iStorageId = iFramework.StorageMgr().DefaultStorageId();
             }
-             
+        
+        if(IsTooLarge(iObjectSize))
+            {
+            *ret = EMTPRespCodeObjectTooLarge;
+            }
         }
     
     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit"));
@@ -608,6 +612,11 @@
     if (result)
         {
         iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
+        if(IsTooLarge(iObjectSize))
+            {
+            SendResponseL(EMTPRespCodeObjectTooLarge);
+            result = EFalse;
+            }
         }
 
     if (result)
@@ -1277,3 +1286,40 @@
         
     return resp;
     }
+
+/**
+Check if the object is too large
+@return ETrue if yes, otherwise EFalse
+*/
+TBool CMTPImageDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
+    {
+    __FLOG(_L8("IsTooLarge - Entry"));
+    TBool ret(aObjectSize > KMaxTInt64);
+    
+    if(!ret)
+        {
+        TBuf<255> fsname;
+        TUint32 storageId = iStorageId;
+        if (storageId == KMTPStorageDefault)
+            {
+            storageId = iFramework.StorageMgr().DefaultStorageId();
+            }
+        TInt drive( iFramework.StorageMgr().DriveNumber(storageId) );
+        if(drive != KErrNotFound)
+            {
+            iFramework.Fs().FileSystemSubType(drive, fsname);        
+        
+            const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1)
+            _LIT(KFsFAT16, "FAT16");
+            _LIT(KFsFAT32, "FAT32");
+        
+            if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize)
+                {
+                ret = ETrue;
+                }
+            }
+        }
+    __FLOG_VA((_L8("Result = %d"), ret));
+    __FLOG(_L8("IsTooLarge - Exit"));
+    return ret;
+    }