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