camerauis/cameraapp/generic/inc/cameracontroller/camfilesaveutility.h
changeset 19 d9aefe59d544
parent 3 8b2d6d0384b0
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Help saving buffer of data (e.g. image content) to a file
       
    15 *                with one function call. Used for testing purposes.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CAM_FILESAVEUTILITY_H
       
    21 #define CAM_FILESAVEUTILITY_H
       
    22 
       
    23 
       
    24 #include <f32file.h>
       
    25 #include <pathinfo.h>
       
    26 
       
    27 #include "camlogging.h"
       
    28 
       
    29 namespace NCamCameraController
       
    30   {
       
    31   inline void SaveImageDataToFileL( const TDesC8& aData, const TDesC& aFilename )
       
    32     {
       
    33     RFs fs;
       
    34     User::LeaveIfError( fs.Connect() );
       
    35     CleanupClosePushL( fs );
       
    36     
       
    37     
       
    38     RFile file;
       
    39     CleanupClosePushL( file );
       
    40   
       
    41     TFileName filename;
       
    42     filename.Append( PathInfo::PhoneMemoryRootPath() );
       
    43     filename.Append( PathInfo::ImagesPath() );
       
    44     filename.Append( aFilename );
       
    45   
       
    46     PRINT1( _L("CamTest: SaveImageDataToFileL file(%S)"), &filename );
       
    47     
       
    48     User::LeaveIfError( file.Replace( fs, filename, EFileShareExclusive|EFileWrite ) );
       
    49     User::LeaveIfError( file.Write( aData ) );
       
    50     
       
    51     CleanupStack::PopAndDestroy( 2 ); // file, fs: Close()
       
    52     };
       
    53   }
       
    54 #endif // CAM_FILESAVEUTILITY_H
       
    55