author | hgs |
Wed, 12 May 2010 10:34:10 +0100 | |
changeset 133 | 2a0ada0a1bf8 |
parent 90 | 947f0dc9f7a8 |
child 109 | b3a1d9898418 |
child 175 | 5af6c74cd793 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
16 |
#include <f32file.h> |
|
17 |
#include <e32test.h> |
|
18 |
#include <e32math.h> |
|
19 |
#include <e32hal.h> |
|
20 |
#include "t_server.h" |
|
21 |
#include "t_chlffs.h" |
|
22 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include "f32_test_utils.h" |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
using namespace F32_Test_Utils; |
0 | 25 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
RTest test(_L("B_GEN")); |
0 | 27 |
// |
28 |
// File test - general test of local filing system routines |
|
29 |
// (finishes with formating current device). |
|
30 |
// Modified from BB's epoc test code |
|
31 |
||
32 |
#define MINIMUM_DATE (315532800L) |
|
33 |
#define DateTests 10 |
|
34 |
||
35 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
TBuf<0x100> gNameBuf; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
TBuf<0x100> gNameOut; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
RFile gFile; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
RFile gFileErr; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
RFile gFile2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
RDir gDir; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
RFormat gFormat; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
TFileName fBuf; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
TInt gDriveNum = -1; |
0 | 45 |
|
46 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
static TBuf8<0x4000> gDataBuf; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
static TEntry gFileEntry; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
static TVolumeInfo volInfo; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
static TFileName pathBuf; |
0 | 51 |
|
52 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
static void doError(const TDesC &aMess, TInt anErr, TInt line) |
0 | 57 |
{ |
58 |
test.Printf(_L("%S failed at line %d. Error %d\n"),&aMess, line, anErr); |
|
59 |
test(0); |
|
60 |
} |
|
61 |
#define Error(aMess, anErr) doError(aMess, anErr, __LINE__) |
|
62 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
static void doError2(const TDesC &aMess, TInt anErr, TInt line, TInt callLine) |
0 | 64 |
{ |
65 |
test.Printf(_L("%S failed at line %d. Error %d. Called from line %d\n"),&aMess, line, anErr, callLine); \ |
|
66 |
test(0); |
|
67 |
} |
|
68 |
#define Error2(aMess, anErr, line) doError2(aMess, anErr, __LINE__, line) |
|
69 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
static void testWrite(const TDesC& aName,TInt aLen,TInt32 aSize,TBool aShouldChange) |
0 | 71 |
// |
72 |
// Write to a file |
|
73 |
// |
|
74 |
{ |
|
75 |
||
76 |
TTime saveTime; |
|
77 |
TInt c; |
|
78 |
test.Printf(_L("Write %u bytes %u\n"),aLen,aShouldChange); |
|
79 |
if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone) |
|
80 |
Error(_L("File info 600"),c); |
|
81 |
saveTime=gFileEntry.iModified; |
|
82 |
User::After(3000000L); // 30 tenths of a sec = 30 00000 micro seconds |
|
83 |
if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone) |
|
84 |
Error(_L("Open 50"),c); |
|
85 |
if ((c=gFile.Write(gDataBuf,aLen))!=KErrNone) |
|
86 |
Error(_L("Write"),c); |
|
87 |
gFile.Close(); |
|
88 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
89 |
Error(_L("File info 601"),c); |
|
90 |
if ((saveTime!=gFileEntry.iModified)!=aShouldChange) |
|
91 |
Error(_L("Change flag check 6"),0); |
|
92 |
if (gFileEntry.iSize!=aSize) |
|
93 |
Error(_L("Size check 602"),0); |
|
94 |
} |
|
95 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
static void testSetEof(const TDesC& aName,TUint32 aPos,TBool aShouldChange) |
0 | 97 |
// |
98 |
// Set the end of a file |
|
99 |
// |
|
100 |
{ |
|
101 |
||
102 |
TTime saveTime; |
|
103 |
TInt c; |
|
104 |
test.Printf(_L("Set EOF to %u %u\n"),aPos,aShouldChange); |
|
105 |
if ((c=TheFs.Entry(aName,gFileEntry))!=KErrNone) |
|
106 |
Error(_L("File info 500"),c); |
|
107 |
saveTime=gFileEntry.iModified; |
|
108 |
User::After(3000000L); |
|
109 |
if ((c=gFile.Open(TheFs,aName,EFileWrite))!=KErrNone) |
|
110 |
Error(_L("Open 50"),c); |
|
111 |
if ((c=gFile.SetSize(aPos))!=KErrNone) |
|
112 |
Error(_L("Set EOF 50"),c); |
|
113 |
gFile.Close(); |
|
114 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
115 |
Error(_L("File info 501"),c); |
|
116 |
if ((saveTime!=gFileEntry.iModified)!=aShouldChange) |
|
117 |
Error(_L("Change flag check 5"),0); |
|
118 |
} |
|
119 |
||
120 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
static void testDir(const TDesC& aDirName) |
0 | 122 |
// |
123 |
// Create a directory |
|
124 |
// |
|
125 |
{ |
|
126 |
||
127 |
TInt c; |
|
128 |
test.Printf(_L("Test dir %S\n"),&aDirName); |
|
129 |
c=gDir.Open(TheFs,aDirName,KEntryAttNormal); |
|
130 |
||
131 |
if (c!=KErrNone) |
|
132 |
Error(_L("Directory open 1000"),c); |
|
133 |
||
134 |
gDir.Close(); |
|
135 |
||
136 |
TChar drive(aDirName[0]); |
|
137 |
TInt driveNo; |
|
138 |
c=RFs::CharToDrive(drive,driveNo); |
|
139 |
test(c==KErrNone); |
|
140 |
if ((c=TheFs.Volume(volInfo,driveNo))!=KErrNone) |
|
141 |
Error(_L("Device info 1000"),c); |
|
142 |
} |
|
143 |
||
144 |
||
145 |
/* |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
static void testNodeInfo(const TDesC& aName,TInt type,TInt anErr) |
0 | 147 |
// |
148 |
// Test p_ninfo. |
|
149 |
// |
|
150 |
{ |
|
151 |
||
152 |
// TInt c; |
|
153 |
test.Printf(_L("Node info: %S\n"),&aName); |
|
154 |
// if ((c=p_ninfo(aDirName,&nInfo))!=anErr) |
|
155 |
// Error(_L("Device info"),c); |
|
156 |
if (anErr==0) |
|
157 |
{ |
|
158 |
// if (!(nInfo.version==2 || nInfo.version==3)) |
|
159 |
// Error(_L("Node version check"),0); |
|
160 |
// if (nInfo.type!=type) |
|
161 |
// Error(_L("Node type check"),0); |
|
162 |
} |
|
163 |
} |
|
164 |
*/ |
|
165 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
static void testDeviceInfo(const TDesC& aDeviceName,TInt anErr) |
0 | 167 |
// |
168 |
// Test p_dinfo. |
|
169 |
// |
|
170 |
{ |
|
171 |
||
172 |
TInt c; |
|
173 |
test.Printf(_L("Device info: %S\n"),&aDeviceName); |
|
174 |
TInt drive=KDefaultDrive; |
|
175 |
if (aDeviceName.Length()) |
|
176 |
{ |
|
177 |
c=RFs::CharToDrive(aDeviceName[0],drive); |
|
178 |
test(c==KErrNone); |
|
179 |
} |
|
180 |
if ((c=TheFs.Volume(volInfo,drive))!=anErr) |
|
181 |
Error(_L("Device info"),c); |
|
182 |
if (anErr==0) |
|
183 |
{ |
|
184 |
// if (!(volInfo.version==2 || volInfo.version==3)) ********* version is not a member of TVolumeInfo |
|
185 |
// Error(_L("Device version check"),0); |
|
186 |
if (volInfo.iFree>volInfo.iSize) |
|
187 |
Error(_L("Free greater than size check"),0); |
|
188 |
} |
|
189 |
} |
|
190 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
static void testFileInfo(const TDesC& aFileName,TInt anErr) |
0 | 192 |
// |
193 |
// Test entry info |
|
194 |
// |
|
195 |
{ |
|
196 |
||
197 |
TInt c; |
|
198 |
test.Printf(_L("File info: %S\n"),&aFileName); |
|
199 |
if ((c=TheFs.Entry(aFileName,gFileEntry))!=anErr) |
|
200 |
Error(_L("Get info 100"),c); |
|
201 |
if (anErr==0) |
|
202 |
{ |
|
203 |
if (aFileName.Length()>=2 && aFileName[0]=='Z' && aFileName[1]==':') |
|
204 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
if ((gFileEntry.iAtt&(KEntryAttReadOnly|EFileStream)) != (TUint32)(KEntryAttReadOnly|EFileStream) && gFileEntry.iAtt!=KEntryAttDir) |
0 | 206 |
Error(_L("Info status check Z:\\"),0); |
207 |
} |
|
208 |
else |
|
209 |
{ |
|
210 |
if (gFileEntry.iAtt&KEntryAttDir) |
|
211 |
return; // Found directory entry |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
if (gFileEntry.iAtt!=(TUint32)(EFileStream|KEntryAttArchive)) |
0 | 213 |
Error(_L("Info status check"),0); |
214 |
if (gFileEntry.iSize!=0L) |
|
215 |
Error(_L("Info size check"),0); |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
static void testRenameFromRoot(const TDesC& aRName,const TDesC& aDName) |
0 | 221 |
// |
222 |
// |
|
223 |
// |
|
224 |
{ |
|
225 |
||
226 |
TInt c; |
|
227 |
if ((c=TheFs.Rename(aRName,aDName))!=KErrNone) |
|
228 |
Error(_L("Rename 92"),c); |
|
229 |
if ((c=gFile.Open(TheFs,aDName,EFileStream))!=KErrNone) |
|
230 |
Error(_L("Open 92"),c); |
|
231 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
if ((c=TheFs.Delete(aRName))!=KErrNotFound) |
0 | 233 |
Error(_L("Delete 92"),c); |
234 |
} |
|
235 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
static void testRenameToRoot(const TDesC& pName,const TDesC& rName) |
0 | 237 |
// |
238 |
// |
|
239 |
// |
|
240 |
{ |
|
241 |
||
242 |
TInt c; |
|
243 |
if ((c=gFile.Replace(TheFs,pName,EFileStream))!=KErrNone) |
|
244 |
Error(_L("Create 91"),c); |
|
245 |
gFile.Close(); |
|
246 |
if ((c=TheFs.Rename(pName,rName))!=KErrNone) |
|
247 |
Error(_L("Rename 91"),c); |
|
248 |
if ((c=gFile.Open(TheFs,rName,EFileStream))!=KErrNone) |
|
249 |
Error(_L("Open 91"),c); |
|
250 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
if ((c=TheFs.Delete(pName))!=KErrNotFound) |
0 | 252 |
Error(_L("Delete 91"),c); |
253 |
} |
|
254 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
static void verifyTestPat1() |
0 | 256 |
// |
257 |
// |
|
258 |
// |
|
259 |
{ |
|
260 |
||
261 |
TInt i; |
|
262 |
TInt c; |
|
263 |
if ((c=gFile.Open(TheFs,_L("\\TESTPAT1.DAT"),EFileStream))!=KErrNone) |
|
264 |
Error(_L("Create testpat1"),c); |
|
265 |
gDataBuf.SetLength(0); |
|
266 |
if ((c=gFile.Read(gDataBuf,512))!=KErrNone || gDataBuf.Length()!=512) |
|
267 |
Error(_L("Read 90"),c); |
|
268 |
gFile.Close(); |
|
269 |
for (i=0;i<512;i++) |
|
270 |
{ |
|
271 |
if (gDataBuf[i]!='X') |
|
272 |
Error(_L("Data check"),0); |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
void TestINC103141() // PDEF104017 |
|
277 |
{ |
|
278 |
test.Printf(_L("Test INC103141\n")); |
|
279 |
_LIT(KDir1, "\\INC103141\\TEST"); |
|
280 |
_LIT(KDir2, "\\INC103141\\test"); |
|
281 |
TBuf<32> dirname; |
|
282 |
dirname.Copy(KDir1); |
|
283 |
dirname.Append(KPathDelimiter); |
|
284 |
MakeDir(dirname); |
|
285 |
TInt err = TheFs.Rename(KDir1, KDir2); |
|
286 |
test(err == KErrNone); |
|
287 |
err = TheFs.RmDir(dirname); |
|
288 |
test(err == KErrNone); |
|
289 |
err = TheFs.RmDir(KDir1); |
|
290 |
test(err == KErrNone); |
|
291 |
} |
|
292 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
static void testRename() |
0 | 294 |
// |
295 |
// Test TheFs.Rename function. |
|
296 |
// |
|
297 |
{ |
|
298 |
||
299 |
TBuf<32> xName; |
|
300 |
TInt i; |
|
301 |
TInt c; |
|
302 |
test.Printf(_L("Test TheFs.Rename\n")); |
|
303 |
||
304 |
test.Printf(_L("Test rename into root\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
if ((c=gFile.Replace(TheFs,_L("\\TESTPAT1.DAT"),EFileStream|EFileWrite))!=KErrNone) |
0 | 306 |
Error(_L("Create testpat1"),c); |
307 |
gDataBuf.Fill('X',512); |
|
308 |
if ((c=gFile.Write(gDataBuf,512))!=KErrNone) |
|
309 |
Error(_L("Write 90"),c); |
|
310 |
gFile.Close(); |
|
311 |
if ((c=TheFs.MkDir(_L("\\DIRX\\")))!=KErrNone) |
|
312 |
Error(_L("Make dir 90"),c); |
|
313 |
for (i=0;i<32;i++) |
|
314 |
{ |
|
315 |
xName.Format(_L("\\DIRX\\FILEX%u"),i); |
|
316 |
TPtrC rootName(xName.Ptr()+5,xName.Length()-5); |
|
317 |
testRenameToRoot(xName,rootName); |
|
318 |
verifyTestPat1(); |
|
319 |
} |
|
320 |
||
321 |
test.Printf(_L("Test rename from root\n")); |
|
322 |
for (i=0;i<32;i++) |
|
323 |
{ |
|
324 |
xName.Format(_L("\\DIRX\\FILEX%u"),i); |
|
325 |
TPtrC rootName(xName.Ptr()+5,xName.Length()-5); |
|
326 |
testRenameFromRoot(rootName,xName); |
|
327 |
verifyTestPat1(); |
|
328 |
} |
|
329 |
for (i=0;i<32;i++) |
|
330 |
{ |
|
331 |
xName.Format(_L("\\DIRX\\FILEX%u"),i); |
|
332 |
if ((c=TheFs.Delete(xName))!=KErrNone) |
|
333 |
Error(_L("Delete 93"),c); |
|
334 |
} |
|
335 |
if ((c=TheFs.RmDir(_L("\\DIRX\\")))!=KErrNone) |
|
336 |
Error(_L("Delete DIRX"),c); |
|
337 |
verifyTestPat1(); |
|
338 |
if ((c=TheFs.Delete(_L("\\TESTPAT1.DAT")))!=KErrNone) |
|
339 |
Error(_L("Delete 80"),c); |
|
340 |
||
341 |
test.Printf(_L("Test rename with wild cards\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
if ((c=TheFs.Rename(_L("*.*"),_L("FRED")))!=KErrBadName) |
0 | 343 |
Error(_L("Rename 100"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
if ((c=TheFs.Rename(_L("?"),_L("FRED")))!=KErrBadName) |
0 | 345 |
Error(_L("Rename 101"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
if ((c=TheFs.Rename(_L(""),_L("FRED")))!=KErrBadName) // KErrBadName) |
0 | 347 |
Error(_L("Rename 101.11"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
if ((c=TheFs.Rename(_L("."),_L("FRED")))!=KErrBadName) |
0 | 349 |
Error(_L("Rename 101.12"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
if ((c=TheFs.Rename(_L("NOEXIST"),_L("*")))!=KErrBadName) |
0 | 351 |
Error(_L("Rename 101.1"),c); |
352 |
if ((c=gFile.Create(TheFs,_L("FILE1"),EFileStream))!=KErrNone) |
|
353 |
Error(_L("Create 101.2"),c); |
|
354 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
if ((c=TheFs.Rename(_L("FILE1"),_L("AAA?")))!=KErrBadName) |
0 | 356 |
Error(_L("Rename 101.3"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
if ((c=TheFs.Rename(_L("FILE1"),_L("")))!=KErrBadName) // KErrBadName) |
0 | 358 |
Error(_L("Rename 101.41"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
if ((c=TheFs.Rename(_L(""),_L("")))!=KErrBadName) // KErrBadName) |
0 | 360 |
Error(_L("Rename 101.42"),c); |
361 |
if ((c=TheFs.Delete(_L("FILE1")))!=KErrNone) |
|
362 |
Error(_L("Delete 101.5"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
363 |
if ((c=TheFs.Rename(_L("\\"),_L("FRED")))!=KErrBadName) |
0 | 364 |
Error(_L("Rename 101.6"),c); |
365 |
||
366 |
test.Printf(_L("Test rename of directories\n")); |
|
367 |
if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone) |
|
368 |
Error(_L("Make dir 102"),c); |
|
369 |
if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\A2345678.123")))!=KErrNone) |
|
370 |
Error(_L("Rename 103.1"),c); |
|
371 |
if ((c=TheFs.Rename(_L("\\A2345678.123"),_L("\\DIR2")))!=KErrNone) |
|
372 |
Error(_L("Rename 103.2"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
if ((c=TheFs.Rename(_L("\\DIR2"),_L("\\A234567.1234")))!=KErrNone) // ****** KErrBadName) Long filenames are supported |
0 | 374 |
Error(_L("Rename 103.3"),c); |
375 |
if ((c=TheFs.Rename(_L("\\A234567.1234"),_L("\\DIR2")))!=KErrNone) |
|
376 |
Error(_L("Rename 103.3"),c); |
|
377 |
if ((c=TheFs.MkDir(_L("\\DIR1\\")))!=KErrNone) |
|
378 |
Error(_L("Make dir 104"),c); |
|
379 |
||
380 |
test.Printf(_L("Test rename of open files\n")); |
|
381 |
if ((c=gFile.Create(TheFs,_L("\\DIR1\\FILE1"),EFileStreamText))!=KErrNone) |
|
382 |
Error(_L("Create 105"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
383 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrInUse) |
0 | 384 |
Error(_L("Rename 106"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=KErrInUse) |
0 | 386 |
Error(_L("Rename 106.1"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=KErrNotFound) |
0 | 388 |
Error(_L("Create 105"),c); |
389 |
gFile.Close(); |
|
390 |
||
391 |
test.Printf(_L("Test rename to same name\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=KErrAlreadyExists) |
0 | 393 |
Error(_L("Rename 105.1"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
394 |
if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR1")))!=KErrNone) // !=KErrAlreadyExists) |
0 | 395 |
Error(_L("Rename 105.2"),c); |
396 |
||
397 |
test.Printf(_L("Test rename of read-only files\n")); // IS ALLOWED // |
|
398 |
if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),KEntryAttReadOnly,0))!=KErrNone) |
|
399 |
Error(_L("Att 106"),c); |
|
400 |
if ((c=TheFs.Entry(_L("\\DIR1\\FILE1"),gFileEntry))!=KErrNone) |
|
401 |
Error(_L("File info 106.1"),c); |
|
402 |
test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
403 |
if (gFileEntry.iAtt!=(TUint32)(KEntryAttReadOnly|EFileStream|KEntryAttArchive)) |
0 | 404 |
Error(_L("Status check 106.2"),0); |
405 |
if ((c=TheFs.Entry(_L("\\DIR1"),gFileEntry))!=KErrNone) |
|
406 |
Error(_L("File info 106.3"),c); |
|
407 |
test.Printf(_L("STATUS=%04x\n"),gFileEntry.iAtt); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
408 |
if (gFileEntry.iAtt!=(TUint32)(EFileStream|KEntryAttDir)) |
0 | 409 |
Error(_L("Status check 106.4"),0); |
410 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
411 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE1")))!=KErrNone) // !=KErrAlreadyExists) |
0 | 412 |
Error(_L("Rename 107"),c); |
413 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR1\\FILE2")))!=KErrNone) |
|
414 |
Error(_L("Rename 108"),c); |
|
415 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE2"),_L("\\DIR2\\FILE2")))!=KErrNone) |
|
416 |
Error(_L("Rename 109"),c); |
|
417 |
if ((c=gFile2.Open(TheFs,_L("\\DIR2\\FILE2"),EFileStream))!=KErrNone) |
|
418 |
Error(_L("Create 110"),c); |
|
419 |
gFile2.Close(); |
|
420 |
if ((c=TheFs.Rename(_L("\\DIR2\\FILE2"),_L("\\DIR1\\FILE1")))!=KErrNone) |
|
421 |
Error(_L("Rename 110.1"),c); |
|
422 |
if ((c=TheFs.SetAtt(_L("\\DIR1\\FILE1"),0,KEntryAttReadOnly))!=KErrNone) |
|
423 |
Error(_L("Att 111"),c); |
|
424 |
||
425 |
test.Printf(_L("Test rename of files across directories\n")); |
|
426 |
if ((c=TheFs.Rename(_L("\\DIR1\\FILE1"),_L("\\DIR2\\FILE1")))!=KErrNone) |
|
427 |
Error(_L("Rename 112"),c); |
|
428 |
if ((c=gFile.Open(TheFs,_L("\\DIR2\\FILE1"),EFileStream))!=KErrNone) |
|
429 |
Error(_L("Exist 113"),c); |
|
430 |
gFile.Close(); |
|
431 |
||
432 |
test.Printf(_L("Test rename of directories across directories\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
433 |
if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\DIR2\\DIR1")))!=KErrNone) // ******** KErrAccessDenied) |
0 | 434 |
Error(_L("Rename 114"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
435 |
if ((c=TheFs.Rename(_L("\\DIR1"),_L("\\")))!=KErrBadName) |
0 | 436 |
Error(_L("Rename 114.1"),c); |
437 |
||
438 |
if ((c=TheFs.Delete(_L("\\DIR2\\FILE1")))!=KErrNone) |
|
439 |
Error(_L("Delete 115"),c); |
|
440 |
if ((c=TheFs.RmDir(_L("\\DIR2\\DIR1\\")))!=KErrNone) |
|
441 |
Error(_L("Delete 115"),c); |
|
442 |
if ((c=TheFs.RmDir(_L("\\DIR2\\")))!=KErrNone) |
|
443 |
Error(_L("Delete 115"),c); |
|
444 |
||
445 |
TestINC103141(); // PDEF104017 |
|
446 |
} |
|
447 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
448 |
static void testDelete() |
0 | 449 |
// |
450 |
// Test RFs::Delete function. |
|
451 |
// |
|
452 |
{ |
|
453 |
||
454 |
TInt c; |
|
455 |
test.Printf(_L("Test RFs::Delete\n")); |
|
456 |
test.Printf(_L("Test delete non-empty directories\n")); |
|
457 |
if ((c=TheFs.MkDir(_L("\\TESTDIR\\")))!=KErrNone) |
|
458 |
Error(_L("Make dir 500"),c); |
|
459 |
if ((c=gFile.Create(TheFs,_L("\\TESTDIR\\NAME.EXT"),EFileStream))!=KErrNone) |
|
460 |
Error(_L("Create"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
if ((c=TheFs.Delete(_L("\\TESTDIR\\")))!=KErrBadName) // ******* KErrAccessDenied) |
0 | 462 |
Error(_L("Delete 501"),c); |
463 |
||
464 |
test.Printf(_L("Test delete open file\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=KErrInUse) |
0 | 466 |
Error(_L("Delete 502"),c); |
467 |
gFile.Close(); |
|
468 |
if ((c=TheFs.Delete(_L("\\TESTDIR\\NAME.EXT")))!=KErrNone) |
|
469 |
Error(_L("Delete 503"),c); |
|
470 |
if ((c=TheFs.RmDir(_L("\\TESTDIR\\")))!=KErrNone) |
|
471 |
Error(_L("Delete 504"),c); |
|
472 |
} |
|
473 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
static void testUnique(TUint fileFormat) |
0 | 475 |
// |
476 |
// Test RFile::Temp |
|
477 |
// |
|
478 |
{ |
|
479 |
||
480 |
TInt pos; |
|
481 |
TInt c; |
|
482 |
test.Printf(_L("Test RFile::Temp\n")); |
|
483 |
gDataBuf.SetLength(1); |
|
484 |
if ((c=gFile.Temp(TheFs,_L(""),gNameBuf,fileFormat))!=KErrNone) |
|
485 |
Error(_L("Directory open 2000"),c); |
|
486 |
if ((c=gFile.Write(gDataBuf,0))!=KErrNone) |
|
487 |
Error(_L("Write 2000"),c); |
|
488 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
489 |
Error(_L("Write 2000"),c); |
|
490 |
pos=0L; |
|
491 |
if ((c=gFile.Seek(ESeekStart,pos))!=KErrNone) // !=E_FILE_INV) Temp file is random access |
|
492 |
Error(_L("Seek 2000"),c); |
|
493 |
gFile.Close(); |
|
494 |
if ((c=TheFs.Delete(gNameBuf))!=KErrNone) |
|
495 |
Error(_L("Delete"),c); |
|
496 |
} |
|
497 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
static void testFileName(const TDesC& aFileName,TInt res) |
0 | 499 |
// |
500 |
// |
|
501 |
// |
|
502 |
{ |
|
503 |
||
504 |
TInt c; |
|
505 |
if ((c=aFileName.Length())>20) |
|
506 |
test.Printf(_L("%u char name\n"),c); |
|
507 |
else |
|
508 |
test.Printf(_L("\"%S\"\n"),&aFileName); |
|
509 |
if ((c=gFile.Create(TheFs,aFileName,EFileStream))!=res) |
|
510 |
Error(_L("Create 200"),c); |
|
511 |
if (res==KErrNone) |
|
512 |
{ |
|
513 |
gFile.Close(); |
|
514 |
if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=KErrNone) |
|
515 |
Error(_L("Open 200"),c); |
|
516 |
gFile.Close(); |
|
517 |
if ((c=TheFs.Delete(aFileName))!=KErrNone) |
|
518 |
Error(_L("Delete 200"),c); |
|
519 |
} |
|
520 |
else |
|
521 |
{ |
|
522 |
if ((c=gFile.Open(TheFs,aFileName,EFileStream))!=res) // test eg *.* // |
|
523 |
Error(_L("Open 201"),c); |
|
524 |
if ((c=gFile.Replace(TheFs,aFileName,EFileStream))!=res) |
|
525 |
Error(_L("Replace 202"),c); |
|
526 |
} |
|
527 |
} |
|
528 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
static void testFileName(const TDesC8& aFileName,TInt res) |
0 | 530 |
// |
531 |
// Defined to cope with all the instances of testFileName(gDataBuf,...) |
|
532 |
// |
|
533 |
{ |
|
534 |
TPtrC gDataBuf16((TText*)aFileName.Ptr(),gDataBuf.Size()/sizeof(TText8)); |
|
535 |
testFileName(gDataBuf16,res); |
|
536 |
} |
|
537 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
538 |
static void testVolumeName(const TDesC& aVolumeName,TInt aResultExpected) |
0 | 539 |
// |
540 |
// |
|
541 |
// |
|
542 |
{ |
|
543 |
||
544 |
TInt result; |
|
545 |
test.Printf(_L("\"%S\"\n"),&aVolumeName); |
|
546 |
TInt drive=KDefaultDrive; |
|
547 |
if (aVolumeName.Length()>=2 && aVolumeName[0]=='Z' && aVolumeName[1]==':') |
|
548 |
{ |
|
549 |
drive=25; |
|
550 |
TPtr volName((TText*)&aVolumeName[2],(aVolumeName.Length()-2),(aVolumeName.Length()-2)); |
|
551 |
result=TheFs.SetVolumeLabel(volName,drive); |
|
552 |
} |
|
553 |
else |
|
554 |
result=TheFs.SetVolumeLabel(aVolumeName,drive); |
|
555 |
||
556 |
if (result==KErrGeneral) |
|
557 |
{ |
|
558 |
test.Printf(_L("KErrGeneral: Cannot set volume label on a substed drive!\n")); |
|
559 |
return; |
|
560 |
} |
|
561 |
if (result!=aResultExpected) |
|
562 |
Error(_L("Set volume name returned"),result); |
|
563 |
||
564 |
/* if (aResultExpected==FALSE) |
|
565 |
{ |
|
566 |
if ((result=TheFs.Volume(volInfo))!=KErrNone) |
|
567 |
Error(_L("Volume Info failed"),result); |
|
568 |
TPtrC vol(aVolumeName); |
|
569 |
if (vol!=volInfo.iName) |
|
570 |
Error(_L("Check volume name failed"),0); |
|
571 |
} |
|
572 |
*/ |
|
573 |
} |
|
574 |
||
575 |
#define testMakeDir(aDirName, res) TestMakeDirLine(aDirName, res, __LINE__) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
static void TestMakeDirLine(const TDesC& aDirName,TInt res, TInt line) |
0 | 577 |
// |
578 |
// |
|
579 |
// |
|
580 |
{ |
|
581 |
||
582 |
TInt c; |
|
583 |
TUint l; |
|
584 |
TFileName buf; |
|
585 |
if ((c=aDirName.Length())>20) |
|
586 |
test.Printf(_L("%u char name\n"),c); |
|
587 |
else |
|
588 |
test.Printf(_L("\"%S\"\n"),&aDirName); |
|
589 |
if ((c=TheFs.MkDirAll(aDirName))!=res) |
|
590 |
Error2(_L("Make directory 1"),c, line); |
|
591 |
if (res==FALSE) |
|
592 |
{ |
|
593 |
TParse parse; |
|
594 |
c=TheFs.Parse(aDirName,parse); |
|
595 |
test(c==KErrNone); |
|
596 |
buf=parse.Path(); |
|
597 |
buf.Append(_L("*")); |
|
598 |
if (buf.Length()<=64) |
|
599 |
{ |
|
600 |
test.Printf(_L("Open dir...\n")); |
|
601 |
if ((c=gDir.Open(TheFs,buf,KEntryAttMaskSupported))!=KErrNone) |
|
602 |
Error2(_L("Directory open 1"),c, line); |
|
603 |
gDataBuf[0]=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
604 |
if ((c=gDir.Read(gFileEntry))!=KErrEof) |
0 | 605 |
{ |
606 |
test.Printf(_L("buf=\"%S\"\n"),&gFileEntry.iName); |
|
607 |
Error2(_L("Directory read"),c, line); |
|
608 |
} |
|
609 |
gDir.Close(); |
|
610 |
} |
|
611 |
buf=aDirName; |
|
612 |
l=buf.Length(); |
|
613 |
FOREVER |
|
614 |
{ |
|
615 |
test.Printf(_L("Delete \"%S\"\n"),&buf); |
|
616 |
if ((c=TheFs.RmDir(buf))!=KErrNone) |
|
617 |
Error2(_L("Delete directory"),c, line); |
|
618 |
while (--l) |
|
619 |
{ |
|
620 |
if (buf[l]=='\\') |
|
621 |
{ |
|
622 |
buf.SetLength(l); |
|
623 |
if (buf.LocateReverse('\\')==0) |
|
624 |
return; |
|
625 |
break; |
|
626 |
} |
|
627 |
} |
|
628 |
if (l == 0) |
|
629 |
break; |
|
630 |
} |
|
631 |
} |
|
632 |
} |
|
633 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
634 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
635 |
static void TestMakeDirLine(const TDesC8& aDirName, TInt res, TInt line) |
0 | 636 |
// |
637 |
// Defined to cope with all the instances of testMakeDir(gDataBuf,...) |
|
638 |
// |
|
639 |
{ |
|
640 |
||
641 |
TPtrC gDataBuf16((TText*)aDirName.Ptr(),gDataBuf.Size()/sizeof(TText8)); |
|
642 |
// Not sizeof(TText16) since gDataBuf is a TBuf*! |
|
643 |
TestMakeDirLine(gDataBuf16, res, line); |
|
644 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
|
0 | 646 |
|
647 |
#ifdef TEST_MEDIA |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
648 |
static void testMedia(const TDesC& instructions,TInt anErr) |
0 | 649 |
// |
650 |
// |
|
651 |
// |
|
652 |
{ |
|
653 |
||
654 |
TBuf<0x40> errBuf; |
|
655 |
TInt openErr; |
|
656 |
TInt c; |
|
657 |
// p_errs(&errBuf[0],anErr); |
|
658 |
pathBuf=fBuf; |
|
659 |
pathBuf.SetLength(7); |
|
660 |
test.Printf(_L("Test %S\n"),&errBuf); |
|
661 |
test.Printf(_L("%S %S\n"),&instructions,&pathBuf); |
|
662 |
p_getch(); |
|
663 |
openErr=anErr; |
|
664 |
if (anErr==WriteProtectErr) |
|
665 |
openErr=0; |
|
666 |
if ((c=gFile.Open(TheFs,fBuf,P_FDIR))!=openErr) |
|
667 |
Error(_L("Directory open 100"),c); |
|
668 |
if (openErr==KErrNone) |
|
669 |
{ |
|
670 |
if (c=gFile.Close()) |
|
671 |
Error(_L("Close 100"),c); |
|
672 |
} |
|
673 |
gNameBuf.SetLength(0); |
|
674 |
if ((c=gFile.Open(TheFs,gNameBuf,P_FUNIQUE|EFileStream))!=anErr) |
|
675 |
Error(_L("Create unique 100"),c); |
|
676 |
if (anErr==0) |
|
677 |
{ |
|
678 |
if (c=gFile.Close()) |
|
679 |
Error(_L("Close 100"),c); |
|
680 |
} |
|
681 |
} |
|
682 |
#endif |
|
683 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
684 |
void CallTestsL() |
0 | 685 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
686 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
687 |
//-- set up console output |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
688 |
F32_Test_Utils::SetConsole(test.Console()); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
689 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
690 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
691 |
test(nRes==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
692 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
693 |
PrintDrvInfo(TheFs, gDriveNum); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
694 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
695 |
//-- quick format the drive, if it isn't the emulator's C: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
696 |
if(!Is_Win32(TheFs, gDriveNum)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
697 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
nRes = FormatDrive(TheFs, gDriveNum, ETrue); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
699 |
test(nRes==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
700 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
701 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
702 |
//----------------------------------- |
0 | 703 |
TInt c; |
704 |
TInt i,count; |
|
705 |
TInt pos; |
|
706 |
TInt64 seed; |
|
707 |
TInt attrib,mask; |
|
708 |
TTime saveTime; |
|
709 |
TInt testSize; |
|
710 |
||
711 |
CreateTestDirectory(_L("\\F32-TST\\BGEN\\")); |
|
712 |
// if (p_date()<MINIMUM_DATE) |
|
713 |
// p_sdate(MINIMUM_DATE); |
|
714 |
||
715 |
seed=(TInt64)1732; |
|
716 |
fBuf=gSessionPath; |
|
717 |
pathBuf=fBuf; |
|
718 |
pathBuf.Append('*'); |
|
719 |
testDir(pathBuf); |
|
720 |
// testDir(_L("Z:")); // Session Path gets added -> KErrPathNotFound |
|
721 |
// testDir(_L("Z:*")); // Session Path gets added -> KErrPathNotFound |
|
722 |
// testDir(_L("Z:*.*")); // Session Path gets added -> KErrPathNotFound |
|
723 |
testDir(_L("Z:\\")); |
|
724 |
testDir(_L("Z:\\*")); |
|
725 |
testDir(_L("Z:\\*.*")); |
|
726 |
||
727 |
test.Printf(_L("Test names containing '\\'\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
728 |
if ((c=gFile.Create(TheFs,_L("Q\\ZZZ"),EFileWrite))!=KErrBadName) |
0 | 729 |
Error(_L("Create 1"),c); |
730 |
||
731 |
test.Printf(_L("Test create in non-exist directory\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
if ((c=gFile.Create(TheFs,_L("\\Q1DDX\\ZZZ"),EFileWrite))!=KErrPathNotFound) |
0 | 733 |
Error(_L("Create 2"),c); |
734 |
||
735 |
test.Printf(_L("Test filenames starting with '.'\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
if ((c=gFile.Create(TheFs,_L("\\.ZZZ"),EFileWrite))!=KErrNone) // ****** KErrBadName) |
0 | 737 |
Error(_L("Create 3"),c); |
738 |
gFile.Close(); |
|
739 |
if ((c=TheFs.Delete(_L("\\.ZZZ")))!=KErrNone) |
|
740 |
Error(_L("Delete 3"),c); |
|
741 |
||
742 |
test.Printf(_L("Test filenames starting with 05/E5\n")); |
|
743 |
gNameBuf.SetLength(5); |
|
744 |
gNameBuf[0]=0xE5; |
|
745 |
gNameBuf[1]='X'; |
|
746 |
gNameBuf[2]='X'; |
|
747 |
gNameBuf[3]='X'; |
|
748 |
gNameBuf[4]=0x00; |
|
749 |
gNameBuf.SetLength(4); |
|
750 |
if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone) |
|
751 |
Error(_L("Replace 4"),c); |
|
752 |
gFile.Close(); |
|
753 |
if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone) |
|
754 |
Error(_L("Open 4"),c); |
|
755 |
gFile.Close(); |
|
756 |
||
757 |
// *************** Silly filename stuff rightly disallowed by NT |
|
758 |
// gNameBuf.SetLength(5); |
|
759 |
// gNameBuf[0]=0x05; |
|
760 |
// gNameBuf[1]='Y'; |
|
761 |
// gNameBuf[2]='Y'; |
|
762 |
// gNameBuf[3]='Y'; |
|
763 |
// gNameBuf[4]=0x00; // Zero terminator gets lost by VFAT |
|
764 |
// if ((c=gFile.Replace(TheFs,gNameBuf,EFileWrite))!=KErrNone) |
|
765 |
// Error(_L("Create 5"),c); |
|
766 |
// gFile.Close(); |
|
767 |
// gNameBuf[0]=0xE5; |
|
768 |
// if ((c=gFile.Open(TheFs,gNameBuf,EFileRead))!=KErrNone) |
|
769 |
// Error(_L("Open 5"),c); |
|
770 |
// gFile.Close(); |
|
771 |
// |
|
772 |
||
773 |
// |
|
774 |
//#ifdef TEST_MEDIA |
|
775 |
// if (fBuf[5]!='B') |
|
776 |
// goto skipMediaTest; |
|
777 |
// testMedia(_L("OPEN DOOR ON"),NotReadyErr); |
|
778 |
// testMedia(_L("INSERT CORRUPT RAM PACK (WRITE ENABLED) INTO"),CorruptMediaErr); |
|
779 |
// testMedia(_L("INSERT CORRUPT RAM PACK (WRITE PROTECTED) INTO"),CorruptMediaErr); |
|
780 |
// testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE ENABLED) INTO"),CorruptMediaErr); |
|
781 |
// testMedia(_L("INSERT CORRUPT FLASH PACK (WRITE PROTECTED) INTO"),CorruptMediaErr); |
|
782 |
//#ifdef FULL_TEST |
|
783 |
// testMedia(_L("INSERT UNKNOWN MEDIA INTO"),UnknownErr); |
|
784 |
//#endif |
|
785 |
// testMedia(_L("INSERT GOOD RAM PACK (WRITE PROTECTED) INTO"),WriteProtectErr); |
|
786 |
// if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr) |
|
787 |
// Error(_L("Format RAM write protect"),c); |
|
788 |
// testMedia(_L("INSERT GOOD FLASH PACK (WRITE PROTECTED) INTO"),WriteProtectErr); |
|
789 |
// if ((c=gFile.Open(TheFs,fBuf,P_FFORMAT))!=WriteProtectErr) |
|
790 |
// Error(_L("Format FLASH write protect"),c); |
|
791 |
// testMedia(_L("INSERT GOOD PACK (WRITE ENABLED) INTO"),0); |
|
792 |
// |
|
793 |
//skipMediaTest: |
|
794 |
//#endif // TEST_MEDIA // |
|
795 |
// |
|
796 |
||
797 |
// Test update is assumed for unique // |
|
798 |
||
799 |
testUnique(EFileStream); |
|
800 |
testUnique(EFileStreamText); |
|
801 |
testDelete(); |
|
802 |
testRename(); |
|
803 |
test.Printf(_L("Test get file info\n")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
804 |
// testFileInfo(_L("*.*"),KErrBadName); ********** Allowed (?) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
testFileInfo(_L(""),KErrNone); // KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
806 |
testFileInfo(_L("\\"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
807 |
testFileInfo(_L("."),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
808 |
testFileInfo(_L(".."),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
testFileInfo(_L("a.1234"),KErrNotFound); // ********* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
810 |
testFileInfo(_L("a23456789"),KErrNotFound); // ********* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
testFileInfo(_L(".a"),KErrNotFound); // ********** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
812 |
testFileInfo(_L("?"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
813 |
testFileInfo(_L("NOEXIST"),KErrNotFound); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
814 |
testFileInfo(_L("\\NODIR\\NAME"),KErrPathNotFound); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
815 |
testFileInfo(_L("L:\\NAME"),KErrNotReady); |
0 | 816 |
gNameBuf.SetLength(0); |
817 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) |
|
818 |
Error(_L("Open 1.1"),c); |
|
819 |
testFileInfo(gNameOut,FALSE); // Not locked // |
|
820 |
gFile.Close(); |
|
821 |
testFileInfo(gNameOut,FALSE); |
|
822 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
823 |
Error(_L("Delete"),c); |
|
824 |
||
825 |
test.Printf(_L("Test get device info\n")); |
|
826 |
testDeviceInfo(_L(""),FALSE); // NULL is current device // |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
827 |
testDeviceInfo(_L("L:"),KErrNotReady); |
0 | 828 |
testDeviceInfo(_L("Z:"),FALSE); |
829 |
testDeviceInfo(fBuf,FALSE); |
|
830 |
||
831 |
||
832 |
// test.Printf(_L("Test get node info\n")); |
|
833 |
// testNodeInfo(_L("LOC::"),P_FSYSTYPE_HIER,FALSE); |
|
834 |
// testNodeInfo(_L("Z:"),P_FSYSTYPE_FLAT,FALSE); |
|
835 |
// testNodeInfo(_L("LOC:"),P_FSYSTYPE_HIER,FALSE); |
|
836 |
// testNodeInfo(_L("LOC"),P_FSYSTYPE_HIER,FALSE); |
|
837 |
// testNodeInfo(_L("*"),P_FSYSTYPE_HIER,FALSE); |
|
838 |
// testNodeInfo(_L(""),P_FSYSTYPE_HIER,FALSE); |
|
839 |
// testNodeInfo(_L("?"),P_FSYSTYPE_HIER,FALSE); |
|
840 |
// testNodeInfo(_L("FRED"),P_FSYSTYPE_HIER,FALSE); |
|
841 |
// testNodeInfo(_L("FRED::"),P_FSYSTYPE_HIER,FALSE); |
|
842 |
// testNodeInfo(_L("....."),P_FSYSTYPE_HIER,FALSE); |
|
843 |
// testNodeInfo(_L("LOC::zzzzzzzzzzzzzzzzzzzzzzzzz"),P_FSYSTYPE_HIER,FALSE); |
|
844 |
// testNodeInfo(_L("LOC::\\"),P_FSYSTYPE_HIER,FALSE); |
|
845 |
// testNodeInfo(_L("XXX::"),0,E_GEN_FSYS); |
|
846 |
// testNodeInfo(_L("REM::"),0,E_GEN_FSYS); |
|
847 |
// testNodeInfo(_L("...::"),0,E_GEN_FSYS); |
|
848 |
||
849 |
// testFileInfo(_L("Z:SYS$WSRV.IMG"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
// testFileInfo(_L("Z:\\SYS$WSRV.IMG"),KErrBadName); // \ not allowed - no path // |
0 | 851 |
// testFileInfo(_L("Z:*"),FALSE); // Z: allows *'s ! // |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
852 |
// testFileInfo(_L("Z:SYS$WSRV."),KErrNotFound); |
0 | 853 |
// testFileInfo(_L("XXX::"),NoFileSystemErr); |
854 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
855 |
testFileInfo(_L("Z:\\Sys\\Bin\\ESHELL.EXE"),FALSE); // we now have paths // |
|
856 |
else |
|
857 |
testFileInfo(_L("Z:\\System\\Bin\\ESHELL.EXE"),FALSE); // we now have paths // |
|
858 |
// testFileInfo(_L("Z:*"),KErrPathNotFound); // session path gets inserted ,FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
859 |
// testFileInfo(_L("Z:SYS$WSRV."),KErrNotFound); |
0 | 860 |
// testFileInfo(_L("H:"),KErrBadName); // ************** NoFileSystemErr); |
861 |
||
862 |
test.Printf(_L("Test weird filenames\n")); |
|
863 |
// Test SPACES // |
|
864 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
testFileName(_L("A B"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
866 |
testFileName(_L(" AB"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
testFileName(_L(" AB "),KErrNone); // ******* KErrBadName); |
0 | 868 |
testFileName(_L(" AB"),KErrNone); |
869 |
testFileName(_L(" AB . cdef"),KErrNone); |
|
870 |
testFileName(_L(" AB . cdef "),KErrNone); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
871 |
testFileName(_L("A2345678 "),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
872 |
testFileName(_L("A2345678.XY "),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
873 |
testFileName(_L("A2345678.XYZ "),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
testFileName(_L("A2345678 XYZ"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
testFileName(_L(" "),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
876 |
testFileName(_L("\\A B\\NAME"),KErrPathNotFound); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
877 |
testFileName(_L("\\ \\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
testFileName(_L("\\asdf\\qer\\ \\asdf\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
879 |
testFileName(_L(" "),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
testFileName(_L("C:\\asdf\\ "),KErrBadName); |
0 | 881 |
// Test short names // |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
testFileName(_L(""),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
883 |
testFileName(_L("\\"),KErrBadName); |
0 | 884 |
testFileName(_L("1"),FALSE); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
testFileName(_L(".1"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
testFileName(_L(".1"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
testFileName(_L("\\.1"),KErrNone); // ******* KErrBadName); |
0 | 888 |
testFileName(_L("1.1"),FALSE); |
889 |
// Test long names // |
|
890 |
testFileName(_L("12345678.123"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
testFileName(_L("123456789.123"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
testFileName(_L("12345678.1234"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
testFileName(_L("1.1234"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
894 |
testFileName(_L("123456789"),KErrNone); // ******* KErrBadName); |
0 | 895 |
gDataBuf.SetLength(256); |
896 |
gDataBuf.Fill('A',255); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
897 |
testFileName(gDataBuf,KErrBadName); |
0 | 898 |
gDataBuf.SetLength(257); |
899 |
gDataBuf.Fill('B',256); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
900 |
testFileName(gDataBuf,KErrBadName); |
0 | 901 |
gDataBuf.SetLength(258); |
902 |
gDataBuf.Fill('C',257); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
testFileName(gDataBuf,KErrBadName); |
0 | 904 |
gDataBuf.SetLength(4096); |
905 |
gDataBuf.Fill('D',4095); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
906 |
testFileName(gDataBuf,KErrBadName); |
0 | 907 |
// Test DOTS // |
908 |
testFileName(_L("A.X"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
testFileName(_L("A..X"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
910 |
testFileName(_L("A.........X"),KErrNone); // ******* KErrBadName); |
0 | 911 |
testFileName(_L("A."),FALSE); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
912 |
testFileName(_L(".X"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
913 |
testFileName(_L("."),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
914 |
testFileName(_L(".."),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
915 |
// testFileName(_L("..."),KErrNone); // KErrBadName); // !!! ********* NT error KErrAccessDenied (?) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
916 |
testFileName(_L("\\a.x\\NAME"),KErrPathNotFound); // KErrPathNotFound == KErrPathNotFound |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
917 |
testFileName(_L("\\a..x\\NAME"),KErrPathNotFound); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
918 |
testFileName(_L("\\.\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
919 |
testFileName(_L("\\..\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
// testFileName(_L("\\...\\NAME"),KErrPathNotFound); // ******** KErrBadName); // !! NT treats ... as .. ?? |
0 | 921 |
// Test WILD CARDS // |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
testFileName(_L("*.*"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
testFileName(_L("*"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
924 |
testFileName(_L("\\*"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
925 |
testFileName(_L("?"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
926 |
testFileName(_L("\\?"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
927 |
testFileName(_L("\\A?B\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
928 |
testFileName(_L("\\A*B\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
929 |
testFileName(_L("\\*\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
testFileName(_L("\\********.***\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
testFileName(_L("A?X"),KErrBadName); |
0 | 932 |
|
933 |
test.Printf(_L("Test set volume name\n")); |
|
934 |
// New behaviour: SetVolumeName accepts any string < 12 chars |
|
935 |
// No modifications are made on the string. |
|
936 |
#if defined(__WINS__) |
|
937 |
TInt ret=TheFs.SetVolumeLabel(_L("TEST"),KDefaultDrive); |
|
938 |
if(ret==KErrNotSupported||ret==KErrAccessDenied) |
|
939 |
{ |
|
940 |
test.Printf(_L("Error: Cannot set volume label on substed drive\n")); |
|
941 |
//test.Getch(); |
|
942 |
} |
|
943 |
else |
|
944 |
#endif |
|
945 |
{ |
|
946 |
testVolumeName(_L("TESTNAME.VOL"),KErrBadName); // 12 chars - too long for volume label |
|
947 |
testVolumeName(_L("TESTNAME"),FALSE); // OK for 8 bit - too long for UNICODE |
|
948 |
testVolumeName(_L("PQRSTUVWXYZ"),FALSE); // just uses the first 5 characters |
|
949 |
testVolumeName(_L("ABCDE"),FALSE); |
|
950 |
testVolumeName(_L("FGHIJK"),FALSE); |
|
951 |
testVolumeName(_L(""),FALSE); |
|
952 |
testVolumeName(_L(""),FALSE); |
|
953 |
testVolumeName(_L("\\"),FALSE); |
|
954 |
gNameBuf.SetLength(0); |
|
955 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) |
|
956 |
Error(_L("Open 60"),c); |
|
957 |
testVolumeName(_L("TEST_NAME"),FALSE); // Check not locked |
|
958 |
gFile.Close(); |
|
959 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
960 |
Error(_L("Delete"),c); |
|
961 |
testVolumeName(_L("voL1"),FALSE); |
|
962 |
testVolumeName(_L("\\vol1"),FALSE); |
|
963 |
testVolumeName(_L("\\12345678.123"),KErrBadName); |
|
964 |
testVolumeName(_L("\\123456.123"),FALSE); |
|
965 |
testVolumeName(_L("\\vol1\\"),KErrNone); |
|
966 |
testVolumeName(_L("."),KErrBadName); // Bug fix SW1-728 to prevent illegal characters |
|
967 |
testVolumeName(_L(".."),KErrBadName); // in the volume name |
|
968 |
testVolumeName(_L("A."),KErrBadName); |
|
969 |
if (!IsTestingLFFS()) |
|
970 |
{ // ??? |
|
971 |
testVolumeName(_L("!\"\x9C$%^&@.(){"),KErrBadName); |
|
972 |
testVolumeName(_L("!\"\x9C$%^&@("),KErrBadName); |
|
973 |
} |
|
974 |
testVolumeName(_L("*.*"),KErrBadName); // Wild cards not allowed |
|
975 |
testVolumeName(_L("?.?"),KErrBadName); |
|
976 |
testVolumeName(_L("????????.???"),KErrBadName); |
|
977 |
testVolumeName(_L("????????.??"),KErrBadName); |
|
978 |
testVolumeName(_L("ABC>DEF"),KErrBadName); |
|
979 |
testVolumeName(_L("ABC<DEF"),KErrBadName); |
|
980 |
testVolumeName(_L("ABC|DEF"),KErrBadName); |
|
981 |
testVolumeName(_L("ABC/DEF"),KErrBadName); |
|
982 |
testVolumeName(_L("ABC\"DEF"),KErrBadName); |
|
983 |
testVolumeName(_L("ABC*DEF"),KErrBadName); |
|
984 |
testVolumeName(_L("ABC:DEF"),KErrBadName); |
|
985 |
testVolumeName(_L("ABC?DEF"),KErrBadName); |
|
986 |
testVolumeName(_L("ABC\\DEF"),KErrBadName); |
|
987 |
testVolumeName(_L("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),KErrBadName); // Too long |
|
988 |
testVolumeName(_L("VOLUME1"),FALSE); // Too long in UNICODE |
|
989 |
testVolumeName(_L("Z:VOLUME1"),KErrAccessDenied); |
|
990 |
} |
|
991 |
||
992 |
test.Printf(_L("Test make directory\n")); |
|
993 |
||
994 |
// Test path |
|
995 |
testMakeDir(_L("\\A2345678.A23\\NAME"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
996 |
testMakeDir(_L("\\A23456789.A23\\NAME"),KErrNone); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
997 |
testMakeDir(_L("\\A2345678.A234\\NAME"),KErrNone); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
998 |
testMakeDir(_L("\\A.1234\\NAME"),KErrNone); // ********* KErrBadName); |
0 | 999 |
testMakeDir(_L("\\A2345678\\NAME"),FALSE); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1000 |
testMakeDir(_L("\\A23456789\\NAME"),KErrNone); // ******** KErrBadName); |
0 | 1001 |
testMakeDir(_L("\\A.X\\NAME"),FALSE); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
testMakeDir(_L("\\A..X\\NAME"),KErrNone); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1003 |
testMakeDir(_L("\\A.\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
testMakeDir(_L("\\.X\\NAME"),KErrNone); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1005 |
testMakeDir(_L("\\.\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
testMakeDir(_L("\\..\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
testMakeDir(_L("\\\\NAME"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1008 |
testMakeDir(_L("\\\\"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1009 |
testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678.123"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678..123"),KErrBadName); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
testMakeDir(_L("\\A\\A2\\A23\\a2345678\\a2345678.\\a2345678.1\\a2345678.1234"),KErrBadName); // ******* KErrBadName); |
0 | 1012 |
gDataBuf.SetLength(256); |
1013 |
gDataBuf.Fill('V',255); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1014 |
testMakeDir(gDataBuf,KErrBadName); |
0 | 1015 |
gDataBuf.SetLength(257); |
1016 |
gDataBuf.Fill('W',256); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1017 |
testMakeDir(gDataBuf,KErrBadName); |
0 | 1018 |
gDataBuf.SetLength(258); |
1019 |
gDataBuf.Fill('X',257); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
testMakeDir(gDataBuf,KErrBadName); |
0 | 1021 |
gDataBuf.SetLength(259); |
1022 |
gDataBuf.Fill('Y',258); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
testMakeDir(gDataBuf,KErrBadName); |
0 | 1024 |
gDataBuf.SetLength(4096); |
1025 |
gDataBuf.Fill('Z',4095); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
testMakeDir(gDataBuf,KErrBadName); |
0 | 1027 |
|
1028 |
// Test names |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
testMakeDir(_L("A..X"),KErrAlreadyExists); // ******* KErrBadName); |
0 | 1030 |
testMakeDir(_L("\\A\\"),FALSE); |
1031 |
testMakeDir(_L("\\12345678.123\\"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
testMakeDir(_L("\\.\\"),KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
testMakeDir(_L("\\..\\"),KErrBadName); |
0 | 1034 |
testMakeDir(_L("\\X\\"),FALSE); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
testMakeDir(_L("\\12345678.1234\\"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
testMakeDir(_L("\\123456789\\"),KErrNone); // ******** KErrBadName); |
0 | 1037 |
// Test max levels |
1038 |
testMakeDir(_L("\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z"),FALSE); |
|
1039 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.3"),FALSE); |
|
1040 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.34"),FALSE); |
|
1041 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.345"),FALSE); |
|
1042 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.3\\xxxxxxxx.xxx"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1043 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.34\\xxxxxxxx.xxx"),KErrNone); // ******* KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1044 |
testMakeDir(_L("\\00000000.000\\11111111.111\\22222222.222\\33333333.333\\45678901.345\\xxxxxxxx.xxx"),KErrNone); // ******* KErrBadName); |
0 | 1045 |
testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23"),FALSE); |
1046 |
testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23456789.123"),FALSE); |
|
1047 |
testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23\\5"),FALSE); |
|
1048 |
testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\23\\56789012.456"),FALSE); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1049 |
testMakeDir(_L("\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\2\\4\\6\\8\\0\\234\\6"),KErrNone); // ******** KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1050 |
testMakeDir(_L("Z:\\ROMDIR\\"),KErrAccessDenied); // |
0 | 1051 |
test.Printf(_L("Test setEof to same length\n")); |
1052 |
gNameBuf.SetLength(0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1053 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1054 |
Error(_L("Open 50"),c); |
1055 |
gFile.Close(); |
|
1056 |
testSetEof(gNameOut,0L,FALSE); // should be no change // |
|
1057 |
testSetEof(gNameOut,1L,TRUE); // should be change // |
|
1058 |
testSetEof(gNameOut,1L,FALSE); // should be no change // |
|
1059 |
testSetEof(gNameOut,1L,FALSE); |
|
1060 |
if (fBuf[5]=='M') |
|
1061 |
testSize=650L; // No room on M: for 65536 ! // |
|
1062 |
else |
|
1063 |
testSize=65536L; |
|
1064 |
testSetEof(gNameOut,testSize,TRUE); |
|
1065 |
testSetEof(gNameOut,testSize,FALSE); |
|
1066 |
testSetEof(gNameOut,testSize+1L,TRUE); |
|
1067 |
testSetEof(gNameOut,testSize,TRUE); |
|
1068 |
||
1069 |
testSetEof(gNameOut,0L,TRUE); |
|
1070 |
testSetEof(gNameOut,0L,FALSE); |
|
1071 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1072 |
Error(_L("Delete"),c); |
|
1073 |
||
1074 |
test.Printf(_L("Test read of zero bytes\n")); |
|
1075 |
gNameBuf.SetLength(0); |
|
1076 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1077 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1078 |
Error(_L("Open 60"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1079 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** KErrEof) |
0 | 1080 |
Error(_L("Read 61"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1081 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** KErrEof) |
0 | 1082 |
Error(_L("Read 62"),c); |
1083 |
if ((c=gFile.Write(gDataBuf,0))!=KErrNone) |
|
1084 |
Error(_L("Write 63"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1085 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** KErrEof) |
0 | 1086 |
Error(_L("Read 64"),c); |
1087 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1088 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1089 |
Error(_L("Open 70"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1090 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** KErrEof) |
0 | 1091 |
Error(_L("Read 71"),c); |
1092 |
gDataBuf.SetLength(1); |
|
1093 |
gDataBuf[0]=0xf0; |
|
1094 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
1095 |
Error(_L("Write 72"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1096 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ********* KErrEof) |
0 | 1097 |
Error(_L("Read 73"),c); |
1098 |
pos=0L; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1099 |
if ((c=gFile.Seek((TSeek)ESeekStart,pos))!=KErrNone) |
0 | 1100 |
Error(_L("Seek 74"),c); |
1101 |
gDataBuf.SetLength(1); |
|
1102 |
gDataBuf[0]=0x83; |
|
1103 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) |
|
1104 |
Error(_L("Read 75"),c); |
|
1105 |
// if (gDataBuf[0]!=0x83) *********** Read zeros the length of a buffer after a zero length read |
|
1106 |
if (gDataBuf.Length()!=0) |
|
1107 |
Error(_L("buffer 1 check"),0); |
|
1108 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) |
|
1109 |
Error(_L("Read 76"),c); |
|
1110 |
if ((c=gFile.Read(gDataBuf,1))!=KErrNone || gDataBuf.Length()!=1) |
|
1111 |
Error(_L("Read 77"),c); |
|
1112 |
if (gDataBuf[0]!=0xf0) |
|
1113 |
Error(_L("buffer 1 check"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1114 |
if ((c=gFile.Read(gDataBuf,0))!=KErrNone) // ******** KErrEof) |
0 | 1115 |
Error(_L("Read 78"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1116 |
if ((c=gFile.Read(gDataBuf,16384))!=KErrNone) // ******* KErrEof) |
0 | 1117 |
Error(_L("Read 79"),c); |
1118 |
gFile.Close(); |
|
1119 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1120 |
Error(_L("Delete"),c); |
|
1121 |
||
1122 |
test.Printf(_L("Test write of zero bytes\n")); |
|
1123 |
gNameBuf.SetLength(0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1124 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1125 |
Error(_L("Open 50"),c); |
1126 |
gFile.Close(); |
|
1127 |
// ********** Error(_L("Close"),c); close has no return value |
|
1128 |
gDataBuf.SetLength(16384); |
|
1129 |
||
1130 |
testWrite(gNameOut,0,0L,FALSE); // should be no change // |
|
1131 |
testWrite(gNameOut,1,1L,TRUE); // should be change // |
|
1132 |
testWrite(gNameOut,0,1L,FALSE); |
|
1133 |
testWrite(gNameOut,0,1L,FALSE); |
|
1134 |
testWrite(gNameOut,16384,16384L,TRUE); |
|
1135 |
testWrite(gNameOut,0,16384L,FALSE); |
|
1136 |
testWrite(gNameOut,16383,16384L,TRUE); |
|
1137 |
||
1138 |
||
1139 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1140 |
Error(_L("Delete"),c); |
|
1141 |
||
1142 |
test.Printf(_L("Test ReadOnly files\n")); |
|
1143 |
gNameBuf.SetLength(0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1144 |
if ((c=gFile.Create(TheFs,_L("TEST1.TMP"),EFileStream|EFileWrite))!=KErrNone) |
0 | 1145 |
Error(_L("Create 40"),c); |
1146 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1147 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1148 |
Error(_L("Open 40"),c); |
1149 |
mask=0; |
|
1150 |
attrib=KEntryAttReadOnly; // Remove writable // |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1151 |
if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrInUse) |
0 | 1152 |
Error(_L("TheFs.SetAtt not locked"),c); |
1153 |
gFile.Close(); |
|
1154 |
if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone) |
|
1155 |
Error(_L("Att 41"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1156 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrAccessDenied) |
0 | 1157 |
Error(_L("Open 41"),c); |
1158 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream))!=KErrNone) |
|
1159 |
Error(_L("Open 42"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1160 |
if ((c=gFileErr.Open(TheFs,gNameOut,EFileStream))!=KErrInUse) |
0 | 1161 |
Error(_L("Open 43"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1162 |
if ((c=TheFs.Rename(_L("TEST1.TMP"),gNameOut))!=KErrAlreadyExists) |
0 | 1163 |
Error(_L("Rename 43.1"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1164 |
if ((c=gFileErr.Create(TheFs,gNameOut,EFileStream))!=KErrAlreadyExists) // KErrInUse) |
0 | 1165 |
Error(_L("Open 44"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1166 |
if ((c=gFileErr.Replace(TheFs,gNameOut,EFileStream))!=KErrInUse) |
0 | 1167 |
Error(_L("Open 45"),c); |
1168 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
if ((c=gFile.Create(TheFs,gNameOut,EFileStream))!=KErrAlreadyExists) |
0 | 1170 |
Error(_L("Create 46"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1171 |
if ((c=gFile.Replace(TheFs,gNameOut,EFileStream))!=KErrAccessDenied) |
0 | 1172 |
Error(_L("Replace 47"),c); |
1173 |
if ((c=gFile.Create(TheFs,_L("FILE1.TMP"),EFileStream))!=KErrNone) |
|
1174 |
Error(_L("Create 48"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1175 |
if ((c=TheFs.Rename(_L("FILE1.TMP"),_L("FILE2.TMP")))!=KErrInUse) |
0 | 1176 |
Error(_L("Rename 49"),c); |
1177 |
gFile.Close(); |
|
1178 |
if ((c=TheFs.Rename(_L("FILE1.TMP"),_L("FILE2.TMP")))!=KErrNone) |
|
1179 |
Error(_L("Rename 50"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1180 |
if ((c=TheFs.Rename(_L("FILE2.TMP"),gNameOut))!=KErrAlreadyExists) |
0 | 1181 |
Error(_L("Rename 51"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1182 |
if ((c=TheFs.Delete(gNameOut))!=KErrAccessDenied) |
0 | 1183 |
Error(_L("Delete"),c); |
1184 |
mask=KEntryAttReadOnly; |
|
1185 |
attrib=0; |
|
1186 |
if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone) |
|
1187 |
Error(_L("Att 42"),c); |
|
1188 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1189 |
Error(_L("Delete 1"),c); |
|
1190 |
if ((c=TheFs.Delete(_L("TEST1.TMP")))!=KErrNone) |
|
1191 |
Error(_L("Delete 2"),c); |
|
1192 |
if ((c=TheFs.Delete(_L("FILE2.TMP")))!=KErrNone) |
|
1193 |
Error(_L("Delete 3"),c); |
|
1194 |
||
1195 |
test.Printf(_L("Test write/setEof without UPDATE\n")); |
|
1196 |
if ((c=gFile.Create(TheFs,_L("B_GEN.001"),EFileStream))!=KErrNone) |
|
1197 |
Error(_L("Open 30"),c); |
|
1198 |
gFile.Close(); |
|
1199 |
if ((c=gFile.Open(TheFs,_L("B_GEN.001"),EFileStream))!=KErrNone) |
|
1200 |
Error(_L("Open 30"),c); |
|
1201 |
pos=1L; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1202 |
if ((c=gFile.SetSize(pos))!=KErrAccessDenied) |
0 | 1203 |
Error(_L("Set EOF 30"),c); |
1204 |
if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone) |
|
1205 |
Error(_L("File info 30"),c); |
|
1206 |
if (gFileEntry.iSize!=0L) |
|
1207 |
Error(_L("Size check 30"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1208 |
if ((c=gFile.Write(gDataBuf,1))!=KErrAccessDenied) |
0 | 1209 |
Error(_L("Write 30"),c); |
1210 |
if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone) |
|
1211 |
Error(_L("File info 31"),c); |
|
1212 |
if (gFileEntry.iSize!=0L) |
|
1213 |
Error(_L("Size check 31"),0); |
|
1214 |
gFile.Close(); |
|
1215 |
if ((c=TheFs.Entry(_L("B_GEN.001"),gFileEntry))!=KErrNone) |
|
1216 |
Error(_L("File info 32"),c); |
|
1217 |
if (gFileEntry.iSize!=0L) |
|
1218 |
Error(_L("Size check 32"),0); |
|
1219 |
if ((c=TheFs.Delete(_L("B_GEN.001")))!=KErrNone) |
|
1220 |
Error(_L("Delete"),c); |
|
1221 |
||
1222 |
||
1223 |
test.Printf(_L("Test dir entries are written out\n")); |
|
1224 |
gNameBuf.SetLength(0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1225 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1226 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) |
0 | 1227 |
Error(_L("Open 20"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1228 |
|
0 | 1229 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
1230 |
Error(_L("File info 0"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1231 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1232 |
if ((gFileEntry.iAtt & KEntryAttArchive)==0) |
0 | 1233 |
Error(_L("Status 20"),0); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1234 |
|
0 | 1235 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1236 |
|
0 | 1237 |
if (gFileEntry.iSize!=0L) |
1238 |
Error(_L("Size check 0"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1239 |
|
0 | 1240 |
saveTime=gFileEntry.iModified; |
1241 |
test.Printf(_L("Wait 3 seconds...\n")); |
|
1242 |
User::After(3000000L); |
|
1243 |
gDataBuf.SetLength(1); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1244 |
|
0 | 1245 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
1246 |
Error(_L("Write 1"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1247 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1248 |
/* === pay attention to the code below if the "not updating file timestamp on Flush" mode is enabled (at least on FAT) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1249 |
//-- the timestamp in the "real" entry on the media (RFs::Entry()) and what we get by RFile::Modified() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1250 |
//-- can differ even after flushing file. The timestamp will be updated only on _closing_ the file. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1251 |
//-- This behaviour can be an optimisation to reduce number of media writes due to updating file timestamps. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1252 |
gFile.Close(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1253 |
nRes = gFile.Open(TheFs, gNameOut, EFileWrite); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1254 |
test(nRes == KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1255 |
//-- restore the expected position in the file |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1256 |
TInt pos1 = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1257 |
nRes = gFile.Seek(ESeekEnd, pos1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1258 |
test(nRes == KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1259 |
//------------------------------------ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1260 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1261 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1262 |
|
0 | 1263 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
1264 |
Error(_L("File info 1"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1265 |
|
0 | 1266 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
1267 |
if (gFileEntry.iSize!=1L) |
|
1268 |
Error(_L("Size check 1"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1269 |
|
0 | 1270 |
if (gFileEntry.iModified==saveTime) |
1271 |
Error(_L("Time update"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1272 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1273 |
|
0 | 1274 |
gDataBuf.SetLength(16384); |
1275 |
if ((c=gFile.Write(gDataBuf,16384))!=KErrNone) |
|
1276 |
Error(_L("Write 2"),c); |
|
1277 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1278 |
Error(_L("File info 2"),c); |
|
1279 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
|
1280 |
if (gFileEntry.iSize!=16385L) |
|
1281 |
Error(_L("Size check 2"),0); |
|
1282 |
pos=0L; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1283 |
if ((c=gFile.Seek((TSeek)ESeekStart,pos))!=KErrNone) |
0 | 1284 |
Error(_L("Seek 0"),c); |
1285 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
1286 |
Error(_L("Write 3"),c); |
|
1287 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1288 |
Error(_L("File info 3"),c); |
|
1289 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
|
1290 |
if (gFileEntry.iSize!=16385L) |
|
1291 |
Error(_L("Size check 3"),0); |
|
1292 |
pos=0L; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1293 |
if ((c=gFile.Seek((TSeek)ESeekStart,pos))!=KErrNone) |
0 | 1294 |
Error(_L("Seek 1"),c); |
1295 |
if ((c=gFile.Write(gDataBuf,16384))!=KErrNone) |
|
1296 |
Error(_L("Write 4"),c); |
|
1297 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
1298 |
Error(_L("Write 5"),c); |
|
1299 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1300 |
Error(_L("File info 4"),c); |
|
1301 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
|
1302 |
if (gFileEntry.iSize!=16385L) |
|
1303 |
Error(_L("Size check 4"),0); |
|
1304 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
1305 |
Error(_L("Write 6"),c); |
|
1306 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1307 |
Error(_L("File info 5"),c); |
|
1308 |
test.Printf(_L("Size=%u\n"),gFileEntry.iSize); |
|
1309 |
if (gFileEntry.iSize!=16386L) |
|
1310 |
Error(_L("Size check 5"),0); |
|
1311 |
for (i=0;i<50;i++) |
|
1312 |
{ |
|
1313 |
TInt r=(Math::Rand(seed) & 0x7fff); |
|
1314 |
test.Printf(_L("%u) Set eof to %u\n"),i,r); |
|
1315 |
pos=r; |
|
1316 |
if ((c=gFile.SetSize(pos))!=KErrNone) |
|
1317 |
Error(_L("Set EOF 1"),c); |
|
1318 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1319 |
Error(_L("File info 6"),c); |
|
1320 |
if (gFileEntry.iSize!=r) |
|
1321 |
Error(_L("Size check 6"),i); |
|
1322 |
} |
|
1323 |
pos=0L; |
|
1324 |
if ((c=gFile.SetSize(pos))!=KErrNone) |
|
1325 |
Error(_L("Set EOF 2"),c); |
|
1326 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1327 |
Error(_L("File info 7"),c); |
|
1328 |
if (gFileEntry.iSize!=0L) |
|
1329 |
Error(_L("Size check 7"),0); |
|
1330 |
gFile.Close(); |
|
1331 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1332 |
Error(_L("File info 8"),c); |
|
1333 |
if (gFileEntry.iSize!=0L) |
|
1334 |
Error(_L("Size check 7"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1335 |
mask=KEntryAttArchive; |
0 | 1336 |
attrib=0; |
1337 |
if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone) |
|
1338 |
Error(_L("Att 20"),c); |
|
1339 |
||
1340 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1341 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1342 |
Error(_L("Open 21"),c); |
1343 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1344 |
Error(_L("File info 9"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1345 |
if (gFileEntry.iAtt & KEntryAttArchive) |
0 | 1346 |
Error(_L("Status 21"),0); |
1347 |
if ((c=gFile.Write(gDataBuf,0))!=KErrNone) |
|
1348 |
Error(_L("Write 21"),c); |
|
1349 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1350 |
Error(_L("File info 9"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1351 |
if ((gFileEntry.iAtt & KEntryAttArchive)) // write 0 should not modify // |
0 | 1352 |
Error(_L("Status 22"),0); |
1353 |
gFile.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1354 |
mask=KEntryAttArchive; |
0 | 1355 |
attrib=0; |
1356 |
if ((c=TheFs.SetAtt(gNameOut,attrib,mask))!=KErrNone) |
|
1357 |
Error(_L("Att 20"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1358 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1359 |
Error(_L("Open 22"),c); |
1360 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1361 |
Error(_L("File info 9"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1362 |
if (gFileEntry.iAtt & KEntryAttArchive) |
0 | 1363 |
Error(_L("Status 23"),0); |
1364 |
pos=0L; |
|
1365 |
if ((c=gFile.SetSize(pos))!=KErrNone) // no change // |
|
1366 |
Error(_L("Set EOF 21"),c); |
|
1367 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1368 |
Error(_L("File info 9"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1369 |
if ((gFileEntry.iAtt & KEntryAttArchive)) |
0 | 1370 |
Error(_L("Status 24"),0); |
1371 |
gFile.Close(); |
|
1372 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1373 |
Error(_L("File info 0"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1374 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1375 |
Error(_L("Open 23"),c); |
1376 |
saveTime=gFileEntry.iModified; |
|
1377 |
test.Printf(_L("Wait 3 seconds...\n")); |
|
1378 |
User::After(3000000L); |
|
1379 |
if ((c=gFile.Flush())!=KErrNone) // Should not alter time // |
|
1380 |
Error(_L("Flush 0"),c); |
|
1381 |
if (gFileEntry.iModified!=saveTime) |
|
1382 |
Error(_L("Flush new time"),0); |
|
1383 |
gFile.Close(); |
|
1384 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1385 |
Error(_L("File info 61"),c); |
|
1386 |
if (gFileEntry.iModified!=saveTime) |
|
1387 |
Error(_L("Close new time"),0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1388 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream|EFileWrite))!=KErrNone) |
0 | 1389 |
Error(_L("Open 24"),c); |
1390 |
if ((c=gFile.Write(gDataBuf,1))!=KErrNone) |
|
1391 |
Error(_L("Write 60"),c); |
|
1392 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1393 |
Error(_L("File info 62"),c); |
|
1394 |
if (gFileEntry.iModified==saveTime) |
|
1395 |
Error(_L("Write new time 1"),0); |
|
1396 |
saveTime=gFileEntry.iModified; |
|
1397 |
test.Printf(_L("Wait 3 seconds...\n")); |
|
1398 |
User::After(3000000L); |
|
1399 |
if ((c=gFile.Flush())!=KErrNone) // Should alter time // |
|
1400 |
Error(_L("Flush 1"),c); |
|
1401 |
if ((c=TheFs.Entry(gNameOut,gFileEntry))!=KErrNone) |
|
1402 |
Error(_L("File info 64"),c); |
|
1403 |
if (gFileEntry.iModified!=saveTime) // ==saveTime) // !!! Flush doesn't alter the time unless the file is modified |
|
1404 |
Error(_L("Flush new time 1"),0); |
|
1405 |
gFile.Close(); |
|
1406 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1407 |
Error(_L("Delete"),c); |
|
1408 |
||
1409 |
test.Printf(_L("Test set file date\n")); |
|
1410 |
gNameOut.SetLength(0); |
|
1411 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) |
|
1412 |
Error(_L("Open 10"),c); |
|
1413 |
gFile.Close(); |
|
1414 |
if ((c=gFile.Open(TheFs,gNameOut,EFileStream))!=KErrNone) |
|
1415 |
Error(_L("Open 10"),c); // Temp file is created as writable. |
|
1416 |
TTime fileTime(0); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
if ((c=gFile.SetModified(fileTime))!=KErrAccessDenied) // KErrInUse) |
0 | 1418 |
Error(_L("Set file date 10"),c); |
1419 |
gFile.Close(); |
|
1420 |
||
1421 |
||
1422 |
for (i=0;i<DateTests;i++) |
|
1423 |
{ |
|
1424 |
// TUint32 testSeconds[] = |
|
1425 |
// { |
|
1426 |
// 0L, |
|
1427 |
// 315532799L, 315532800L, 315532801L,315532802L, |
|
1428 |
// 0xfffffffeL,0xffffffffL,0x7fffffffL, |
|
1429 |
// 0x80000000L,0x80000001L |
|
1430 |
// }; |
|
1431 |
// TUint32 checkSeconds[] = |
|
1432 |
// { |
|
1433 |
// 315532800L, 315532800L, 315532800L, 315532800L, 315532802L, |
|
1434 |
// 0xfffffffeL,0xfffffffeL,0x7ffffffeL, |
|
1435 |
// 0x80000000L,0x80000000L |
|
1436 |
// }; |
|
1437 |
// TInt64 num64((TReal)(testSeconds[i]*1000000)); // !!! NT fails on dates < 1601 |
|
1438 |
// TTime fileTime(num64); |
|
1439 |
// if ((c=TheFs.SetModified(gNameBuf,fileTime))!=KErrNone) |
|
1440 |
// Error(_L("Set file date 0"),c); |
|
1441 |
// if ((c=TheFs.Entry(gNameBuf,gFileEntry))!=KErrNone) |
|
1442 |
// Error(_L("File info 10"),c); |
|
1443 |
// num64=(TReal)checkSeconds[i]*1000000; |
|
1444 |
// if (gFileEntry.iModified.Int64()!=num64) |
|
1445 |
// Error(_L("Date check 0"),i); |
|
1446 |
} |
|
1447 |
if ((c=TheFs.Delete(gNameOut))!=KErrNone) |
|
1448 |
Error(_L("Delete 1"),c); |
|
1449 |
test.Printf(_L("Test format\n")); |
|
1450 |
gNameOut.SetLength(0); |
|
1451 |
if ((c=gFile.Temp(TheFs,gNameBuf,gNameOut,EFileStream))!=KErrNone) |
|
1452 |
Error(_L("Open 1"),c); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1453 |
if ((c=gFormat.Open(TheFs,fBuf,EFullFormat,count))!=KErrInUse) |
0 | 1454 |
Error(_L("Format lock check 1"),c); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1455 |
if ((c=gFormat.Open(TheFs,fBuf,EQuickFormat,count))!=KErrInUse) |
0 | 1456 |
Error(_L("Format lock check 2"),c); |
1457 |
gFile.Close(); |
|
1458 |
||
1459 |
if ((c=gFormat.Open(TheFs,fBuf,EFullFormat,count))!=KErrNone) |
|
1460 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1461 |
if (c==KErrInUse || c==KErrAccessDenied) |
0 | 1462 |
{ |
1463 |
test.Printf(_L("Format: locked, no test\n")); |
|
1464 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1465 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1466 |
{ |
0 | 1467 |
Error(_L("Format lock check"),c); |
1468 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1469 |
} |
0 | 1470 |
|
1471 |
gFormat.Close(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1472 |
|
0 | 1473 |
DeleteTestDirectory(); |
1474 |
||
1475 |
} |