userlibandfileserver/fileserver/sfsrv/cl_clamp.cpp
changeset 9 96e5fb8b040d
child 8 538db54a451d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\sfsrv\cl_clamp.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <f32file.h>
       
    19 
       
    20 
       
    21 EXPORT_C TInt RFileClamp::Clamp(RFile& aFile)
       
    22 /**
       
    23 	Clamp the supplied file and store the resulting cookie in this object.
       
    24 
       
    25 	@param	aFile			File to clamp.
       
    26 	@return					Symbian OS error code.
       
    27  */
       
    28 	{
       
    29 	return aFile.Clamp(*this);
       
    30 	}
       
    31 
       
    32 EXPORT_C TInt RFileClamp::Close(RFs& aFs)
       
    33 /**
       
    34 	Unclamp the file which was clamped with this object.
       
    35 	It is safe to call this function a handle that was not
       
    36 	successfully opened.
       
    37 
       
    38 	@param	aFs				File server session which was used to
       
    39 							generate this clamp cookie value.
       
    40 	@return					Symbian OS error code.
       
    41  */
       
    42 	{
       
    43 	TInt r = KErrNone;
       
    44 
       
    45 	TBool opened = !(iCookie[0] == 0 && iCookie[1] == 0);
       
    46 	if (opened)
       
    47 		{
       
    48 		r = aFs.Unclamp(*this);
       
    49 		if (r == KErrNone)
       
    50 			*this = RFileClamp();
       
    51 		}
       
    52 
       
    53 	return r;
       
    54 	}
       
    55 
       
    56