1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/fs_utils/filesystem_utils.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,118 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +// Collection of common constants, utility functions, etc. for the file server and file systems.
1.19 +// Definitions here must be filesystem-agnostic, i.e. generic enougs to be used by every file system
1.20 +//
1.21 +// This is the internal file and must not be exported.
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalTechnology
1.26 +*/
1.27 +
1.28 +#if !defined(__FILESYSTEM_UTILS_H__)
1.29 +#define __FILESYSTEM_UTILS_H__
1.30 +
1.31 +#if !defined(__E32BASE_H__)
1.32 +#include <e32base.h>
1.33 +#endif
1.34 +
1.35 +//#######################################################################################################################################
1.36 +//# constants definitions
1.37 +//#######################################################################################################################################
1.38 +
1.39 +const TUint KBitsInByteLog2 = 3;
1.40 +const TUint KBitsInByte = 1<<KBitsInByteLog2;
1.41 +
1.42 +
1.43 +const TUint16 K1KiloByteLog2 = 10;
1.44 +const TUint32 K1KiloByte = 1<<K1KiloByteLog2;
1.45 +const TUint32 K1MegaByte = 1<<20;
1.46 +
1.47 +const TUint32 K1uSec = 1; ///< 1 misrosecond in TTimeIntervalMicroSeconds32
1.48 +const TUint32 K1mSec = 1000; ///< 1 millisecond in TTimeIntervalMicroSeconds32
1.49 +const TUint32 K1Sec = 1000*K1mSec; ///< 1 second in TTimeIntervalMicroSeconds32
1.50 +
1.51 +//---------------------------------------------------------------------------------------------------------------------------------------
1.52 +
1.53 +const TUint KDefSectorSzLog2=9; ///< Log2 of the default sector size for the media
1.54 +const TUint KDefaultSectorSize = 1 << KDefSectorSzLog2; ///< Default sector size for the media, 512 bytes
1.55 +
1.56 +//#######################################################################################################################################
1.57 +//# some useful utility functions
1.58 +//#######################################################################################################################################
1.59 +
1.60 +inline TUint32 Pow2(TUint32 aVal); //-- return 2^aVal
1.61 +inline TUint32 Pow2_32(TUint32 aVal); //-- return 2^aVal
1.62 +inline TUint64 Pow2_64(TUint32 aVal); //-- return 2^aVal
1.63 +
1.64 +inline TBool IsPowerOf2(TUint32 aVal); //-- return ETrue if aVal is a power of 2
1.65 +inline TBool IsPowerOf2_64(TUint64 aVal); //-- return ETrue if aVal is a power of 2
1.66 +
1.67 +inline TUint32 RoundDown(TUint32 aVal, TUint32 aGranularityLog2);
1.68 +inline TUint32 RoundUp(TUint32 aVal, TUint32 aGranularityLog2);
1.69 +
1.70 +inline TBool BoolXOR(TBool a1, TBool a2); //-- return Boolean XOR of a1 and a2
1.71 +
1.72 +inline TUint32 Log2_inline(TUint32 aVal); //-- Calculates the Log2(aVal)
1.73 +TUint32 Log2(TUint32 aVal); //-- Calculates the Log2(aVal)
1.74 +
1.75 +inline TUint32 Count1Bits_inline(TUint32 aVal); //-- counts number of '1' bits in the aVal
1.76 +TUint32 Count1Bits(TUint32 aVal); //-- counts number of '1' bits in the aVal
1.77 +
1.78 +//-----------------------------------------------------------------------------
1.79 +
1.80 +TPtrC RemoveTrailingDots(const TDesC& aName); //-- Removes trailing dots from aName. "Name..." -> "Name"
1.81 +
1.82 +
1.83 +//#######################################################################################################################################
1.84 +/**
1.85 + A class representing a simple abstraction of the 32 bit flags
1.86 +*/
1.87 +class T32Bits
1.88 +{
1.89 + public:
1.90 + T32Bits() : iData(0) {}
1.91 +
1.92 + inline void Clear();
1.93 + inline TBool HasBitsSet() const;
1.94 + inline void SetBit(TUint32 aIndex);
1.95 + inline TBool operator[](TUint32 aIndex) const;
1.96 +
1.97 + private:
1.98 + TUint32 iData; ///< 32 bits data
1.99 +};
1.100 +
1.101 +
1.102 +
1.103 +
1.104 +
1.105 +
1.106 +#include "filesystem_utils.inl"
1.107 +
1.108 +
1.109 +#endif //__FILESYSTEM_UTILS_H__
1.110 +
1.111 +
1.112 +
1.113 +
1.114 +
1.115 +
1.116 +
1.117 +
1.118 +
1.119 +
1.120 +
1.121 +