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