userlibandfileserver/fileserver/sfile/sf_debug.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
    17 
    17 
    18 #include "sf_std.h"
    18 #include "sf_std.h"
    19 #include <f32dbg.h>
    19 #include <f32dbg.h>
    20 #include "f32image.h"
    20 #include "f32image.h"
    21 #include <f32plugin.h>
    21 #include <f32plugin.h>
       
    22 #include <filesystem_fat.h>
    22 #include "sf_file_cache.h"
    23 #include "sf_file_cache.h"
    23 
    24 #include "sf_memory_man.h"
    24 
    25 
    25 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    26 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    26 
    27 
    27 //
    28 //
    28 // ONLY INCLUDED IN DEBUG BUILDS
    29 // ONLY INCLUDED IN DEBUG BUILDS
   619             {
   620             {
   620             TPckgBuf<TInt> pkgBuf(ObjectCount);
   621             TPckgBuf<TInt> pkgBuf(ObjectCount);
   621             TInt r=aRequest->Write(2,pkgBuf);
   622             TInt r=aRequest->Write(2,pkgBuf);
   622             return r;
   623             return r;
   623             }
   624             }
       
   625         // Check if the file is in 'file sequential/non-rugged file' mode
       
   626         case KControlIoIsFileSequential:
       
   627         	{
       
   628         	TDrive* drive = aRequest->Drive();
       
   629         	if(!drive)
       
   630         		return KErrNotSupported;
       
   631         	
       
   632         	// RFs::ControlIO uses narrow descriptors, so convert narrow back to wide
       
   633         	TBuf8<KMaxPath> fileNameNarrow;
       
   634         	TInt r = aRequest->Read(2, fileNameNarrow);
       
   635         	if (r != KErrNone)
       
   636         		return r;
       
   637         	TFileName fileNameWide;
       
   638         	fileNameWide.Copy(fileNameNarrow);
       
   639         	
       
   640         	// Locate the file
       
   641         	CFileCB* file = drive->LocateFile(fileNameWide);
       
   642         	if(!file)
       
   643         		return KErrNotFound;
       
   644         	
       
   645         	// isFileSequential = 1 or 0 for EFileSequential mode enabled or disabled respectively
       
   646         	TUint8 isFileSequential = (file->IsSequentialMode() != 0);
       
   647         	TPtr8 pkgBuf(&isFileSequential,1,1);
       
   648         	aRequest->Write(3, pkgBuf);
       
   649         	
       
   650         	return KErrNone;
       
   651         	}
       
   652         case KControlIoGlobalCacheConfig:
       
   653 		// read ESTART.TXT file for global memory settings
       
   654             {
       
   655             TGlobalCacheConfig globalCacheConfig;
       
   656             TInt32 rel;
       
   657             
       
   658             const TInt KByteToByteShift = 10;
       
   659             _LIT8(KLitSectionNameCacheMemory,"CacheMemory");
       
   660             
       
   661             if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("GlobalCacheMemorySize"), rel))
       
   662                 globalCacheConfig.iGlobalCacheSizeInBytes = rel << KByteToByteShift;
       
   663             else
       
   664                 globalCacheConfig.iGlobalCacheSizeInBytes = KErrNotFound;
       
   665 
       
   666             if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("LowMemoryThreshold"), rel))
       
   667                 globalCacheConfig.iGlobalLowMemoryThreshold = rel;
       
   668             else
       
   669                 globalCacheConfig.iGlobalLowMemoryThreshold = KErrNotFound;
       
   670 
       
   671             TPckgBuf<TGlobalCacheConfig> pkgBuf(globalCacheConfig);
       
   672             TInt r=aRequest->Write(2,pkgBuf);
       
   673             return r;
       
   674             }
       
   675         case KControlIoGlobalCacheInfo:
       
   676     	// get system's current global cache memory info
       
   677             {
       
   678             TGlobalCacheInfo info;
       
   679             info.iGlobalCacheSizeInBytes = TGlobalCacheMemorySettings::CacheSize();
       
   680             info.iGlobalLowMemoryThreshold = TGlobalCacheMemorySettings::LowMemoryThreshold();
       
   681             TPckgBuf<TGlobalCacheInfo> pkgBuf(info);
       
   682             TInt r=aRequest->Write(2,pkgBuf);
       
   683             return r;
       
   684             }
       
   685          case KControlIoDirCacheConfig:
       
   686          // read ESTART.TXT file for per-drive directory cache settings
       
   687             {
       
   688             TInt driveNumber = aRequest->Drive()->DriveNumber();
       
   689             TDirCacheConfig dirCacheConfig;
       
   690             TInt32 rel;
       
   691             dirCacheConfig.iDrive = driveNumber;
       
   692             TBuf8<32> driveSection;
       
   693             driveSection.Format(_L8("Drive%c"), 'A' + driveNumber);
       
   694             
       
   695             if (F32Properties::GetInt(driveSection, _L8("FAT_LeafDirCacheSize"), rel))
       
   696                 dirCacheConfig.iLeafDirCacheSize = rel;
       
   697             else
       
   698                 dirCacheConfig.iLeafDirCacheSize = KErrNotFound;
       
   699 
       
   700             if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMin"), rel))
       
   701                 dirCacheConfig.iDirCacheSizeMin = rel << KByteToByteShift;
       
   702             else
       
   703                 dirCacheConfig.iDirCacheSizeMin = KErrNotFound;
       
   704 
       
   705             if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMax"), rel))
       
   706                 dirCacheConfig.iDirCacheSizeMax = rel << KByteToByteShift;
       
   707             else
       
   708                 dirCacheConfig.iDirCacheSizeMax = KErrNotFound;
       
   709 
       
   710             TPckgBuf<TDirCacheConfig> pkgBuf(dirCacheConfig);
       
   711             TInt r=aRequest->Write(2,pkgBuf);
       
   712             return r;
       
   713             }
       
   714          case KControlIoDirCacheInfo:
       
   715          // get system's current per-drive directory cache settings
       
   716 		 //  currently only supports FAT file system
       
   717              {
       
   718              TFSName fsName;
       
   719              aRequest->Drive()->CurrentMount().FileSystemName(fsName);
       
   720              if (fsName.CompareF(KFileSystemName_FAT) == 0)
       
   721                  {
       
   722                  // 16 is the control cmd used for FAT
       
   723                  //  see EFATDirCacheInfo in FAT code please. 
       
   724                  const TInt KFATDirCacheInfo = 16;
       
   725                  return(aRequest->Drive()->ControlIO(aRequest->Message(),KFATDirCacheInfo,param1,param2));
       
   726                  }
       
   727              return KErrNotSupported;
       
   728              }
       
   729          case KControlIoSimulateMemoryLow:
       
   730              {
       
   731              CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager();
       
   732              if (cacheMemManager)
       
   733                  cacheMemManager->SetMemoryLow(ETrue);
       
   734              else
       
   735                  return KErrNotSupported;
       
   736              return KErrNone;
       
   737              }
       
   738          case KControlIoStopSimulateMemoryLow:
       
   739              {
       
   740              CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager();
       
   741              if (cacheMemManager)
       
   742                  cacheMemManager->SetMemoryLow(EFalse);
       
   743              else
       
   744                  return KErrNotSupported;
       
   745              return KErrNone;
       
   746              }
   624 		
   747 		
   625 		}
   748 		}
   626 #endif
   749 #endif
   627 
   750 
   628 	return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2));
   751 	return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2));