author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:34:56 +0100 | |
branch | RCL_3 |
changeset 44 | 3e88ff8f41d5 |
parent 43 | c1f20ce4abcf |
permissions | -rw-r--r-- |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
2 |
// All rights reserved. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
7 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
8 |
// Initial Contributors: |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
10 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
11 |
// Contributors: |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
12 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
13 |
// Description: |
44 | 14 |
// f32\sfat\sl_file.cpp |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
15 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
16 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
17 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
18 |
#include "sl_std.h" |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
19 |
#include "sl_cache.h" |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
20 |
#include <e32math.h> |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
21 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
22 |
const TInt KSeekIndexSize=128; // Cache 128 clusters |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
23 |
const TInt KSeekIndexSizeLog2=7; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
24 |
const TInt KFirstClusterNum=2; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
25 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
26 |
CFatFileCB::CFatFileCB() |
44 | 27 |
{ |
28 |
__PRINT1(_L("CFatFileCB created 0x%x"),this); |
|
29 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
30 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
31 |
CFatFileCB::~CFatFileCB() |
44 | 32 |
{ |
33 |
__PRINT1(_L("~CFatFileCB deleted 0x%x"),this); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
34 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
35 |
//-- a nasty trick to find out if the CFatFileCB is in consistent state on the moment of destruction. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
36 |
//-- Because of OOM conditions CFatFileCB might not be fully constructed and to be deleted, while FlushAll() |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
37 |
//-- implies valid iMount. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
38 |
const CMountCB* pMount = &Mount(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
39 |
if(pMount) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
40 |
{//-- do some finalisation work if CMountCB is valid |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
41 |
if(FileAttModified()) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
42 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
43 |
IndicateFileTimeModified(ETrue); //-- this will force writing file modification time to the media on Flush |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
44 |
TRAP_IGNORE(FlushAllL()); |
44 | 45 |
} |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
46 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
47 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
48 |
delete[] iSeekIndex; |
44 | 49 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
50 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
51 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
52 |
void CFatFileCB::CreateSeekIndex() |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
53 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
54 |
// Create a seek index |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
55 |
// |
44 | 56 |
{ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
57 |
|
44 | 58 |
iSeekIndex = new TUint32[KSeekIndexSize]; |
59 |
if (iSeekIndex == NULL) |
|
60 |
return; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
61 |
|
44 | 62 |
Mem::FillZ(iSeekIndex, sizeof(TUint32) * KSeekIndexSize); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
63 |
|
44 | 64 |
iSeekIndexSize=CalcSeekIndexSize(FCB_FileSize()); |
65 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
66 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
67 |
TInt CFatFileCB::SeekToPosition(TUint aNewRelCluster, TUint aClusterOffset) |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
68 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
69 |
// Use the seek index to set iCurrentPos.iCluster as close as possible to aNewRelCluster |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
70 |
// Return aNewRelCluster-aCurrentPos.iCluster |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
71 |
// |
44 | 72 |
{ |
73 |
TInt clusterOffset=aClusterOffset; |
|
74 |
TInt seekPos=(aNewRelCluster>>iSeekIndexSize)-1; |
|
75 |
__ASSERT_DEBUG(seekPos<KSeekIndexSize,Fault(EFatFileSeekIndexTooSmall)); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
76 |
|
44 | 77 |
while(seekPos>=0 && iSeekIndex[seekPos]==0 && clusterOffset!=0) |
78 |
{ |
|
79 |
seekPos--; |
|
80 |
clusterOffset--; |
|
81 |
} |
|
82 |
if (clusterOffset==0) // Counted back to the current cluster |
|
83 |
return(aClusterOffset); |
|
84 |
if (seekPos<0) |
|
85 |
{ |
|
86 |
iCurrentPos.iCluster=FCB_StartCluster(); |
|
87 |
return(aNewRelCluster); |
|
88 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
89 |
|
44 | 90 |
iCurrentPos.iCluster=iSeekIndex[seekPos]; |
91 |
return(aNewRelCluster-((seekPos+1)<<iSeekIndexSize)); |
|
92 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
93 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
94 |
void CFatFileCB::SetSeekIndexValueL(TUint aRelCluster, TUint aStoredCluster) |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
95 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
96 |
// Sets a value in the seekindex |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
97 |
// |
44 | 98 |
{ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
99 |
|
44 | 100 |
TInt seekPos=(aRelCluster>>iSeekIndexSize)-1; |
101 |
__ASSERT_DEBUG(seekPos<KSeekIndexSize,Fault(EFatFileSeekIndexTooSmall)); |
|
102 |
__ASSERT_DEBUG(seekPos>=0,Fault(EFatFileSeekIndexTooSmall2)); |
|
103 |
iSeekIndex[seekPos] = aStoredCluster; |
|
104 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
105 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
106 |
void CFatFileCB::CheckPosL(TUint aPos) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
107 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
108 |
// Check that the file is positioned correctly. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
109 |
// If aPos<currentPos attempt to guess the new position. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
110 |
// |
44 | 111 |
{ |
112 |
__PRINT1(_L("CFatFileCB::CheckPosL(%d)"), aPos); |
|
113 |
if (aPos==iCurrentPos.iPos) |
|
114 |
return; |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
115 |
__ASSERT_DEBUG(aPos <= FCB_FileSize(), Fault(EFatFilePosBeyondEnd)); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
116 |
|
44 | 117 |
TUint newRelCluster=aPos>>ClusterSizeLog2(); |
118 |
if ( aPos && (aPos==(newRelCluster<<ClusterSizeLog2())) ) |
|
119 |
newRelCluster--; |
|
120 |
TUint oldRelCluster=iCurrentPos.iPos>>ClusterSizeLog2(); |
|
121 |
||
122 |
if ( iCurrentPos.iPos && (iCurrentPos.iPos==(oldRelCluster<<ClusterSizeLog2())) ) |
|
123 |
oldRelCluster--; |
|
124 |
||
125 |
TInt clusterOffset=newRelCluster-oldRelCluster; |
|
126 |
TUint32 oldCluster=iCurrentPos.iCluster; |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
127 |
|
44 | 128 |
iCurrentPos.iPos=aPos; |
129 |
if (clusterOffset==0) |
|
130 |
return; |
|
131 |
TInt seekOffset=clusterOffset; |
|
132 |
if (iSeekIndex!=NULL) |
|
133 |
{ // Can alter iCurrentPos.iCluster |
|
134 |
seekOffset=SeekToPosition(newRelCluster,seekOffset); |
|
135 |
if (seekOffset==0) |
|
136 |
return; |
|
137 |
} |
|
138 |
if (clusterOffset==-1 && seekOffset!=1) |
|
139 |
{ // Check previous cluster |
|
140 |
TUint32 cluster=oldCluster-1; |
|
141 |
if (FAT().GetNextClusterL(cluster) && cluster==oldCluster) |
|
142 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
143 |
iCurrentPos.iCluster=oldCluster-1; |
44 | 144 |
return; |
145 |
} |
|
146 |
} |
|
147 |
if (seekOffset<0) |
|
148 |
{ |
|
149 |
seekOffset=newRelCluster; |
|
150 |
iCurrentPos.iCluster=FCB_StartCluster(); |
|
151 |
} |
|
152 |
while (seekOffset--) |
|
153 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
154 |
if (!FAT().GetNextClusterL(iCurrentPos.iCluster)) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
155 |
{ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
156 |
__PRINT(_L("CFatFileCB::CheckPosL() corrupt#1")); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
157 |
User::Leave(KErrCorrupt); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
158 |
} |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
159 |
TInt cluster=newRelCluster-seekOffset; |
44 | 160 |
if (iSeekIndex!=NULL && cluster && (cluster>>iSeekIndexSize)<<iSeekIndexSize==cluster) |
161 |
SetSeekIndexValueL(cluster,iCurrentPos.iCluster); |
|
162 |
} |
|
163 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
164 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
165 |
//----------------------------------------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
166 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
167 |
Initialize FileCB from file's entry data. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
168 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
169 |
@param aFatDirEntry this file DOS dir entry. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
170 |
@param aFileDosEntryPos this file DOS entry dir. iterator in the parent directory. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
171 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
172 |
void CFatFileCB::SetupL(const TFatDirEntry& aFatDirEntry, const TEntryPos& aFileDosEntryPos) |
44 | 173 |
{ |
174 |
__PRINT1(_L("CFatFileCB::SetupL[0x%x]"), this); |
|
175 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
176 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
177 |
//-- set up a file control block |
44 | 178 |
iCurrentPos.iCluster= FatMount().StartCluster(aFatDirEntry); |
179 |
iCurrentPos.iPos=0; |
|
180 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
181 |
SetAtt(aFatDirEntry.Attributes()); |
44 | 182 |
SetModified(aFatDirEntry.Time(FatMount().TimeOffset())); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
183 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
184 |
FCB_SetStartCluster(iCurrentPos.iCluster); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
185 |
FCB_SetFileSize(aFatDirEntry.Size()); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
186 |
|
44 | 187 |
iFileDosEntryPos = aFileDosEntryPos; |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
188 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
189 |
SetMaxSupportedSize(KMaxSupportedFatFileSize); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
190 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
191 |
//-- create seek index |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
192 |
ASSERT(!iSeekIndex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
193 |
CreateSeekIndex(); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
194 |
if(!iSeekIndex) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
195 |
User::Leave(KErrNoMemory); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
196 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
197 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
198 |
IndicateFileAttModified(EFalse); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
199 |
IndicateFileSizeModified(EFalse); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
200 |
IndicateFileTimeModified(EFalse); |
44 | 201 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
202 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
203 |
//----------------------------------------------------------------------------- |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
204 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
205 |
Read data from the file. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
206 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
207 |
@param aFilePos start read position within a file |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
208 |
@param aLength how many bytes to read; on return will be how many bytes actually read |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
209 |
@param aDes local buffer desctriptor |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
210 |
@param aMessage from file server, used to write data to the buffer in different address space. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
211 |
@param aDesOffset offset within data descriptor where the data will be copied |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
212 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
213 |
@leave on media read error |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
214 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
215 |
*/ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
216 |
void CFatFileCB::ReadL(TInt64 aPos,TInt& aLength, TDes8* aDes, const RMessagePtr2& aMessage, TInt aOffset) |
44 | 217 |
{ |
218 |
__PRINT3(_L("CFatFileCB::ReadL[0x%x] pos=%LU len=%d"), this, aPos, aLength); |
|
219 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
220 |
if((TUint64)aPos > KMaxSupportedFatFileSize-1) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
221 |
User::Leave(KErrNotSupported); //-- max. position in the file is 0xFFFFFFFE |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
222 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
223 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
224 |
|
44 | 225 |
CheckPosL(I64LOW(aPos)); |
226 |
||
227 |
const TUint startPos = iCurrentPos.iPos; |
|
228 |
const TUint curSize = FCB_FileSize(); |
|
229 |
const TUint length = (TUint)aLength; |
|
230 |
||
231 |
if((startPos + length > curSize) || (startPos > startPos + length) ) |
|
232 |
aLength=curSize-startPos; |
|
42
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
233 |
|
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
234 |
TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0; |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
235 |
|
42
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
236 |
FatMount().ReadFromClusterListL(iCurrentPos,aLength,aDes,aMessage,aOffset, flag); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
237 |
aLength=iCurrentPos.iPos-startPos; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
238 |
} |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
239 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
240 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
241 |
void CFatFileCB::ReadL(TInt aFilePos,TInt& aLength,const TAny* aTrg,const RMessagePtr2& aMessage) |
44 | 242 |
{ |
243 |
ReadL(TInt64(aFilePos),aLength,(TDes8*) aTrg,aMessage, 0); |
|
244 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
245 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
246 |
//----------------------------------------------------------------------------- |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
247 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
248 |
Write data to the file. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
249 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
250 |
@param aFilePos start write position within a file |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
251 |
@param aLength how many bytes to write; on return contain amount of data actually written |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
252 |
@param aDes local buffer desctriptor |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
253 |
@param aMessage from file server, used to write data to the media from different address space. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
254 |
@param aDesOffset offset within data descriptor |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
255 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
256 |
@leave on media read error |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
257 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
258 |
*/ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
259 |
void CFatFileCB::WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aSrc,const RMessagePtr2& aMessage, TInt aOffset) |
44 | 260 |
{ |
261 |
__PRINT3(_L("CFatFileCB::WriteL[0x%x] pos=%LU len=%d"), this, aPos, aLength); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
262 |
|
44 | 263 |
// FAT supports 32 bits only for file size |
264 |
TUint64 endPos = aPos + aLength; |
|
265 |
if(endPos > KMaxSupportedFatFileSize) |
|
266 |
User::Leave(KErrNotSupported); |
|
267 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
268 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
269 |
FatMount().CheckWritableL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
270 |
const TUint pos = I64LOW(aPos); |
44 | 271 |
CheckPosL(pos); |
272 |
||
273 |
const TUint startCluster = FCB_StartCluster(); |
|
274 |
const TUint length = (TUint)aLength; |
|
275 |
||
276 |
endPos = iCurrentPos.iPos + length; |
|
277 |
if ((endPos > FCB_FileSize()) || |
|
278 |
(iCurrentPos.iPos > endPos) ) // Overflow condition |
|
279 |
DoSetSizeL(iCurrentPos.iPos+length,EFalse); |
|
280 |
||
281 |
TUint startPos=iCurrentPos.iPos; |
|
282 |
TUint badcluster=0; |
|
283 |
TUint goodcluster=0; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
284 |
|
42
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
285 |
TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0; |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
286 |
|
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
287 |
TRAPD(ret, FatMount().WriteToClusterListL(iCurrentPos,aLength,aSrc,aMessage,aOffset,badcluster, goodcluster, flag)); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
288 |
|
44 | 289 |
if (ret == KErrCorrupt || ret == KErrDied) |
290 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
291 |
if(startCluster == 0) |
44 | 292 |
{ //Empty File, revert all the clusters allocated. |
293 |
const TUint32 cluster = FCB_StartCluster(); |
|
294 |
FCB_SetStartCluster(0); |
|
295 |
FCB_SetFileSize(0); |
|
296 |
IndicateFileSizeModified(ETrue); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
297 |
|
44 | 298 |
FlushAllL(); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
299 |
|
44 | 300 |
iCurrentPos.iCluster = 0; |
301 |
iCurrentPos.iPos = 0; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
302 |
|
44 | 303 |
FAT().FreeClusterListL(cluster); |
304 |
FAT().FlushL(); |
|
305 |
} |
|
306 |
else |
|
307 |
{ //Calculate the clusters required based on file size, revert extra clusters if allocated. |
|
308 |
const TUint curSize = FCB_FileSize(); |
|
309 |
TUint ClustersNeeded = curSize >> ClusterSizeLog2(); |
|
310 |
if(curSize > (ClustersNeeded << ClusterSizeLog2())) |
|
311 |
{ |
|
312 |
ClustersNeeded++; |
|
313 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
314 |
|
44 | 315 |
TUint32 cluster = FCB_StartCluster(); |
316 |
while(--ClustersNeeded) |
|
317 |
{ |
|
318 |
FAT().GetNextClusterL(cluster); |
|
319 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
320 |
|
44 | 321 |
iCurrentPos.iCluster = cluster; |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
322 |
|
44 | 323 |
if (FAT().GetNextClusterL(cluster)) |
324 |
{ |
|
325 |
FAT().FreeClusterListL(cluster); |
|
326 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
327 |
|
44 | 328 |
FAT().WriteFatEntryEofL(iCurrentPos.iCluster); |
329 |
FAT().FlushL(); |
|
330 |
} |
|
331 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
332 |
|
44 | 333 |
User::LeaveIfError(ret); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
334 |
|
44 | 335 |
if(badcluster != 0) |
336 |
{ |
|
337 |
if(FCB_StartCluster() == badcluster) |
|
338 |
{ |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
339 |
FCB_SetStartCluster(goodcluster); |
44 | 340 |
FlushStartClusterL(); |
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
TUint32 aCluster = FCB_StartCluster(); |
|
345 |
do |
|
346 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
347 |
if((TUint)badcluster == FAT().ReadL(aCluster)) |
44 | 348 |
{ |
349 |
FAT().WriteL(aCluster, goodcluster); |
|
350 |
FAT().FlushL(); |
|
351 |
break; |
|
352 |
} |
|
353 |
} |
|
354 |
while(FAT().GetNextClusterL(aCluster)); |
|
355 |
} |
|
356 |
} |
|
357 |
aLength=iCurrentPos.iPos-startPos; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
358 |
|
44 | 359 |
if(FatMount().IsRuggedFSys() && pos+(TUint)aLength > FCB_FileSize()) |
360 |
{ |
|
361 |
WriteFileSizeL(pos+aLength); |
|
362 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
363 |
|
44 | 364 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
365 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
366 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
367 |
void CFatFileCB::WriteL(TInt aFilePos,TInt& aLength,const TAny* aSrc,const RMessagePtr2& aMessage) |
44 | 368 |
{ |
369 |
WriteL(TInt64(aFilePos),aLength,(TDesC8*) aSrc,aMessage, 0); |
|
370 |
} |
|
371 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
372 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
373 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
374 |
//----------------------------------------------------------------------------- |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
375 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
376 |
void CFatFileCB::ResizeIndex(TInt aNewMult,TUint aNewSize) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
377 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
378 |
// Resize the seek index to accomodate a larger or smaller filesize |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
379 |
// Assumes KSeekIndexSize is a power of 2. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
380 |
// |
44 | 381 |
{ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
382 |
|
44 | 383 |
TInt maxNewIndex=aNewSize>>(ClusterSizeLog2()+aNewMult); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
384 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
385 |
|
44 | 386 |
TInt index=0; |
387 |
TInt indexEnd=KSeekIndexSize; |
|
388 |
TInt newValEnd=maxNewIndex; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
389 |
|
44 | 390 |
if (iSeekIndexSize<aNewMult) |
391 |
{ |
|
392 |
TInt newVal=index; |
|
393 |
TInt step=1<<(aNewMult-iSeekIndexSize); |
|
394 |
index+=step-1; |
|
395 |
while(index<indexEnd && newVal<newValEnd) |
|
396 |
{ |
|
397 |
iSeekIndex[newVal] = iSeekIndex[index]; |
|
398 |
newVal++; |
|
399 |
index+=step; |
|
400 |
} |
|
401 |
while(newVal<indexEnd) |
|
402 |
iSeekIndex[newVal++] = 0; |
|
403 |
} |
|
404 |
else |
|
405 |
{ |
|
406 |
TInt diffSize = iSeekIndexSize-aNewMult; |
|
407 |
TInt oldVal=(KSeekIndexSize>>diffSize) - 1; |
|
408 |
TInt newVal=indexEnd-1; |
|
409 |
TInt skip=(1<<diffSize)-1; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
410 |
|
44 | 411 |
if ((iSeekIndexSize - aNewMult) > KSeekIndexSizeLog2) |
412 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
413 |
ClearIndex(0); //-- Invalidate every entry. |
44 | 414 |
} |
415 |
else |
|
416 |
{ |
|
417 |
while(newVal>=index) |
|
418 |
{ |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
419 |
|
44 | 420 |
iSeekIndex[newVal--] = iSeekIndex[oldVal--]; |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
421 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
422 |
|
44 | 423 |
for(TInt i=skip;i>0;i--) |
424 |
{ |
|
425 |
iSeekIndex[newVal--] = 0; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
426 |
|
44 | 427 |
} |
428 |
} |
|
429 |
} |
|
430 |
} |
|
431 |
iSeekIndexSize=aNewMult; |
|
432 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
433 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
434 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
435 |
/** |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
436 |
Zero freed clusters in the index |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
437 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
438 |
@param aNewSize new size of the file that the index corresponds to. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
439 |
if = 0 all existing index will be zero filled |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
440 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
441 |
void CFatFileCB::ClearIndex(TUint aNewSize) |
44 | 442 |
{ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
443 |
|
44 | 444 |
if (!iSeekIndex) |
445 |
return; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
446 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
447 |
if(aNewSize==0) |
44 | 448 |
{ |
449 |
//-- zero fill all the array |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
450 |
Mem::FillZ(iSeekIndex, KSeekIndexSize*sizeof(TUint32)); |
44 | 451 |
return; |
452 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
453 |
|
44 | 454 |
// Files that fill up a cluster exactly do not have a trailing empty |
455 |
// cluster. So the entry for that position must also be invalidated |
|
456 |
aNewSize--; |
|
457 |
TInt firstInvalidIndex=aNewSize>>(iSeekIndexSize+ClusterSizeLog2()); |
|
458 |
||
459 |
TInt indexLen=KSeekIndexSize-firstInvalidIndex; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
460 |
|
44 | 461 |
Mem::FillZ(iSeekIndex+firstInvalidIndex, indexLen * sizeof(TUint32)); |
462 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
463 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
464 |
TInt CFatFileCB::CalcSeekIndexSize(TUint aSize) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
465 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
466 |
// Find the nearest power of 2 > aSize |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
467 |
// |
44 | 468 |
{ |
469 |
TInt count = 0; |
|
470 |
const TUint indexSize=KSeekIndexSize<<ClusterSizeLog2();//KSeekIndexSize=128 |
|
471 |
if (aSize<=indexSize) |
|
472 |
return(count); |
|
473 |
||
474 |
while((aSize>>=1)>0) |
|
475 |
{ |
|
476 |
count++; |
|
477 |
} |
|
478 |
return (count - (KSeekIndexSizeLog2 + ClusterSizeLog2()) + 1); |
|
479 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
480 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
481 |
//----------------------------------------------------------------------------- |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
482 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
483 |
Set file size. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
484 |
@param aSize new file size. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
485 |
*/ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
486 |
void CFatFileCB::SetSizeL(TInt64 aSize) |
44 | 487 |
{ |
488 |
__PRINT2(_L("CFatFileCB::SetSizeL[0x%x] sz=%LU"), this, aSize); |
|
489 |
||
490 |
//-- max. file size for FAT is 4GB-1 |
|
491 |
if (I64HIGH(aSize)) |
|
492 |
User::Leave(KErrNotSupported); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
493 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
494 |
DoSetSizeL(I64LOW(aSize), FatMount().IsRuggedFSys()); |
44 | 495 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
496 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
497 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
498 |
void CFatFileCB::SetSizeL(TInt aSize) |
44 | 499 |
{ |
500 |
SetSizeL(TInt64(aSize)); |
|
501 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
502 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
503 |
//----------------------------------------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
504 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
505 |
Shrink file to zero size. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
506 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
507 |
void CFatFileCB::DoShrinkFileToZeroSizeL() |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
508 |
{ |
44 | 509 |
ASSERT(FCB_FileSize()); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
510 |
ASSERT(FileSizeModified()); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
511 |
|
44 | 512 |
ClearIndex(0); //-- clear seek index array |
513 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
514 |
//-- update file dir. entry |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
515 |
const TUint32 cluster = FCB_StartCluster(); |
44 | 516 |
FCB_SetStartCluster(0); |
517 |
FCB_SetFileSize(0); |
|
518 |
FlushAllL(); |
|
519 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
520 |
//-- free cluster list. |
44 | 521 |
CheckPosL(0); |
522 |
FAT().FreeClusterListL(cluster); |
|
523 |
FAT().FlushL(); |
|
524 |
} |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
525 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
526 |
//----------------------------------------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
527 |
/* |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
528 |
Shrink file to smaller size, but > 0 |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
529 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
530 |
@param aNewSize new file size |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
531 |
@param aForceCachesFlush if ETrue, all file/FAT caches will be flushed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
532 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
533 |
void CFatFileCB::DoShrinkFileL(TUint32 aNewSize, TBool aForceCachesFlush) |
44 | 534 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
535 |
ASSERT(FileSizeModified()); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
536 |
ASSERT(FCB_FileSize() > aNewSize && aNewSize); |
44 | 537 |
|
538 |
if(aForceCachesFlush) |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
539 |
WriteFileSizeL(aNewSize); //-- write file size directly to its dir. entry |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
540 |
|
44 | 541 |
CheckPosL(aNewSize); |
542 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
543 |
TUint32 cluster=iCurrentPos.iCluster; |
44 | 544 |
if (FAT().GetNextClusterL(cluster)) |
545 |
{//-- truncate the cluster chain |
|
546 |
FAT().WriteFatEntryEofL(iCurrentPos.iCluster); |
|
547 |
FAT().FreeClusterListL(cluster); |
|
548 |
} |
|
549 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
550 |
ClearIndex(aNewSize); |
44 | 551 |
FAT().FlushL(); |
552 |
} |
|
553 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
554 |
//----------------------------------------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
555 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
556 |
Expand a file. |
44 | 557 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
558 |
@param aNewSize new file size. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
559 |
@param aForceCachesFlush if ETrue, all file/FAT caches will be flushed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
560 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
561 |
void CFatFileCB::DoExpandFileL(TUint32 aNewSize, TBool aForceCachesFlush) |
44 | 562 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
563 |
ASSERT(FCB_FileSize() < aNewSize); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
564 |
ASSERT(FileSizeModified()); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
565 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
566 |
const TUint32 KClusterSzLog2 = ClusterSizeLog2(); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
567 |
const TUint32 newSizeClusters = (TUint32)(((TUint64)aNewSize + Pow2(KClusterSzLog2) - 1) >> KClusterSzLog2); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
568 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
569 |
|
44 | 570 |
//-- expanding a file |
571 |
if (FCB_StartCluster() == 0) |
|
572 |
{//-- the initial file size is 0 (no cluster chain) |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
573 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
574 |
ClearIndex(0); //-- clear seek index array |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
575 |
//-- FAT().FreeClusterHint() will give us a hint of the last free cluster |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
576 |
const TUint32 tempStartCluster=FAT().AllocateClusterListL(newSizeClusters, FAT().FreeClusterHint()); |
44 | 577 |
FAT().FlushL(); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
578 |
|
44 | 579 |
iCurrentPos.iCluster=tempStartCluster; |
580 |
FCB_SetStartCluster(tempStartCluster); |
|
581 |
FCB_SetFileSize(aNewSize); |
|
582 |
FlushAllL(); |
|
583 |
} |
|
584 |
else |
|
585 |
{ |
|
586 |
const TUint curSize = FCB_FileSize(); |
|
587 |
const TUint32 oldSizeClusters = ((curSize + Pow2(KClusterSzLog2) - 1) >> KClusterSzLog2); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
588 |
ASSERT(newSizeClusters >= oldSizeClusters); |
44 | 589 |
const TUint newClusters = newSizeClusters-oldSizeClusters; //-- Number of clusters we need to append to the existing cluster chain |
590 |
if (newClusters) |
|
591 |
{ |
|
592 |
TEntryPos currentPos=iCurrentPos; |
|
593 |
CheckPosL(FCB_FileSize()); |
|
594 |
FAT().ExtendClusterListL(newClusters,iCurrentPos.iCluster); |
|
595 |
iCurrentPos=currentPos; |
|
596 |
} |
|
597 |
||
598 |
FAT().FlushL(); |
|
599 |
||
600 |
if(aForceCachesFlush) // write file size if increasing |
|
601 |
WriteFileSizeL(aNewSize); |
|
602 |
} |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
603 |
|
44 | 604 |
} |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
605 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
606 |
//----------------------------------------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
607 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
608 |
Set file size. This can involve extending/truncating file's cluster chain. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
609 |
@param aSize new file size |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
610 |
@param aForceCachesFlush if ETrue, all changes in metadata will go to the media immediately. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
611 |
it is used in Rugged FAT mode. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
612 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
613 |
void CFatFileCB::DoSetSizeL(TUint aSize, TBool aForceCachesFlush) |
44 | 614 |
{ |
615 |
__PRINT4(_L("CFatFileCB::DoSetSizeL[0x%x] sz:%d, oldSz:%d, flush:%d"), this, aSize, FCB_FileSize(), aForceCachesFlush); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
616 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
617 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
618 |
FatMount().CheckWritableL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
619 |
|
44 | 620 |
|
621 |
// Can not change the file size if it is clamped |
|
622 |
if(Mount().IsFileClamped(MAKE_TINT64(0,FCB_StartCluster())) > 0) |
|
623 |
User::Leave(KErrInUse); |
|
624 |
||
625 |
if(aSize == FCB_FileSize()) |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
626 |
return; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
627 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
628 |
IndicateFileSizeModified(ETrue); |
41
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
629 |
IndicateFileAttModified(ETrue); // ensure file size is flushed |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
630 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
631 |
TInt newIndexMult=CalcSeekIndexSize(aSize); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
632 |
if (iSeekIndex!=NULL && newIndexMult!=iSeekIndexSize) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
633 |
ResizeIndex(newIndexMult,aSize); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
634 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
635 |
//------------------------------------------- |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
636 |
//-- shrinking file to 0 size |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
637 |
if(aSize == 0) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
638 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
639 |
DoShrinkFileToZeroSizeL(); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
640 |
return; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
641 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
642 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
643 |
//------------------------------------------- |
44 | 644 |
//-- shrinking file to non-zero size |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
645 |
if (aSize < FCB_FileSize()) |
44 | 646 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
647 |
DoShrinkFileL(aSize, aForceCachesFlush); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
648 |
return; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
649 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
650 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
651 |
//------------------------------------------- |
44 | 652 |
//-- expanding a file |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
653 |
DoExpandFileL(aSize, aForceCachesFlush); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
654 |
|
44 | 655 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
656 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
657 |
//----------------------------------------------------------------------------- |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
658 |
/** |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
659 |
Set file entry details, like file attributes and modified time |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
660 |
This method doesn't write data to the media immediately, instead, all modified data are cached and can be flushed later |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
661 |
in FlushAllL() |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
662 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
663 |
@param aTime file modification time (and last access as well) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
664 |
@param aSetAttMask file attributes OR mask |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
665 |
@param aClearAttMask file attributes AND mask |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
666 |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
667 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
668 |
void CFatFileCB::SetEntryL(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask) |
44 | 669 |
{ |
670 |
__PRINT1(_L("CFatFileCB::SetEntryL[0x%x]"), this); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
671 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
672 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
673 |
FatMount().CheckWritableL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
674 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
675 |
//-- change file attributes |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
676 |
const TUint setAttMask = (aSetAttMask & KEntryAttMaskSupported); //-- supported attributes to set |
41
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
677 |
TUint oldAtt = Att(); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
678 |
TUint newAtt = oldAtt; |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
679 |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
680 |
if (setAttMask|aClearAttMask) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
681 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
682 |
newAtt |= setAttMask; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
683 |
newAtt &= ~aClearAttMask; |
41
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
684 |
if (newAtt != oldAtt) |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
685 |
{ |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
686 |
SetAtt(newAtt); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
687 |
IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
688 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
689 |
} |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
690 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
691 |
//-- set file entry modification time if required |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
692 |
if (aSetAttMask&KEntryAttModified) |
41
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
693 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
694 |
SetModified(aTime); //-- set file modified time |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
695 |
IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
696 |
IndicateFileTimeModified(ETrue); //-- this will force writing file mod. time to the media on Flush |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
697 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
698 |
|
44 | 699 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
700 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
701 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
702 |
//----------------------------------------------------------------------------- |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
703 |
/** |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
704 |
The same as FlushAllL(). This method is called from RFile::Flush() |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
705 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
706 |
void CFatFileCB::FlushDataL() |
44 | 707 |
{ |
708 |
__PRINT1(_L("CFatFileCB::FlushDataL[0x%x]"), this); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
709 |
FlushAllL(); |
44 | 710 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
711 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
712 |
//----------------------------------------------------------------------------- |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
713 |
/** |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
714 |
Flush the fide directory entry data: files size, attributes, time etc. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
715 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
716 |
void CFatFileCB::FlushAllL() |
44 | 717 |
{ |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
718 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
719 |
//-- define this symbol in order to enable legacy behaviour, i.e. compulsory updating file dir. entry on flush. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
720 |
//-- otherwise the FlushAllL() will update the file dir. entry only if it differs from what is on the media, i.e. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
721 |
//-- file size, start cluster, attributes and modification timestamp |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
722 |
#define ALWAYS_UPDATE_ENTRY_ON_FLUSH |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
723 |
|
44 | 724 |
__PRINT1(_L("CFatFileCB::FlushAllL[0x%x]"), this); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
725 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
726 |
if (Mount().IsCurrentMount()==EFalse) |
44 | 727 |
User::Leave(KErrDisMounted); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
728 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
729 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
730 |
FatMount().CheckWritableL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
731 |
|
44 | 732 |
if(!FileSizeModified() && !FileAttModified() && !FileTimeModified()) |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
733 |
return; //-- nothing has changed in the file entry at all |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
734 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
735 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
736 |
//-- read file dir. entry |
44 | 737 |
TFatDirEntry entry; |
738 |
FatMount().ReadDirEntryL(iFileDosEntryPos,entry); |
|
739 |
__ASSERT_ALWAYS(entry.IsEndOfDirectory()==EFalse,User::Leave(KErrCorrupt)); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
740 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
741 |
//-- the problem with KEntryAttModified here is that the file server uses this flag to |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
742 |
//-- deal with dirty file data. This means that this flag can be set even if there were no changes |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
743 |
//-- in file time and attributes. Just check if any of the entry field has changed at all |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
744 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
745 |
TBool bUpdateDirEntry = ETrue; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
746 |
const TTimeIntervalSeconds timeOffset = FatMount().TimeOffset(); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
747 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
748 |
#ifndef ALWAYS_UPDATE_ENTRY_ON_FLUSH |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
749 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
750 |
TBool bTimeModified = FileTimeModified(); //-- check if file modifiication time has been changed explicitly |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
751 |
if(bTimeModified) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
752 |
{//-- additional check; for FAT entry modification time has 2 sec. granularity. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
753 |
bTimeModified = !entry.IsTimeTheSame(iModified, timeOffset); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
754 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
755 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
756 |
if(!bTimeModified) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
757 |
if(//-- TS is the same as on the media, check other entry fields |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
758 |
(entry.Attributes() == (Att() & KEntryAttMaskSupported)) && //-- file attributes have not changed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
759 |
(entry.Size() == FCB_FileSize()) && //-- file size hasn't changed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
760 |
(entry.StartCluster() == FCB_StartCluster()) //-- file start cluster hasn't changed |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
761 |
) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
762 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
763 |
bUpdateDirEntry = EFalse; //-- no need to update file dir. entry |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
764 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
765 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
766 |
#endif //#ifndef ALWAYS_UPDATE_ENTRY_TS_ON_FLUSH |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
767 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
768 |
if(bUpdateDirEntry) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
769 |
{//-- write entry to the media |
44 | 770 |
__PRINT(_L(" CFatFileCB::FlushAllL #1")); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
771 |
entry.SetAttributes(Att() & KEntryAttMaskSupported); |
44 | 772 |
entry.SetSize(FCB_FileSize()); |
773 |
entry.SetTime(iModified, timeOffset); |
|
774 |
||
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
775 |
entry.SetStartCluster(FCB_StartCluster()); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
776 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
777 |
const TBool setNotify = FatMount().GetNotifyUser(); |
44 | 778 |
if(setNotify) |
779 |
{ |
|
780 |
FatMount().SetNotifyOff(); // do not launch a notifier |
|
781 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
782 |
|
44 | 783 |
TRAPD(ret, FatMount().WriteDirEntryL(iFileDosEntryPos,entry)); |
784 |
||
785 |
if(setNotify) |
|
786 |
{ |
|
787 |
FatMount().SetNotifyOn(); |
|
788 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
789 |
|
44 | 790 |
User::LeaveIfError(ret); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
791 |
|
44 | 792 |
IndicateFileSizeModified(EFalse); |
793 |
IndicateFileTimeModified(EFalse); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
794 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
795 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
796 |
|
44 | 797 |
//-- KEntryAttModified must be reset anyway |
798 |
IndicateFileAttModified(EFalse); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
799 |
} |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
800 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
801 |
//----------------------------------------------------------------------------- |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
802 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
803 |
/** |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
804 |
Rename already opened file. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
805 |
@param aNewName new file name; all trailing dots from the name will be removed |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
806 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
807 |
void CFatFileCB::RenameL(const TDesC& aNewName) |
44 | 808 |
{ |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
809 |
__PRINT2(_L("CFatFileCB::RenameL[0x%x], name:%S"),this, &aNewName); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
810 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
811 |
FatMount().CheckStateConsistentL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
812 |
FatMount().CheckWritableL(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
813 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
814 |
const TPtrC fileName = RemoveTrailingDots(aNewName); //-- remove trailing dots from the name |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
815 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
816 |
|
44 | 817 |
FatMount().DoRenameOrReplaceL(*iFileName, fileName, CFatMountCB::EModeRename, iFileDosEntryPos); |
818 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
819 |
AllocBufferL(iFileName, fileName); |
44 | 820 |
|
821 |
if(!FatMount().IsRuggedFSys()) |
|
822 |
FAT().FlushL(); |
|
823 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
824 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
825 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
826 |
//*********************************************************** |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
827 |
//* BlockMap interface |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
828 |
//*********************************************************** |
44 | 829 |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
830 |
TInt CFatFileCB::BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
831 |
// |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
832 |
// Retrieves the block map of a given section of the file, in the FAT file system. |
44 | 833 |
// |
834 |
{ |
|
835 |
__PRINT2(_L("CFatFileCB::BlockMap aStartPos=%ld aEndPos=%ld"), aStartPos, aEndPos); |
|
836 |
||
837 |
if ( I64HIGH(aStartPos) || I64HIGH(aEndPos) ) |
|
838 |
return KErrNotSupported; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
839 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
840 |
TUint startPos = I64LOW(aStartPos); |
44 | 841 |
TUint endPos = I64LOW(aEndPos); |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
842 |
|
44 | 843 |
// aEndPos will always be >=0 at this point |
844 |
const TUint length = endPos - startPos; |
|
845 |
||
846 |
// Store the position of cluster zero in aInfo |
|
847 |
CFatMountCB& fatMount = FatMount(); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
848 |
|
44 | 849 |
TInt drvNo=-1; |
850 |
TBusLocalDrive* locDrv; |
|
851 |
if((fatMount.LocalDrive()->GetLocalDrive(locDrv)==KErrNone) && ((drvNo=GetLocalDriveNumber(locDrv))>=0) && (drvNo<KMaxLocalDrives)) |
|
852 |
aInfo.iLocalDriveNumber=drvNo; |
|
853 |
else |
|
854 |
return KErrNotSupported; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
855 |
|
44 | 856 |
TInt r; |
857 |
||
42
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
41
diff
changeset
|
858 |
// Fetch the address of cluster 0 |
44 | 859 |
TRAP(r, aInfo.iStartBlockAddress = fatMount.FAT().DataPositionInBytesL(KFirstClusterNum)); |
860 |
if (r != KErrNone) |
|
861 |
return r; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
862 |
|
44 | 863 |
|
864 |
TRAP(r, CheckPosL(startPos)); |
|
865 |
if (r != KErrNone) |
|
866 |
return r; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
867 |
|
44 | 868 |
aInfo.iBlockStartOffset = fatMount.ClusterRelativePos(iCurrentPos.iPos); |
869 |
aInfo.iBlockGranularity = 1 << FatMount().ClusterSizeLog2(); |
|
870 |
const TUint myStartPos = iCurrentPos.iPos; |
|
871 |
if ( myStartPos + length > FCB_FileSize()) |
|
872 |
return KErrArgument; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
873 |
|
44 | 874 |
TRAP(r, FatMount().BlockMapReadFromClusterListL(iCurrentPos, length, aInfo)); |
875 |
if (r != KErrNone) |
|
876 |
return r; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
877 |
|
44 | 878 |
aStartPos = iCurrentPos.iPos; |
879 |
if ((I64LOW(aStartPos) == FCB_FileSize()) || ( I64LOW(aStartPos) == (myStartPos + length))) |
|
880 |
return KErrCompletion; |
|
881 |
else |
|
882 |
return KErrNone; |
|
883 |
} |
|
884 |
||
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
885 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
886 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
887 |
TInt CFatFileCB::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput) |
44 | 888 |
{ |
889 |
switch(aInterfaceId) |
|
890 |
{ |
|
891 |
case EExtendedFileInterface: |
|
892 |
((CFileCB::MExtendedFileInterface*&) aInterface) = this; |
|
893 |
return KErrNone; |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
894 |
|
44 | 895 |
case EBlockMapInterface: |
896 |
aInterface = (CFileCB::MBlockMapInterface*) this; |
|
897 |
return KErrNone; |
|
898 |
||
899 |
case EGetLocalDrive: |
|
900 |
return FatMount().LocalDrive()->GetLocalDrive((TBusLocalDrive*&) aInterface); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
901 |
|
44 | 902 |
default: |
903 |
return CFileCB::GetInterface(aInterfaceId,aInterface,aInput); |
|
904 |
} |
|
905 |
} |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
906 |
|
44 | 907 |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
908 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
909 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
910 |
/** |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
911 |
Overwrites file's start cluster (iStartCluster) in its directory entry. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
912 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
913 |
void CFatFileCB::FlushStartClusterL() |
44 | 914 |
{ |
915 |
__PRINT1(_L("CFatFileCB::FlushStartClusterL[0x%x]"), this); |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
916 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
917 |
CFatMountCB& mount = FatMount(); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
918 |
TFatDirEntry dirEntry; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
919 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
920 |
mount.ReadDirEntryL(iFileDosEntryPos, dirEntry); //-- read this file's dir. entry |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
921 |
dirEntry.SetStartCluster(FCB_StartCluster()); //-- set new start cluster |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
922 |
mount.WriteDirEntryL(iFileDosEntryPos, dirEntry);//-- write the entry back |
44 | 923 |
} |
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
924 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
925 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
926 |
/** |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
927 |
This is a RuggedFAT - specific method. Writes file size to the corresponding field of its file directory entry. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
928 |
*/ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
929 |
void CFatFileCB::WriteFileSizeL(TUint aSize) |
44 | 930 |
{ |
931 |
__PRINT2(_L("CFatFileCB::WriteFileSizeL[0x%x], sz:%d"), this, aSize); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
932 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
933 |
CFatMountCB& mount = FatMount(); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
934 |
TFatDirEntry dirEntry; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
935 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
936 |
mount.ReadDirEntryL(iFileDosEntryPos, dirEntry); //-- read this file's dir. entry |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
937 |
dirEntry.SetSize(aSize); //-- set new size |
41
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
938 |
|
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
939 |
// As we're updating the directory entry anyway, we might as well update the attributes & time |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
940 |
// if these have been modified to save having to update them later... |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
941 |
if (FileAttModified()) |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
942 |
{ |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
943 |
dirEntry.SetAttributes(Att() & KEntryAttMaskSupported); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
944 |
IndicateFileAttModified(EFalse); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
945 |
IndicateFileTimeModified(ETrue); //-- this mirrors the behaviour of CFatFileCB::~CFatFileCB() |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
946 |
} |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
947 |
if (FileTimeModified()) |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
948 |
{ |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
949 |
dirEntry.SetTime(iModified, FatMount().TimeOffset()); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
950 |
IndicateFileTimeModified(EFalse); |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
951 |
} |
0ffb4e86fcc9
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
952 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
953 |
mount.WriteDirEntryL(iFileDosEntryPos, dirEntry);//-- write the entry back |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
954 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
955 |
IndicateFileSizeModified(EFalse); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
956 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
957 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
958 |
|
2
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
959 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
960 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
diff
changeset
|
961 |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
962 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
2
diff
changeset
|
963 |