epoc32/include/bafl/sysutil.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/sysutil.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2000-2006 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  SysUtil API provides functions for applications to retrieve
williamr@2
    15
*                SW and language package versions and check whether there is
williamr@2
    16
*                free space on a disk drive.
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
#ifndef SYSUTIL_H
williamr@2
    22
#define SYSUTIL_H
williamr@2
    23
williamr@2
    24
#include <e32base.h>
williamr@2
    25
williamr@2
    26
/**
williamr@2
    27
* Helper constant to allocate buffers for GetSWVersion, GetLangSWVersion,
williamr@2
    28
* GetLangVersion.
williamr@2
    29
*/
williamr@2
    30
const TInt KSysUtilVersionTextLength = 64;
williamr@2
    31
williamr@2
    32
class RFs;
williamr@2
    33
williamr@2
    34
/**
williamr@2
    35
 *  SysUtil provides various utility methods for applications.
williamr@2
    36
 *
williamr@2
    37
 *  SysUtil API provides functions for applications to retrieve SW and language
williamr@2
    38
 *  package versions and check whether there is free space on a disk drive.
williamr@2
    39
 *
williamr@2
    40
 *  @lib sysutil.lib
williamr@2
    41
 *  @since S60 v2.0
williamr@2
    42
 */
williamr@2
    43
class SysUtil
williamr@2
    44
    {
williamr@2
    45
williamr@2
    46
public:
williamr@2
    47
williamr@2
    48
    /**
williamr@2
    49
     * Obtains the software version string.
williamr@2
    50
     *
williamr@2
    51
     * @since S60 v2.0
williamr@2
    52
     *
williamr@2
    53
     * Usage example:
williamr@2
    54
     * @code
williamr@2
    55
     * TBuf<KSysUtilVersionTextLength> version;
williamr@2
    56
     * if ( SysUtil::GetSWVersion( version ) == KErrNone )
williamr@2
    57
     *     {
williamr@2
    58
     *     // Use the version string.
williamr@2
    59
     *     ...
williamr@2
    60
     *     }
williamr@2
    61
     * @endcode
williamr@2
    62
     *
williamr@2
    63
     * @param aValue On return, contains the software version string.
williamr@2
    64
     *               The buffer should have space for KSysUtilVersionTextLength
williamr@2
    65
     *               characters.
williamr@2
    66
     *
williamr@2
    67
     * @return KErrNone on success, or one of the Symbian error codes if reading
williamr@2
    68
     *         the version string fails.
williamr@2
    69
     */
williamr@2
    70
    IMPORT_C static TInt GetSWVersion( TDes& aValue );
williamr@2
    71
williamr@2
    72
    /**
williamr@2
    73
     * Returns software version which the currently installed language package
williamr@2
    74
     * is compatible with.
williamr@2
    75
     *
williamr@2
    76
     * @since S60 v2.0
williamr@2
    77
     *
williamr@2
    78
     * @param aValue On return, contains the version string.
williamr@2
    79
     *               The buffer should have space for KSysUtilVersionTextLength
williamr@2
    80
     *               characters.
williamr@2
    81
     *
williamr@2
    82
     * @return KErrNone on success, or one of the Symbian error codes if reading
williamr@2
    83
     *         the version string fails.
williamr@2
    84
     */
williamr@2
    85
    IMPORT_C static TInt GetLangSWVersion( TDes& aValue );
williamr@2
    86
williamr@2
    87
    /**
williamr@2
    88
     * Obtains the version of the currently installed language package.
williamr@2
    89
     *
williamr@2
    90
     * @since S60 v2.0
williamr@2
    91
     *
williamr@2
    92
     * @param aValue On return, contains the language package version string.
williamr@2
    93
     *               The buffer should have space for KSysUtilVersionTextLength
williamr@2
    94
     *               characters.
williamr@2
    95
     *
williamr@2
    96
     * @return KErrNone on success, or one of the Symbian error codes if reading
williamr@2
    97
     *         the version string fails.
williamr@2
    98
     */
williamr@2
    99
    IMPORT_C static TInt GetLangVersion( TDes& aValue );
williamr@2
   100
williamr@2
   101
    /**
williamr@2
   102
     * Checks if free FFS (internal flash file system) storage space is or will
williamr@2
   103
     * fall below critical level. Static configuration value stored in Central
williamr@2
   104
     * Repository is used to determine the critical level for the FFS drive.
williamr@2
   105
     *
williamr@2
   106
     * @since S60 v2.0
williamr@2
   107
     *
williamr@2
   108
     * @param aFs File server session. Must be given if available, e.g. from
williamr@2
   109
     *            EIKON environment. If NULL, this method will create a
williamr@2
   110
     *            temporary session, which causes the method to consume more
williamr@2
   111
     *            time and system resources.
williamr@2
   112
     * @param aBytesToWrite Number of bytes the caller is about to write to
williamr@2
   113
     *                      FFS. If value 0 is given, this method checks
williamr@2
   114
     *                      if the current FFS space is already below critical
williamr@2
   115
     *                      level.
williamr@2
   116
     *
williamr@2
   117
     * @return ETrue if FFS space would go below critical level after writing
williamr@2
   118
     *         aBytesToWrite more data, EFalse otherwise.
williamr@2
   119
     *
williamr@2
   120
     * @leave Leaves with one of the Symbian error codes if checking the FFS
williamr@2
   121
     *        space fails, for instance if there is not enough free memory to
williamr@2
   122
     *        create a temporary connection to file server.
williamr@2
   123
     */
williamr@2
   124
    IMPORT_C static TBool FFSSpaceBelowCriticalLevelL(
williamr@2
   125
        RFs* aFs,
williamr@2
   126
        TInt aBytesToWrite = 0 );
williamr@2
   127
williamr@2
   128
williamr@2
   129
    /**
williamr@2
   130
     * Checks if free MMC storage space is or will fall below critical
williamr@2
   131
     * level. Static configuration value stored in Central Repository is
williamr@2
   132
     * used to determine the critical level for the MMC drive.
williamr@2
   133
     * PathInfo API is used to determine the drive letter for the MMC drive.
williamr@2
   134
     *
williamr@2
   135
     * @since S60 v2.0
williamr@2
   136
     *
williamr@2
   137
     * @param aFs File server session. Must be given if available, e.g. from
williamr@2
   138
     *            EIKON environment. If NULL, this method will create a
williamr@2
   139
     *            temporary session, which causes the method to consume more
williamr@2
   140
     *            time and system resources.
williamr@2
   141
     * @param aBytesToWrite Number of bytes the caller is about to write to
williamr@2
   142
     *                      MMC. If value 0 is given, this method checks
williamr@2
   143
     *                      if the current MMC space is already below critical
williamr@2
   144
     *                      level.
williamr@2
   145
     *
williamr@2
   146
     * @return ETrue if MMC space would go below critical level after writing
williamr@2
   147
     *         aBytesToWrite more data, EFalse otherwise.
williamr@2
   148
     *         EFalse if the system has no MMC drive support.
williamr@2
   149
     *
williamr@2
   150
     * @leave Leaves with one of the Symbian error codes if checking the MMC
williamr@2
   151
     *        space fails, for instance if the MMC drive contains no media or
williamr@2
   152
     *        there is not enough free memory to create a temporary connection to
williamr@2
   153
     *        file server.
williamr@2
   154
     */
williamr@2
   155
    IMPORT_C static TBool MMCSpaceBelowCriticalLevelL(
williamr@2
   156
        RFs* aFs,
williamr@2
   157
        TInt aBytesToWrite = 0 );
williamr@2
   158
williamr@2
   159
    /**
williamr@2
   160
     * Checks if free disk drive storage space is or will fall below critical
williamr@2
   161
     * level. Static configuration values stored in Central Repository are
williamr@2
   162
     * used to determine a critical level for each drive.
williamr@2
   163
     *
williamr@2
   164
     * Usage example:
williamr@2
   165
     * @code
williamr@2
   166
     * TInt dataSize = 500;
williamr@2
   167
     * if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFsSession, dataSize, EDriveC ) )
williamr@2
   168
     *     {
williamr@2
   169
     *     // Can not write the data, there's not enough free space on disk.
williamr@2
   170
     *     ...
williamr@2
   171
     *     }
williamr@2
   172
     * else
williamr@2
   173
     *     {
williamr@2
   174
     *     // It's ok to actually write the data.
williamr@2
   175
     *     ...
williamr@2
   176
     *     }
williamr@2
   177
     * @endcode
williamr@2
   178
     *
williamr@2
   179
     * @since S60 v2.0
williamr@2
   180
     *
williamr@2
   181
     * @param aFs File server session. Must be given if available, e.g. from
williamr@2
   182
     *            EIKON environment. If NULL, this method will create a
williamr@2
   183
     *            temporary session, which causes the method to consume more
williamr@2
   184
     *            time and system resources.
williamr@2
   185
     * @param aBytesToWrite Number of bytes the caller is about to write to
williamr@2
   186
     *                      disk. If value 0 is given, this method checks
williamr@2
   187
     *                      if the current disk space is already below critical
williamr@2
   188
     *                      level.
williamr@2
   189
     * @param aDrive Identifies the disk drive to be checked. Numeric values
williamr@2
   190
     *               for identifying disk drives are defined in TDriveNumber
williamr@2
   191
     *               enumeration.
williamr@2
   192
     *
williamr@2
   193
     * @see TDriveNumber in f32file.h.
williamr@2
   194
     *
williamr@2
   195
     * @return ETrue if disk space would go below critical level after writing
williamr@2
   196
     *         aBytesToWrite more data, EFalse otherwise.
williamr@2
   197
     *
williamr@2
   198
     * @leave Leaves with one of the Symbian error codes if checking the disk
williamr@2
   199
     *        space fails, for instance if the drive contains no media or there
williamr@2
   200
     *        is not enough free memory to create a temporary connection to
williamr@2
   201
     *        file server.
williamr@2
   202
     */
williamr@2
   203
    IMPORT_C static TBool DiskSpaceBelowCriticalLevelL(
williamr@2
   204
        RFs* aFs,
williamr@2
   205
        TInt aBytesToWrite,
williamr@2
   206
        TInt aDrive );
williamr@2
   207
williamr@2
   208
    };
williamr@2
   209
williamr@2
   210
#endif // SYSUTIL_H