userlibandfileserver/fileserver/sfat32/sl_fsy.cpp
changeset 9 96e5fb8b040d
child 6 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\sfat\sl_fsy.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "sl_std.h"
       
    19 #include <e32hal.h>
       
    20 
       
    21 CFatFileSystem* CFatFileSystem::New()
       
    22 //
       
    23 // Create a FatFileSystem 
       
    24 //
       
    25 	{
       
    26 	CFatFileSystem* fatfsys=new CFatFileSystem();
       
    27 	if (fatfsys==NULL)
       
    28 		return(NULL);
       
    29 
       
    30 	return fatfsys;
       
    31 	}
       
    32 
       
    33 
       
    34 CFatFileSystem::CFatFileSystem() : iUseLocalTimeIfRemovable(EFalse)
       
    35 //
       
    36 // Construct the file system
       
    37 //
       
    38 	{
       
    39 	}	
       
    40 
       
    41 CFatFileSystem::~CFatFileSystem()
       
    42 //
       
    43 // Destructor
       
    44 //
       
    45 	{
       
    46 	}
       
    47 
       
    48 TInt CFatFileSystem::Install()
       
    49 //
       
    50 // Install the file system
       
    51 //
       
    52 	{
       
    53 	iVersion=TVersion(KF32MajorVersionNumber,KF32MinorVersionNumber,KF32BuildVersionNumber);
       
    54 
       
    55 	// Read in setting from the config file to possibly make file server 
       
    56  	// use local time.
       
    57  	_LIT8(KFatConfigSection, "FatConfig");
       
    58  	_LIT8(KLocalTimeIfRemovable, "LocalTimeIfRemovable");
       
    59  	F32Properties::GetBool(KFatConfigSection, KLocalTimeIfRemovable, iUseLocalTimeIfRemovable);
       
    60 
       
    61 	return(SetName(&KFileSystemName_FAT));
       
    62 	}
       
    63 
       
    64 CMountCB* CFatFileSystem::NewMountL() const
       
    65 //
       
    66 // Create a new mount control block.
       
    67 //
       
    68 	{
       
    69 
       
    70 	return(CFatMountCB::NewL());
       
    71 	}
       
    72 
       
    73 CFileCB* CFatFileSystem::NewFileL() const
       
    74 //
       
    75 // Create a new file.
       
    76 //
       
    77 	{
       
    78 
       
    79 	return(new(ELeave) CFatFileCB());
       
    80 	}
       
    81 
       
    82 CDirCB* CFatFileSystem::NewDirL() const
       
    83 //
       
    84 // Create a new directory lister.
       
    85 //
       
    86 	{
       
    87 
       
    88 	return(CFatDirCB::NewL());
       
    89 	}
       
    90 
       
    91 CFormatCB* CFatFileSystem::NewFormatL() const
       
    92 //
       
    93 // Create a new media formatter.
       
    94 //
       
    95 	{
       
    96 
       
    97 	return (new(ELeave) CFatFormatCB());
       
    98 	}
       
    99 
       
   100 TInt CFatFileSystem::DefaultPath(TDes& aPath) const
       
   101 //
       
   102 // Return the initial default path.
       
   103 //
       
   104 	{
       
   105 
       
   106 	aPath=_L("?:\\");
       
   107 	aPath[0] = (TUint8) RFs::GetSystemDriveChar();
       
   108 	return(KErrNone);
       
   109 	}
       
   110 
       
   111 
       
   112 void CFatFileSystem::DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const
       
   113 //
       
   114 // Return the drive info. iBatteryState are already set.
       
   115 //
       
   116 	{
       
   117 
       
   118 	if(!IsValidLocalDriveMapping(aDriveNumber))
       
   119 		return;
       
   120 
       
   121     TLocalDriveCapsV2Buf localDriveCaps;
       
   122 	
       
   123 	TInt r = KErrNone;
       
   124 
       
   125 	// is the drive local?
       
   126 	if (!IsProxyDrive(aDriveNumber))
       
   127 		{
       
   128 		// if not valid local drive, use default values in localDriveCaps
       
   129 		// if valid local drive and not locked, use TBusLocalDrive::Caps() values
       
   130 		// if valid drive and locked, hard-code attributes
       
   131 		r = GetLocalDrive(aDriveNumber).Caps(localDriveCaps);
       
   132 		}
       
   133 	else  // this need to be made a bit nicer
       
   134 		{   
       
   135 		CExtProxyDrive* pD = GetProxyDrive(aDriveNumber);
       
   136 		if(pD)
       
   137 			r = pD->Caps(localDriveCaps);
       
   138 		else
       
   139 			r = KErrNotReady;	// What should the behaviour really be here?
       
   140 		}
       
   141 
       
   142 	if (r != KErrLocked )
       
   143 		{
       
   144 		anInfo.iMediaAtt=localDriveCaps().iMediaAtt;
       
   145 		}
       
   146 	else
       
   147 		{
       
   148 		anInfo.iMediaAtt = KMediaAttLocked | KMediaAttLockable | KMediaAttHasPassword;
       
   149 		}
       
   150 
       
   151 	anInfo.iType=localDriveCaps().iType;
       
   152 	anInfo.iDriveAtt=localDriveCaps().iDriveAtt;
       
   153 	}
       
   154 
       
   155 
       
   156 TBool CFatFileSystem::IsExtensionSupported() const
       
   157 //
       
   158 //
       
   159 //
       
   160 	{
       
   161 	return(ETrue);
       
   162 	}
       
   163 
       
   164 TBool CFatFileSystem::GetUseLocalTime() const
       
   165 	{
       
   166 	return iUseLocalTimeIfRemovable;
       
   167 	}
       
   168 
       
   169 void CFatFileSystem::SetUseLocalTime(TBool aFlag)
       
   170 	{
       
   171 	iUseLocalTimeIfRemovable = aFlag;
       
   172 	}
       
   173 
       
   174 /**
       
   175 Reports whether the specified interface is supported - if it is,
       
   176 the supplied interface object is modified to it
       
   177 
       
   178 @param aInterfaceId     The interface of interest
       
   179 @param aInterface       The interface object
       
   180 @return                 KErrNone if the interface is supported, otherwise KErrNotFound 
       
   181 
       
   182 @see CFileSystem::GetInterface()
       
   183 */
       
   184 TInt CFatFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
       
   185     {
       
   186     switch(aInterfaceId)
       
   187         {
       
   188         case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives
       
   189 			return KErrNone;
       
   190 
       
   191         default:
       
   192             return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput));
       
   193         }
       
   194     }