persistentstorage/store/UFILE/UF_STRM.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-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 "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 //
       
    15 
       
    16 #include "UF_STD.H"
       
    17 
       
    18 EXPORT_C RFileReadStream::RFileReadStream(RFile& aFile,TInt aPos)
       
    19 /** Constructs the read stream object, associates it with an already opened file, 
       
    20 and prepares the stream for reading.
       
    21 
       
    22 @param aFile A reference to the opened file.
       
    23 @param aPos The offset into the file from where the stream is to be read. Defaults 
       
    24 to zero. */
       
    25 	{
       
    26 	Attach(aFile,aPos);
       
    27 	}
       
    28 
       
    29 EXPORT_C TInt RFileReadStream::Open(RFs& aFs,const TDesC& aName,TUint aFileMode)
       
    30 /** Opens a file containing a stream and prepares the stream for reading.
       
    31 
       
    32 The stream will be read from offset zero in the file.
       
    33 
       
    34 @param aFs Handle to a file server session.
       
    35 @param aName The full path name of the file.
       
    36 @param aFileMode The mode in which the file is to be accessed. The mode is 
       
    37 defined by by the TFileMode type.
       
    38 @return KErrNone, if successful; otherwise, one of the other system wide eror 
       
    39 codes. 
       
    40 @see TFileMode */
       
    41 	{
       
    42 	TInt r=iSource.Open(aFs,aName,aFileMode);
       
    43 	if (r==KErrNone)
       
    44 		RReadStream::Attach(&iSource);
       
    45 	return r;
       
    46 	}
       
    47 
       
    48 EXPORT_C void RFileReadStream::Attach(RFile& aFile,TInt aPos)
       
    49 /** Associates this stream with an already opened file and prepares the stream 
       
    50 for reading.
       
    51 
       
    52 @param aFile A reference to the opened file.
       
    53 @param aPos The offset into the file from where the stream is to be read. Defaults 
       
    54 to zero. */
       
    55 	{
       
    56 	iSource.Attach(aFile,aPos);
       
    57 	RReadStream::Attach(&iSource);
       
    58 	}
       
    59 
       
    60 EXPORT_C RFileWriteStream::RFileWriteStream(RFile& aFile,TInt aPos)
       
    61 /** Constructs the write stream object, associates it with an already opened file, 
       
    62 and prepares the stream for writing.
       
    63 
       
    64 @param aFile A reference to the opened file.
       
    65 @param aPos The offset into the file where the stream is to be written. Defaults 
       
    66 to zero. */
       
    67 	{
       
    68 	Attach(aFile,aPos);
       
    69 	}
       
    70 
       
    71 EXPORT_C TInt RFileWriteStream::Open(RFs& aFs,const TDesC& aName,TUint aFileMode)
       
    72 /** Opens a file containing a stream and prepares the stream for writing.
       
    73 
       
    74 The stream will be written to offset zero in the file.
       
    75 
       
    76 @param aFs Handle to a file server session.
       
    77 @param aName The full path name of the file.
       
    78 @param aFileMode The mode in which the file is to be accessed. The mode is 
       
    79 defined by by the TFileMode type.
       
    80 @return KErrNone, if successful; otherwise, one of the other system wide error 
       
    81 codes.
       
    82 @see TFileMode */
       
    83 	{
       
    84 	TInt r=iSink.Open(aFs,aName,aFileMode);
       
    85 	if (r==KErrNone)
       
    86 		RWriteStream::Attach(&iSink);
       
    87 	return r;
       
    88 	}
       
    89 
       
    90 EXPORT_C TInt RFileWriteStream::Create(RFs& aFs,const TDesC& aName,TUint aFileMode)
       
    91 /** Creates a new file, associates it with this stream, and prepares the stream 
       
    92 for writing.
       
    93 
       
    94 The stream will be written to offset zero in the file.
       
    95 
       
    96 @param aFs Handle to a file server session.
       
    97 @param aName The full path name of the new file. A file with this name must 
       
    98 not already exist. 
       
    99 @param aFileMode The mode in which the file is to be accessed. The mode is 
       
   100 defined by by the TFileMode type.
       
   101 @return KErrNone, if successful; otherwise, one of the other system wide error 
       
   102 codes.
       
   103 @see TFileMode */
       
   104 	{
       
   105 	TInt r=iSink.Create(aFs,aName,aFileMode);
       
   106 	if (r==KErrNone)
       
   107 		RWriteStream::Attach(&iSink);
       
   108 	return r;
       
   109 	}
       
   110 
       
   111 EXPORT_C TInt RFileWriteStream::Replace(RFs& aFs,const TDesC& aName,TUint aFileMode)
       
   112 /** Creates a new file, associates the file with this stream, and prepares the 
       
   113 stream for writing.
       
   114 
       
   115 The file replaces any existing file of the same name.
       
   116 
       
   117 The stream will be written to offset zero in the file.
       
   118 
       
   119 @param aFs Handle to a file server session.
       
   120 @param aName The full path name of the file.
       
   121 @param aFileMode The mode in which the file is to be accessed. The mode is 
       
   122 defined by by the TFileMode type.
       
   123 @return KErrNone, if successful; otherwise, one of the other system wide error 
       
   124 codes.
       
   125 @see TFileMode */
       
   126 	{
       
   127 	TInt r=iSink.Replace(aFs,aName,aFileMode);
       
   128 	if (r==KErrNone)
       
   129 		RWriteStream::Attach(&iSink);
       
   130 	return r;
       
   131 	}
       
   132 
       
   133 EXPORT_C TInt RFileWriteStream::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
       
   134 /** Creates a temporary file, associates it with this stream, and prepares the 
       
   135 stream for writing.
       
   136 
       
   137 The new file is created in the specified path and a unique file name is generated 
       
   138 by the file server.
       
   139 
       
   140 Note that the store framework does not delete a temporary file after it is 
       
   141 closed.
       
   142 
       
   143 The stream will be written to offset zero in the file.
       
   144 
       
   145 @param aFs Handle to a file server session.
       
   146 @param aPath The path where the new file is to be created.
       
   147 @param aName On return, contains the full path name of the new file.
       
   148 @param aFileMode The mode in which the file is to be accessed. The mode is 
       
   149 defined by by the TFileMode type.
       
   150 @return KErrNone, if successful; otherwise, one of the other system wide error 
       
   151 codes.
       
   152 @see TFileMode */
       
   153 	{
       
   154 	TInt r=iSink.Temp(aFs,aPath,aName,aFileMode);
       
   155 	if (r==KErrNone)
       
   156 		RWriteStream::Attach(&iSink);
       
   157 	return r;
       
   158 	}
       
   159 
       
   160 EXPORT_C void RFileWriteStream::Attach(RFile& aFile,TInt aPos)
       
   161 /** Associates this stream with an already opened file and prepares the stream 
       
   162 for writing.
       
   163 
       
   164 @param aFile A reference to the opened file.
       
   165 @param aPos The offset into the file where the stream is to be written. Defaults 
       
   166 to zero. */
       
   167 	{
       
   168 	iSink.Attach(aFile,aPos);
       
   169 	RWriteStream::Attach(&iSink);
       
   170 	}
       
   171