diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/storageserver/server/src/atdriveinfo.cpp --- a/memana/analyzetoolclient/storageserver/server/src/atdriveinfo.cpp Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Definitions for the class TATDriveInfo. -* -*/ - - - -// INCLUDE FILES -#include -#include -#include "atdriveinfo.h" -#include "atstorageservercommon.h" -#include "atlog.h" - -// ----------------------------------------------------------------------------- -// TATDriveInfo::TATDriveInfo -// C++ default constructor. -// ----------------------------------------------------------------------------- -// -TATDriveInfo::TATDriveInfo() - { - LOGSTR1( "TATD TATDriveInfo::TATDriveInfo()" ); - } - -// ----------------------------------------------------------------------------- -// TATDriveInfo::CreatePath() -// ----------------------------------------------------------------------------- -// -TInt TATDriveInfo::CreatePath( TDes& aPath, - const TDesC& aFileName, RFs& aFs ) - { - LOGSTR1( "TATD TInt TATDriveInfo::CreatePath()" ); - - // Drive letter - TChar driveLetter; - // Drive number - TInt dNumber( EDriveZ ); - TBool found( EFalse ); - // Drive type - TUint driveType( KDriveAttRemovable ); - TInt err( KErrNotFound ); - - while ( !found ) - { - // Get drive letter - if ( GetDrive( driveLetter, dNumber, aFs, driveType ) == KErrNotFound ) - { - if ( driveType == KDriveAttInternal ) - { - return KErrNotFound; - } - driveType = KDriveAttInternal; - dNumber = EDriveZ; - } - else - { - // Create path - aPath.Delete( 0, aPath.MaxLength() ); - aPath.Append( driveLetter ); - aPath.Append( KATDataFilePath ); - - // Make a directory for AToolStorageServer's logging data file - err = aFs.MkDir( aPath ); - LOGSTR2( "STSE > aFs.MkDir err = %i", err ); - - if ( !err || err == KErrAlreadyExists ) - { - if ( aFileName.Length() != 0 && - ( ( aPath.MaxLength() - aPath.Length() ) > aFileName.Length() ) ) - { - aPath.Append( aFileName ); - } - found = ETrue; - } - } - } - return err; - } - -// ----------------------------------------------------------------------------- -// TATDriveInfo::GetDrive() -// ----------------------------------------------------------------------------- -// -TInt TATDriveInfo::GetDrive( TChar& aDrive, TInt& aDriveNumber, RFs& aFs, - const TUint aDriveType ) - { - LOGSTR1( "TATD TInt TATDriveInfo::GetDrive()" ); - - // Contains drive information. - TDriveInfo driveInfo; - - for ( TInt i = aDriveNumber; i >= (TInt)EDriveA; i-- ) - { - // Gets information about a drive and the medium mounted on it. - // If error occured then skip to next drive. - if ( aFs.Drive( driveInfo, i ) != KErrNone ) - continue; - - // Test whether drive is available. If not, skip to next drive. - if ( driveInfo.iDriveAtt & KDriveAbsent || i == (TInt)EDriveD || - driveInfo.iDriveAtt & KDriveAttRom || - driveInfo.iMediaAtt & KMediaAttWriteProtected || - driveInfo.iDriveAtt & KDriveFileSysROFS ) - continue; - - // Maps a drive number to the corresponding character. - if ( aFs.DriveToChar( i, aDrive ) != KErrNone ) - continue; - - if ( driveInfo.iDriveAtt & aDriveType && - driveInfo.iType != EMediaNotPresent && - driveInfo.iType != EMediaCdRom ) - { - TUint status( 0 ); - - switch ( aDriveType ) - { - case KDriveAttRemovable: - { - // Get the drive status of the default removable mass storage. - if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone ) - { - // To indicate that the drive is physically removable. - if ( status & DriveInfo::EDriveRemovable && - !( status & DriveInfo::EDriveCorrupt ) ) - { - aDriveNumber = --i; - return KErrNone; - } - } - } - break; - case KDriveAttInternal: - { - // Get the drive status of the default removable mass storage. - if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone ) - { - // To indicate that the drive is internal and - // cannot be physically removed. - if ( status & DriveInfo::EDriveInternal && - !( status & DriveInfo::EDriveExternallyMountable ) ) - { - aDriveNumber = --i; - return KErrNone; - } - } - } - break; - - default: - break; - } - } - } - return KErrNotFound; - } - -// End of File