os/kernelhwsrv/userlibandfileserver/fileserver/fs_utils/filesystem_utils.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
//  Collection of common constants, utility functions, etc. for the file server and file systems.
sl@0
    16
//  Definitions here must be filesystem-agnostic, i.e. generic enougs to be used by every file system
sl@0
    17
//
sl@0
    18
//  This is the internal file and must not be exported.
sl@0
    19
sl@0
    20
/**
sl@0
    21
    @file
sl@0
    22
    @internalTechnology
sl@0
    23
*/
sl@0
    24
sl@0
    25
#if !defined(__FILESYSTEM_UTILS_H__)
sl@0
    26
#define __FILESYSTEM_UTILS_H__
sl@0
    27
sl@0
    28
#if !defined(__E32BASE_H__)
sl@0
    29
#include <e32base.h>
sl@0
    30
#endif
sl@0
    31
sl@0
    32
//#######################################################################################################################################
sl@0
    33
//#   constants definitions
sl@0
    34
//#######################################################################################################################################
sl@0
    35
sl@0
    36
const TUint KBitsInByteLog2 = 3;
sl@0
    37
const TUint KBitsInByte = 1<<KBitsInByteLog2;
sl@0
    38
sl@0
    39
sl@0
    40
const TUint16 K1KiloByteLog2 = 10;
sl@0
    41
const TUint32 K1KiloByte = 1<<K1KiloByteLog2; 
sl@0
    42
const TUint32 K1MegaByte = 1<<20; 
sl@0
    43
sl@0
    44
const TUint32 K1uSec = 1;               ///< 1 misrosecond in TTimeIntervalMicroSeconds32
sl@0
    45
const TUint32 K1mSec = 1000;            ///< 1 millisecond in TTimeIntervalMicroSeconds32
sl@0
    46
const TUint32 K1Sec  = 1000*K1mSec;     ///< 1 second in TTimeIntervalMicroSeconds32
sl@0
    47
sl@0
    48
//---------------------------------------------------------------------------------------------------------------------------------------
sl@0
    49
sl@0
    50
const TUint KDefSectorSzLog2=9;                         ///< Log2 of the default sector size for the media 
sl@0
    51
const TUint KDefaultSectorSize = 1 << KDefSectorSzLog2; ///< Default sector size for the media, 512 bytes
sl@0
    52
sl@0
    53
//#######################################################################################################################################
sl@0
    54
//#   some useful utility functions
sl@0
    55
//#######################################################################################################################################
sl@0
    56
sl@0
    57
inline TUint32 Pow2(TUint32 aVal);          //-- return 2^aVal
sl@0
    58
inline TUint32 Pow2_32(TUint32 aVal);       //-- return 2^aVal
sl@0
    59
inline TUint64 Pow2_64(TUint32 aVal);       //-- return 2^aVal
sl@0
    60
sl@0
    61
inline TBool IsPowerOf2(TUint32 aVal);      //-- return ETrue if aVal is a power of 2 
sl@0
    62
inline TBool IsPowerOf2_64(TUint64 aVal);   //-- return ETrue if aVal is a power of 2 
sl@0
    63
sl@0
    64
inline TUint32 RoundDown(TUint32 aVal, TUint32 aGranularityLog2);
sl@0
    65
inline TUint32 RoundUp(TUint32 aVal, TUint32 aGranularityLog2);
sl@0
    66
sl@0
    67
inline TBool BoolXOR(TBool a1, TBool a2);           //-- return Boolean XOR of a1 and a2
sl@0
    68
sl@0
    69
inline TUint32 Log2_inline(TUint32 aVal);           //-- Calculates the Log2(aVal)
sl@0
    70
TUint32 Log2(TUint32 aVal);                         //-- Calculates the Log2(aVal)
sl@0
    71
sl@0
    72
inline TUint32 Count1Bits_inline(TUint32 aVal);     //-- counts number of '1' bits in the aVal
sl@0
    73
TUint32 Count1Bits(TUint32 aVal);                   //-- counts number of '1' bits in the aVal
sl@0
    74
sl@0
    75
//-----------------------------------------------------------------------------
sl@0
    76
sl@0
    77
TPtrC RemoveTrailingDots(const TDesC& aName); //-- Removes trailing dots from aName. "Name..." -> "Name"
sl@0
    78
sl@0
    79
sl@0
    80
//#######################################################################################################################################
sl@0
    81
/**
sl@0
    82
    A class representing a simple abstraction of the 32 bit flags
sl@0
    83
*/
sl@0
    84
class T32Bits
sl@0
    85
{
sl@0
    86
 public:
sl@0
    87
    T32Bits() : iData(0) {}
sl@0
    88
sl@0
    89
    inline void  Clear();
sl@0
    90
    inline TBool HasBitsSet() const;
sl@0
    91
    inline void SetBit(TUint32 aIndex);
sl@0
    92
    inline TBool operator[](TUint32 aIndex) const;
sl@0
    93
sl@0
    94
 private:
sl@0
    95
    TUint32 iData; ///< 32 bits data
sl@0
    96
};
sl@0
    97
sl@0
    98
sl@0
    99
sl@0
   100
sl@0
   101
sl@0
   102
sl@0
   103
#include "filesystem_utils.inl"
sl@0
   104
sl@0
   105
sl@0
   106
#endif //__FILESYSTEM_UTILS_H__
sl@0
   107
sl@0
   108
sl@0
   109
sl@0
   110
sl@0
   111
sl@0
   112
sl@0
   113
sl@0
   114
sl@0
   115
sl@0
   116
sl@0
   117
sl@0
   118