55 TInt r; |
56 TInt r; |
56 const TUint KBufSize = 256*K1KiloByte; |
57 const TUint KBufSize = 256*K1KiloByte; |
57 RBuf8 buf; |
58 RBuf8 buf; |
58 |
59 |
59 r = buf.CreateMax(KBufSize); |
60 r = buf.CreateMax(KBufSize); |
60 test(r == KErrNone); |
61 test_KErrNone(r); |
61 |
62 |
62 RFile64 file; |
63 RFile64 file; |
63 TFileName fileName; |
64 TFileName fileName; |
64 fileName.Append(gDriveToTest); |
65 fileName.Append(gDriveToTest); |
65 fileName.Append(KTestPath); |
66 fileName.Append(KTestPath); |
66 fileName.Append(_L("File4GBMinusOne.txt")); |
67 fileName.Append(_L("File4GBMinusOne.txt")); |
67 r = file.Replace(TheFs,fileName, EFileWrite); |
68 r = file.Replace(TheFs,fileName, EFileWrite); |
68 test(r == KErrNone); |
69 test_KErrNone(r); |
69 |
70 |
70 r = file.SetSize(K4GBMinusOne); |
71 r = file.SetSize(K4GBMinusOne); |
71 test(r == KErrNone); |
72 test_KErrNone(r); |
72 |
73 |
73 TInt64 nNumberOfBytesToWrite = 0; |
74 TInt64 nNumberOfBytesToWrite = 0; |
74 TInt64 nNumberOfBytesWritten = 0; |
75 TInt64 nNumberOfBytesWritten = 0; |
75 for (TInt64 pos = 0; pos < K4GBMinusOne; pos += nNumberOfBytesWritten) |
76 for (TInt64 pos = 0; pos < K4GBMinusOne; pos += nNumberOfBytesWritten) |
76 { |
77 { |
213 // Gets a filtered list of a directory's contents. |
203 // Gets a filtered list of a directory's contents. |
214 // |
204 // |
215 { |
205 { |
216 test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName); |
206 test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName); |
217 TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList); |
207 TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList); |
218 test(r == KErrNone); |
208 test_KErrNone(r); |
219 return(*this); |
209 return(*this); |
220 } |
210 } |
221 |
211 |
222 RFsTest& RFsTest::GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey,CDir*& anEntryList,CDir*& aDirList) |
212 RFsTest& RFsTest::GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey,CDir*& anEntryList,CDir*& aDirList) |
223 // |
213 // |
224 // Gets a filtered list of the directory and the file entries contained in a directory and a |
214 // Gets a filtered list of the directory and the file entries contained in a directory and a |
225 // list of the directory entries only. |
215 // list of the directory entries only. |
226 { |
216 { |
227 test.Printf(_L("Name of the directory for which directory and file listing is required %S\n"),&aName); |
217 test.Printf(_L("Name of the directory for which directory and file listing is required %S\n"),&aName); |
228 TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList,aDirList); |
218 TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList,aDirList); |
229 test(r == KErrNone); |
219 test_KErrNone(r); |
230 return(*this); |
220 return(*this); |
231 } |
221 } |
232 |
222 |
233 RFsTest& RFsTest::GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey,CDir*& aFileList) |
223 RFsTest& RFsTest::GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey,CDir*& aFileList) |
234 // |
224 // |
235 // Gets a filtered list of directory contents by UID type. |
225 // Gets a filtered list of directory contents by UID type. |
236 // |
226 // |
237 { |
227 { |
238 test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName); |
228 test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName); |
239 TInt r = TheFs.GetDir(aName,anEntryUid,anEntrySortKey,aFileList); |
229 TInt r = TheFs.GetDir(aName,anEntryUid,anEntrySortKey,aFileList); |
240 test(r == KErrNone); |
230 test_KErrNone(r); |
241 return(*this); |
231 return(*this); |
242 } |
232 } |
243 |
233 |
244 |
234 |
245 RFileTest::RFileTest(const TDesC& aName) |
235 RFileTest::RFileTest(const TDesC& aName) |
278 // if it exists or cretaing a new file if it does not exist. |
268 // if it exists or cretaing a new file if it does not exist. |
279 // |
269 // |
280 { |
270 { |
281 test.Printf(_L("%S replace %S in %d Mode\n"),&iName,&aName, aFileMode); |
271 test.Printf(_L("%S replace %S in %d Mode\n"),&iName,&aName, aFileMode); |
282 TInt r = RFile64::Replace(TheFs,aName,aFileMode); |
272 TInt r = RFile64::Replace(TheFs,aName,aFileMode); |
283 if (r == KErrNone) |
273 test_Value(r, r == KErrNone || r == KErrBadName); |
284 test(r == KErrNone); |
|
285 else |
|
286 test(r == KErrBadName); |
|
287 return(*this); |
274 return(*this); |
288 } |
275 } |
289 |
276 |
290 RFileTest& RFileTest::Open(const TDesC& aName) |
277 RFileTest& RFileTest::Open(const TDesC& aName) |
291 // |
278 // |
292 // Open a existing file for reading and writing in shared access mode. |
279 // Open a existing file for reading and writing in shared access mode. |
293 // |
280 // |
294 { |
281 { |
295 test.Printf(_L("%S open %S\n"),&iName,&aName); |
282 test.Printf(_L("%S open %S\n"),&iName,&aName); |
296 TInt r = RFile64::Open(TheFs,aName,EFileWrite|EFileShareAny); |
283 TInt r = RFile64::Open(TheFs,aName,EFileWrite|EFileShareAny); |
297 test(r == KErrNone); |
284 test_KErrNone(r); |
298 return(*this); |
285 return(*this); |
299 } |
286 } |
300 |
287 |
301 RFileTest& RFileTest::Open(const TDesC& aName, TUint aFileMode) |
288 RFileTest& RFileTest::Open(const TDesC& aName, TUint aFileMode) |
302 // |
289 // |
303 // Opens an existing file using aFileMode. |
290 // Opens an existing file using aFileMode. |
304 // |
291 // |
305 { |
292 { |
306 test.Printf(_L("%S open %S in %d Mode\n"),&iName,&aName, aFileMode); |
293 test.Printf(_L("%S open %S in %d Mode\n"),&iName,&aName, aFileMode); |
307 TInt r = RFile64::Open(TheFs,aName,aFileMode); |
294 TInt r = RFile64::Open(TheFs,aName,aFileMode); |
308 test(r == KErrNone); |
295 test_KErrNone(r); |
309 return(*this); |
296 return(*this); |
310 } |
297 } |
311 |
298 |
312 RFileTest& RFileTest::Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode) |
299 RFileTest& RFileTest::Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode) |
313 // |
300 // |
314 // Creates and opens a temporary file with a unique name for writing and reading. |
301 // Creates and opens a temporary file with a unique name for writing and reading. |
315 // |
302 // |
316 { |
303 { |
317 test.Printf(_L("%S Temp file %S in %d Mode\n"),&iName,&aName, aFileMode); |
304 test.Printf(_L("%S Temp file %S in %d Mode\n"),&iName,&aName, aFileMode); |
318 TInt r = RFile64::Temp(TheFs,aPath,aName,aFileMode); |
305 TInt r = RFile64::Temp(TheFs,aPath,aName,aFileMode); |
319 test(r == KErrNone); |
306 test_KErrNone(r); |
320 return(*this); |
307 return(*this); |
321 } |
308 } |
322 |
309 |
323 void RFileTest::Close() |
310 void RFileTest::Close() |
324 // |
311 // |
333 // Set a lock on the file. Expected not to fail. |
320 // Set a lock on the file. Expected not to fail. |
334 // |
321 // |
335 { |
322 { |
336 test.Printf(_L("%S lock 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
323 test.Printf(_L("%S lock 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
337 TInt r = RFile64::Lock(aPos,aLen); |
324 TInt r = RFile64::Lock(aPos,aLen); |
338 test(r == KErrNone); |
325 test_KErrNone(r); |
339 return(*this); |
326 return(*this); |
340 } |
327 } |
341 |
328 |
342 RFileTest& RFileTest::LockE(TInt64 aPos, TInt64 aLen) |
329 RFileTest& RFileTest::LockE(TInt64 aPos, TInt64 aLen) |
343 // |
330 // |
344 // Set a lock on the file. Expected to fail. |
331 // Set a lock on the file. Expected to fail. |
345 // |
332 // |
346 { |
333 { |
347 test.Printf(_L("%S lockE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
334 test.Printf(_L("%S lockE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
348 TInt r = RFile64::Lock(aPos,aLen); |
335 TInt r = RFile64::Lock(aPos,aLen); |
349 test(r == KErrLocked); |
336 test_Value(r, r == KErrLocked); |
350 return(*this); |
337 return(*this); |
351 } |
338 } |
352 |
339 |
353 RFileTest& RFileTest::UnLock(TInt64 aPos, TInt64 aLen) |
340 RFileTest& RFileTest::UnLock(TInt64 aPos, TInt64 aLen) |
354 // |
341 // |
355 // Unlock the file. Expected not to fail. |
342 // Unlock the file. Expected not to fail. |
356 // |
343 // |
357 { |
344 { |
358 test.Printf(_L("%S ulock 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
345 test.Printf(_L("%S ulock 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
359 TInt r = RFile64::UnLock(aPos,aLen); |
346 TInt r = RFile64::UnLock(aPos,aLen); |
360 test(r == KErrNone); |
347 test_KErrNone(r); |
361 return(*this); |
348 return(*this); |
362 } |
349 } |
363 |
350 |
364 RFileTest& RFileTest::UnLockE(TInt64 aPos, TInt64 aLen) |
351 RFileTest& RFileTest::UnLockE(TInt64 aPos, TInt64 aLen) |
365 // |
352 // |
366 // Unlock the file. Expected to fail. |
353 // Unlock the file. Expected to fail. |
367 // |
354 // |
368 { |
355 { |
369 test.Printf(_L("%S ulockE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
356 test.Printf(_L("%S ulockE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1); |
370 TInt r = RFile64::UnLock(aPos,aLen); |
357 TInt r = RFile64::UnLock(aPos,aLen); |
371 test(r == KErrNotFound); |
358 test_Value(r, r == KErrNotFound); |
372 return(*this); |
359 return(*this); |
373 } |
360 } |
374 |
361 |
375 RFileTest& RFileTest::Write(const TDesC8& aDes) |
362 RFileTest& RFileTest::Write(const TDesC8& aDes) |
376 // |
363 // |
1058 TestRFile1.SetSize(testSize); |
1063 TestRFile1.SetSize(testSize); |
1059 TestRFile1.Close(); |
1064 TestRFile1.Close(); |
1060 |
1065 |
1061 test.Next(_L("3GB File: Open")); |
1066 test.Next(_L("3GB File: Open")); |
1062 r = TheFs.Entry(fileName, entry); |
1067 r = TheFs.Entry(fileName, entry); |
1063 test(r == KErrNone); |
1068 test_KErrNone(r); |
1064 test((TUint) entry.iSize == testSize); |
1069 test((TUint) entry.iSize == testSize); |
1065 |
1070 |
1066 TestRFile1.Open(fileName,EFileRead); |
1071 TestRFile1.Open(fileName,EFileRead); |
1067 |
1072 |
1068 TestRFile1.Size(size); |
1073 TestRFile1.Size(size); |
1069 test(size == testSize); |
1074 test(size == testSize); |
1070 TestRFile1.Close(); |
1075 TestRFile1.Close(); |
1071 |
1076 |
1072 r = TheFs.Delete(fileName); |
1077 r = TheFs.Delete(fileName); |
1073 test(r == KErrNone); |
1078 test_KErrNone(r); |
1074 } |
1079 } |
1075 |
1080 |
1076 /** |
1081 /** |
1077 @SYMTestCaseID PBASE-T_FILE64BIT-0758 |
1082 @SYMTestCaseID PBASE-T_FILE64BIT-0758 |
1078 @SYMTestPriority High |
1083 @SYMTestPriority High |
1154 TestRFile1.SetSize(testSize); |
1159 TestRFile1.SetSize(testSize); |
1155 TestRFile1.Close(); |
1160 TestRFile1.Close(); |
1156 |
1161 |
1157 test.Next(_L("4GB File: Open")); |
1162 test.Next(_L("4GB File: Open")); |
1158 r = TheFs.Entry(fileName, entry); |
1163 r = TheFs.Entry(fileName, entry); |
1159 test(r == KErrNone); |
1164 test_KErrNone(r); |
1160 |
1165 |
1161 if ((TUint) entry.iSize == testSize) |
1166 if ((TUint) entry.iSize == testSize) |
1162 { |
1167 { |
1163 TestRFile1.Open(fileName, EFileRead); |
1168 TestRFile1.Open(fileName, EFileRead); |
1164 TestRFile1.Size(size); |
1169 TestRFile1.Size(size); |
1165 test(size == testSize); |
1170 test(size == testSize); |
1166 TestRFile1.Close(); |
1171 TestRFile1.Close(); |
1167 } |
1172 } |
1168 |
1173 |
1169 r = TheFs.Delete(fileName); |
1174 r = TheFs.Delete(fileName); |
1170 test(r == KErrNone); |
1175 test_KErrNone(r); |
1171 |
1176 |
1172 } |
1177 } |
1173 |
1178 |
1174 /** |
1179 /** |
1175 @SYMTestCaseID PBASE-T_FILE64BIT-0760 |
1180 @SYMTestCaseID PBASE-T_FILE64BIT-0760 |
1338 test.Next(_L("Set the file size to 4GB-1\n")); |
1343 test.Next(_L("Set the file size to 4GB-1\n")); |
1339 TestRFile1.SetSize(K4GBMinusOne); |
1344 TestRFile1.SetSize(K4GBMinusOne); |
1340 |
1345 |
1341 test.Next(_L("Query the file size using Rfile::Size()\n")); |
1346 test.Next(_L("Query the file size using Rfile::Size()\n")); |
1342 r = file.Size(size); |
1347 r = file.Size(size); |
1343 test (r == KErrTooBig); |
1348 test_Value(r, r == KErrTooBig); |
1344 |
1349 |
1345 test.Next(_L("Seek to the file position using 2GB+5 using RFile::Seek()\n")); |
1350 test.Next(_L("Seek to the file position using 2GB+5 using RFile::Seek()\n")); |
1346 TUint seekPos1 = K2GB + 5; |
1351 TUint seekPos1 = K2GB + 5; |
1347 TInt seekPos = (TInt)seekPos1; |
1352 TInt seekPos = (TInt)seekPos1; |
1348 r = file.Seek(ESeekStart,seekPos); |
1353 r = file.Seek(ESeekStart,seekPos); |
1349 test(r == KErrArgument); |
1354 test_Value(r, r == KErrArgument); |
1350 |
1355 |
1351 test.Next(_L("Get the file size using RFile64::Size()\n")); |
1356 test.Next(_L("Get the file size using RFile64::Size()\n")); |
1352 TestRFile1.Size(size64); |
1357 TestRFile1.Size(size64); |
1353 |
1358 |
1354 test.Next(_L("Seek to the file position 4GB-10 using RFile64::Seek()\n")); |
1359 test.Next(_L("Seek to the file position 4GB-10 using RFile64::Seek()\n")); |
1372 TestRFile1.Close(); |
1377 TestRFile1.Close(); |
1373 file.Close(); |
1378 file.Close(); |
1374 |
1379 |
1375 test.Next(_L("Open the file using Rfile::Open()\n")); |
1380 test.Next(_L("Open the file using Rfile::Open()\n")); |
1376 r = file.Open(TheFs,fileName,EFileShareAny|EFileWrite); |
1381 r = file.Open(TheFs,fileName,EFileShareAny|EFileWrite); |
1377 test(r == KErrTooBig); |
1382 test_Value(r, r == KErrTooBig); |
1378 |
1383 |
1379 test.Next(_L("Open the file using Rfile64::Open() and close\n")); |
1384 test.Next(_L("Open the file using Rfile64::Open() and close\n")); |
1380 TestRFile1.Open(fileName,EFileShareAny|EFileWrite); |
1385 TestRFile1.Open(fileName,EFileShareAny|EFileWrite); |
1381 TestRFile1.Close(); |
1386 TestRFile1.Close(); |
1382 |
1387 |
1383 r = TheFs.Delete(fileName); |
1388 r = TheFs.Delete(fileName); |
1384 test(r == KErrNone); |
1389 test_KErrNone(r); |
1385 } |
1390 } |
1386 |
1391 |
1387 /** |
1392 /** |
1388 @SYMTestCaseID PBASE-T_FILE64BIT-0762 |
1393 @SYMTestCaseID PBASE-T_FILE64BIT-0762 |
1389 @SYMTestPriority High |
1394 @SYMTestPriority High |
1484 |
1489 |
1485 TestRFile1.Close(); |
1490 TestRFile1.Close(); |
1486 |
1491 |
1487 test.Next(_L("Delete the temporary file\n")); |
1492 test.Next(_L("Delete the temporary file\n")); |
1488 r = TheFs.Delete(fileName); |
1493 r = TheFs.Delete(fileName); |
1489 test(r == KErrNotFound); |
1494 test_Value(r, r == KErrNotFound); |
1490 |
1495 |
1491 test.Next(_L("Create a temporary file using RFile64::Temp without EDeleteOnClose flag\n")); |
1496 test.Next(_L("Create a temporary file using RFile64::Temp without EDeleteOnClose flag\n")); |
1492 TestRFile1.Temp(testDir, fileName, EFileWrite); |
1497 TestRFile1.Temp(testDir, fileName, EFileWrite); |
1493 |
1498 |
1494 test.Next(_L("Close the file\n")); |
1499 test.Next(_L("Close the file\n")); |
1495 TestRFile1.Close(); |
1500 TestRFile1.Close(); |
1496 |
1501 |
1497 test.Next(_L("Delete the temporary the file\n")); |
1502 test.Next(_L("Delete the temporary the file\n")); |
1498 r = TheFs.Delete(fileName); |
1503 r = TheFs.Delete(fileName); |
1499 test(r == KErrNone); |
1504 test_KErrNone(r); |
1500 |
1505 |
1501 } |
1506 } |
1502 |
1507 |
1503 /** |
1508 /** |
1504 @SYMTestCaseID PBASE-T_FILE64BIT-0763 |
1509 @SYMTestCaseID PBASE-T_FILE64BIT-0763 |
1899 { |
1904 { |
1900 test.Next(_L("Tests for checking RFile64::AdoptFromClient()")); |
1905 test.Next(_L("Tests for checking RFile64::AdoptFromClient()")); |
1901 |
1906 |
1902 RProcess p; |
1907 RProcess p; |
1903 TInt r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
1908 TInt r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
1904 test(r == KErrNone); |
1909 test_KErrNone(r); |
1905 |
1910 |
1906 |
1911 |
1907 test.Next(_L("Connect to the File server \n")); |
1912 test.Next(_L("Connect to the File server \n")); |
1908 RFs fs; |
1913 RFs fs; |
1909 r = fs.Connect(); |
1914 r = fs.Connect(); |
1910 test(r == KErrNone); |
1915 test_KErrNone(r); |
1911 |
1916 |
1912 // Check the number of open file handles |
1917 // Check the number of open file handles |
1913 TInt resCount = fs.ResourceCount(); |
1918 TInt resCount = fs.ResourceCount(); |
1914 test(resCount == 0); |
1919 test(resCount == 0); |
1915 |
1920 |
1916 r = fs.ShareProtected(); |
1921 r = fs.ShareProtected(); |
1917 test(r == KErrNone); |
1922 test_KErrNone(r); |
1918 |
1923 |
1919 r = fs.CreatePrivatePath(gDrive); |
1924 r = fs.CreatePrivatePath(gDrive); |
1920 test(r == KErrNone); |
1925 test_KErrNone(r); |
1921 r = fs.SetSessionToPrivate(gDrive); |
1926 r = fs.SetSessionToPrivate(gDrive); |
1922 |
1927 |
1923 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
1928 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
1924 RFile64 file1; |
1929 RFile64 file1; |
1925 r = file1.Replace(fs,KClientFileName,EFileWrite); |
1930 r = file1.Replace(fs,KClientFileName,EFileWrite); |
1926 test(r == KErrNone); |
1931 test_KErrNone(r); |
1927 r = file1.SetSize(K4GB-1); |
1932 r = file1.SetSize(K4GB-1); |
1928 test(r == KErrNone); |
1933 test_KErrNone(r); |
1929 |
1934 |
1930 test.Next(_L("Write few bytes to the location 4GB-10, length = 9bytes\n")); |
1935 test.Next(_L("Write few bytes to the location 4GB-10, length = 9bytes\n")); |
1931 r = file1.Write(K4GB-10,KTestData3(),9); |
1936 r = file1.Write(K4GB-10,KTestData3(),9); |
1932 test(r == KErrNone); |
1937 test_KErrNone(r); |
1933 file1.Close(); |
1938 file1.Close(); |
1934 |
1939 |
1935 r = p.SetParameter(3, gDrive); |
1940 r = p.SetParameter(3, gDrive); |
1936 test(r == KErrNone); |
1941 test_KErrNone(r); |
1937 |
1942 |
1938 p.Resume(); |
1943 p.Resume(); |
1939 |
1944 |
1940 |
1945 |
1941 test.Next(_L("Transfer the file handle using TransferToServer() close the file\n")); |
1946 test.Next(_L("Transfer the file handle using TransferToServer() close the file\n")); |
1943 do |
1948 do |
1944 { |
1949 { |
1945 r = handsvr.Connect(); |
1950 r = handsvr.Connect(); |
1946 } |
1951 } |
1947 while(r == KErrNotFound); |
1952 while(r == KErrNotFound); |
1948 test(r == KErrNone); |
1953 test_KErrNone(r); |
1949 |
1954 |
1950 r = handsvr.SetTestDrive(gDrive); |
1955 r = handsvr.SetTestDrive(gDrive); |
1951 test(r == KErrNone); |
1956 test_KErrNone(r); |
1952 |
1957 |
1953 r = fs.SetSessionToPrivate(gDrive); |
1958 r = fs.SetSessionToPrivate(gDrive); |
1954 test(r == KErrNone); |
1959 test_KErrNone(r); |
1955 |
1960 |
1956 r = file1.Open(fs,KClientFileName,EFileRead); |
1961 r = file1.Open(fs,KClientFileName,EFileRead); |
1957 test(r == KErrNone); |
1962 test_KErrNone(r); |
1958 |
1963 |
1959 // pass the file handle to FHServer |
1964 // pass the file handle to FHServer |
1960 test.Next(_L("RFile::TransferToServer()")); |
1965 test.Next(_L("RFile::TransferToServer()")); |
1961 |
1966 |
1962 TIpcArgs ipcArgs; |
1967 TIpcArgs ipcArgs; |
1963 r = file1.TransferToServer(ipcArgs, 0, 1); |
1968 r = file1.TransferToServer(ipcArgs, 0, 1); |
1964 test(r == KErrNone); |
1969 test_KErrNone(r); |
1965 |
1970 |
1966 test.Next(_L("Adopt the already open file from a client using RFile64::AdoptFromClient()\n")); |
1971 test.Next(_L("Adopt the already open file from a client using RFile64::AdoptFromClient()\n")); |
1967 r = handsvr.PassFileHandleProcessLargeFileClient(ipcArgs); |
1972 r = handsvr.PassFileHandleProcessLargeFileClient(ipcArgs); |
1968 test(r == KErrNone); |
1973 test_KErrNone(r); |
1969 |
1974 |
1970 // verify that the original file handle's position is unchanged |
1975 // verify that the original file handle's position is unchanged |
1971 TInt64 pos = 0; |
1976 TInt64 pos = 0; |
1972 r = file1.Seek(ESeekCurrent, pos); |
1977 r = file1.Seek(ESeekCurrent, pos); |
1973 test(r == KErrNone); |
1978 test_KErrNone(r); |
1974 test(pos == 0); |
1979 test(pos == 0); |
1975 // make sure we can still use it |
1980 // make sure we can still use it |
1976 |
1981 |
1977 test.Next(_L("Read the file from position 4GB-10 and compare the data\n")); |
1982 test.Next(_L("Read the file from position 4GB-10 and compare the data\n")); |
1978 TBuf8<9> rbuf; |
1983 TBuf8<9> rbuf; |
1979 r = file1.Read(K4GB-10,rbuf); |
1984 r = file1.Read(K4GB-10,rbuf); |
1980 test(r == KErrNone); |
1985 test_KErrNone(r); |
1981 test (rbuf == KTestData3); |
1986 test (rbuf == KTestData3); |
1982 |
1987 |
1983 // Close the file |
1988 // Close the file |
1984 file1.Close(); |
1989 file1.Close(); |
1985 handsvr.Exit(); |
1990 handsvr.Exit(); |
1986 handsvr.Close(); |
1991 handsvr.Close(); |
1987 r = fs.MkDir(_L("C:\\mdir")); |
1992 r = fs.MkDir(_L("C:\\mdir")); |
1988 test(r == KErrNone || r == KErrAlreadyExists); |
1993 test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
1989 |
1994 |
1990 // Check the number of open file handles |
1995 // Check the number of open file handles |
1991 resCount = fs.ResourceCount(); |
1996 resCount = fs.ResourceCount(); |
1992 test(resCount == 0); |
1997 test(resCount == 0); |
1993 |
1998 |
1994 r = fs.Delete(KClientFileName); |
1999 r = fs.Delete(KClientFileName); |
1995 test(r == KErrNone); |
2000 test_KErrNone(r); |
1996 fs.Close(); |
2001 fs.Close(); |
1997 } |
2002 } |
1998 |
2003 |
1999 /** |
2004 /** |
2000 @SYMTestCaseID PBASE-T_FILE64BIT-0767 |
2005 @SYMTestCaseID PBASE-T_FILE64BIT-0767 |
2029 test.Next(_L("Tests for checking RFile64::AdoptFromCreator()")); |
2034 test.Next(_L("Tests for checking RFile64::AdoptFromCreator()")); |
2030 //create test server |
2035 //create test server |
2031 test.Next(_L("Create a process named FHServer64Bit.exe\n")); |
2036 test.Next(_L("Create a process named FHServer64Bit.exe\n")); |
2032 RProcess p; |
2037 RProcess p; |
2033 r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
2038 r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
2034 test(r == KErrNone); |
2039 test_KErrNone(r); |
2035 |
2040 |
2036 test.Next(_L("Connect to the file server\n")); |
2041 test.Next(_L("Connect to the file server\n")); |
2037 RFs fs; |
2042 RFs fs; |
2038 r = fs.Connect(); |
2043 r = fs.Connect(); |
2039 test(r == KErrNone); |
2044 test_KErrNone(r); |
2040 |
2045 |
2041 // Check the number of open file handles |
2046 // Check the number of open file handles |
2042 TInt resCount = fs.ResourceCount(); |
2047 TInt resCount = fs.ResourceCount(); |
2043 test(resCount == 0); |
2048 test(resCount == 0); |
2044 |
2049 |
2045 r = fs.ShareProtected(); |
2050 r = fs.ShareProtected(); |
2046 test(r == KErrNone); |
2051 test_KErrNone(r); |
2047 |
2052 |
2048 r = fs.CreatePrivatePath(gDrive); |
2053 r = fs.CreatePrivatePath(gDrive); |
2049 test(r == KErrNone); |
2054 test_KErrNone(r); |
2050 r = fs.SetSessionToPrivate(gDrive); |
2055 r = fs.SetSessionToPrivate(gDrive); |
2051 |
2056 |
2052 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
2057 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
2053 RFile64 file1; |
2058 RFile64 file1; |
2054 r = file1.Replace(fs,KClientFileName,EFileWrite); |
2059 r = file1.Replace(fs,KClientFileName,EFileWrite); |
2055 test(r == KErrNone); |
2060 test_KErrNone(r); |
2056 r = file1.SetSize(K4GB-1); |
2061 r = file1.SetSize(K4GB-1); |
2057 test(r == KErrNone); |
2062 test_KErrNone(r); |
2058 |
2063 |
2059 test.Next(_L("Write few bytes to the location 4GB-10, length = 3bytes\n")); |
2064 test.Next(_L("Write few bytes to the location 4GB-10, length = 3bytes\n")); |
2060 r = file1.Write(K4GB-10,KTestData2(),3); |
2065 r = file1.Write(K4GB-10,KTestData2(),3); |
2061 test(r == KErrNone); |
2066 test_KErrNone(r); |
2062 file1.Close(); |
2067 file1.Close(); |
2063 |
2068 |
2064 r = file1.Open(fs, KClientFileName, EFileWrite); |
2069 r = file1.Open(fs, KClientFileName, EFileWrite); |
2065 |
2070 |
2066 test(r == KErrNone); |
2071 test_KErrNone(r); |
2067 |
2072 |
2068 // NB slot 0 is reserved for the command line |
2073 // NB slot 0 is reserved for the command line |
2069 |
2074 |
2070 test.Next(_L("Transfer the file handle using TransferToProcess() close the file")); |
2075 test.Next(_L("Transfer the file handle using TransferToProcess() close the file")); |
2071 |
2076 |
2072 r = file1.TransferToProcess(p, 1, 2); |
2077 r = file1.TransferToProcess(p, 1, 2); |
2073 |
2078 |
2074 r = p.SetParameter(3, gDrive); |
2079 r = p.SetParameter(3, gDrive); |
2075 test(r == KErrNone); |
2080 test_KErrNone(r); |
2076 |
2081 |
2077 r = fs.SetSessionToPrivate(gDrive); |
2082 r = fs.SetSessionToPrivate(gDrive); |
2078 test(r == KErrNone); |
2083 test_KErrNone(r); |
2079 |
2084 |
2080 // make sure we can still read from the file |
2085 // make sure we can still read from the file |
2081 TBuf8<3> rbuf; |
2086 TBuf8<3> rbuf; |
2082 r = file1.Read(K4GB-10,rbuf,3); |
2087 r = file1.Read(K4GB-10,rbuf,3); |
2083 test(r == KErrNone); |
2088 test_KErrNone(r); |
2084 r = rbuf.CompareF(KTestData2()); |
2089 r = rbuf.CompareF(KTestData2()); |
2085 test(r == KErrNone); |
2090 test_KErrNone(r); |
2086 file1.Close(); |
2091 file1.Close(); |
2087 |
2092 |
2088 r = fs.MkDir(_L("C:\\mdir")); |
2093 r = fs.MkDir(_L("C:\\mdir")); |
2089 test(r == KErrNone || r == KErrAlreadyExists); |
2094 test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
2090 |
2095 |
2091 // Check the number of open file handles - |
2096 // Check the number of open file handles - |
2092 // should be 1 (the one duplicated for the other process) |
2097 // should be 1 (the one duplicated for the other process) |
2093 resCount = fs.ResourceCount(); |
2098 resCount = fs.ResourceCount(); |
2094 test(resCount == 1); |
2099 test(resCount == 1); |
2149 TInt r; |
2154 TInt r; |
2150 |
2155 |
2151 test.Next(_L("Connect to the file server\n")); |
2156 test.Next(_L("Connect to the file server\n")); |
2152 RFs fs; |
2157 RFs fs; |
2153 r = fs.Connect(); |
2158 r = fs.Connect(); |
2154 test(r == KErrNone); |
2159 test_KErrNone(r); |
2155 |
2160 |
2156 // Check the number of open file handles |
2161 // Check the number of open file handles |
2157 TInt resCount = fs.ResourceCount(); |
2162 TInt resCount = fs.ResourceCount(); |
2158 test(resCount == 0); |
2163 test(resCount == 0); |
2159 |
2164 |
2160 r = fs.ShareProtected(); |
2165 r = fs.ShareProtected(); |
2161 test(r == KErrNone); |
2166 test_KErrNone(r); |
2162 |
2167 |
2163 r = fs.CreatePrivatePath(gDrive); |
2168 r = fs.CreatePrivatePath(gDrive); |
2164 test(r == KErrNone); |
2169 test_KErrNone(r); |
2165 r = fs.SetSessionToPrivate(gDrive); |
2170 r = fs.SetSessionToPrivate(gDrive); |
2166 |
2171 |
2167 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
2172 test.Next(_L("Create a file and set the file size to 4GB-1\n")); |
2168 RFile64 file1; |
2173 RFile64 file1; |
2169 r = file1.Replace(fs,KClientFileName,EFileWrite); |
2174 r = file1.Replace(fs,KClientFileName,EFileWrite); |
2170 test(r == KErrNone); |
2175 test_KErrNone(r); |
2171 r = file1.SetSize(K4GB-1); |
2176 r = file1.SetSize(K4GB-1); |
2172 test(r == KErrNone); |
2177 test_KErrNone(r); |
2173 |
2178 |
2174 |
2179 |
2175 r = file1.Write(K4GB-10,KTestData3(),9); |
2180 r = file1.Write(K4GB-10,KTestData3(),9); |
2176 test(r == KErrNone); |
2181 test_KErrNone(r); |
2177 |
2182 |
2178 file1.Close(); |
2183 file1.Close(); |
2179 r = fs.Delete(KClientFileName); |
2184 r = fs.Delete(KClientFileName); |
2180 test(r == KErrNone); |
2185 test_KErrNone(r); |
2181 |
2186 |
2182 RProcess p; |
2187 RProcess p; |
2183 r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
2188 r = p.Create(_L("FHServer64Bit.exe"), KNullDesC); |
2184 test(r == KErrNone); |
2189 test_KErrNone(r); |
2185 // Request an open file (write mode) from the server |
2190 // Request an open file (write mode) from the server |
2186 // using RFile64::AdoptFromServer() |
2191 // using RFile64::AdoptFromServer() |
2187 |
2192 |
2188 test.Next(_L("Adopt an already open file from a server using RFile64::AdoptFromServer()\n")); |
2193 test.Next(_L("Adopt an already open file from a server using RFile64::AdoptFromServer()\n")); |
2189 p.Resume(); |
2194 p.Resume(); |
2213 // adopt the file handle from FHServer |
2218 // adopt the file handle from FHServer |
2214 test.Next(_L("RFile64::AdoptFromServer()")); |
2219 test.Next(_L("RFile64::AdoptFromServer()")); |
2215 |
2220 |
2216 RFile64 file; |
2221 RFile64 file; |
2217 r = file.AdoptFromServer(fsh, ssh); |
2222 r = file.AdoptFromServer(fsh, ssh); |
2218 test(r == KErrNone); |
2223 test_KErrNone(r); |
2219 |
2224 |
2220 test.Next(_L("Read the file from position 4GB-10 and compare the data\n")); |
2225 test.Next(_L("Read the file from position 4GB-10 and compare the data\n")); |
2221 TBuf8<9> rbuf; |
2226 TBuf8<9> rbuf; |
2222 r = file.Read(K4GB-10,rbuf); |
2227 r = file.Read(K4GB-10,rbuf); |
2223 test(r == KErrNone); |
2228 test_KErrNone(r); |
2224 // server should write KTestData1 ("Server!!!") to file |
2229 // server should write KTestData1 ("Server!!!") to file |
2225 test (rbuf == KTestData4); |
2230 test (rbuf == KTestData4); |
2226 |
2231 |
2227 TFileName fileName; |
2232 TFileName fileName; |
2228 r = file.FullName(fileName); |
2233 r = file.FullName(fileName); |
2229 test(r == KErrNone); |
2234 test_KErrNone(r); |
2230 |
2235 |
2231 file.Close(); |
2236 file.Close(); |
2232 //cleanup |
2237 //cleanup |
2233 r = fs.Delete(fileName); |
2238 r = fs.Delete(fileName); |
2234 test(r == KErrNone); |
2239 test_KErrNone(r); |
2235 |
2240 |
2236 TFileName sessionPath; |
2241 TFileName sessionPath; |
2237 r = fs.SessionPath(sessionPath); |
2242 r = fs.SessionPath(sessionPath); |
2238 test(r == KErrNone); |
2243 test_KErrNone(r); |
2239 |
2244 |
2240 r = fs.RmDir(sessionPath); |
2245 r = fs.RmDir(sessionPath); |
2241 test(r == KErrNone); |
2246 test_KErrNone(r); |
2242 |
2247 |
2243 fs.Close(); |
2248 fs.Close(); |
2244 |
2249 |
2245 } |
2250 } |
2246 |
2251 |
4046 fileName.Append(gDriveToTest); |
4051 fileName.Append(gDriveToTest); |
4047 fileName.Append(KTestPath); |
4052 fileName.Append(KTestPath); |
4048 fileName.Append(_L("File4GBMinusOne.txt")); |
4053 fileName.Append(_L("File4GBMinusOne.txt")); |
4049 |
4054 |
4050 TInt r = file.Replace(TheFs,fileName,EFileWrite); |
4055 TInt r = file.Replace(TheFs,fileName,EFileWrite); |
4051 test(r == KErrNone); |
4056 test_KErrNone(r); |
4052 r = file.SetSize(K4GBMinusOne); |
4057 r = file.SetSize(K4GBMinusOne); |
4053 test(r == KErrNone); |
4058 test_KErrNone(r); |
4054 file.Close(); |
4059 file.Close(); |
4055 |
4060 |
4056 test.Next(_L("Read from a big file using RFs::ReadFileSection() from position 3GB-1,52byte lengths of data\n")); |
4061 test.Next(_L("Read from a big file using RFs::ReadFileSection() from position 3GB-1,52byte lengths of data\n")); |
4057 TestRFs.ReadFileSection(fileName,K3GBMinusOne,testDes,52); |
4062 TestRFs.ReadFileSection(fileName,K3GBMinusOne,testDes,52); |
4058 |
4063 |
4143 TestRFile1.Close(); |
4148 TestRFile1.Close(); |
4144 |
4149 |
4145 test.Next(_L("Get the directory listing, sort by size\n")); |
4150 test.Next(_L("Get the directory listing, sort by size\n")); |
4146 RDir dir; |
4151 RDir dir; |
4147 TInt r = dir.Open(TheFs, dirName, KEntryAttNormal); |
4152 TInt r = dir.Open(TheFs, dirName, KEntryAttNormal); |
4148 test (r == KErrNone); |
4153 test_KErrNone(r); |
4149 |
4154 |
4150 TEntryArray entryArray; |
4155 TEntryArray entryArray; |
4151 r = dir.Read(entryArray); |
4156 r = dir.Read(entryArray); |
4152 test (r == KErrEof); |
4157 test_Value(r, r == KErrEof); |
4153 |
4158 |
4154 test.Next(_L("Check the files count in the directory. Number of files in a directory is 4\n")); |
4159 test.Next(_L("Check the files count in the directory. Number of files in a directory is 4\n")); |
4155 test(entryArray.Count() == gFilesInDirectory); |
4160 test(entryArray.Count() == gFilesInDirectory); |
4156 |
4161 |
4157 test.Next(_L("Get the entry list & Check the files are listed in order of file sizes\n")); |
4162 test.Next(_L("Get the entry list & Check the files are listed in order of file sizes\n")); |
4295 dirName.Append(KTestPath); |
4300 dirName.Append(KTestPath); |
4296 |
4301 |
4297 test.Next(_L("Open the directory containing large file, using RDir open()\n")); |
4302 test.Next(_L("Open the directory containing large file, using RDir open()\n")); |
4298 RDir dir; |
4303 RDir dir; |
4299 TInt r = dir.Open(TheFs, dirName, KEntryAttNormal); |
4304 TInt r = dir.Open(TheFs, dirName, KEntryAttNormal); |
4300 test (r == KErrNone); |
4305 test_KErrNone(r); |
4301 |
4306 |
4302 test.Next(_L("Read the directory entry using TEntryArray as parameter\n")); |
4307 test.Next(_L("Read the directory entry using TEntryArray as parameter\n")); |
4303 TEntryArray entryArray; |
4308 TEntryArray entryArray; |
4304 r = dir.Read(entryArray); |
4309 r = dir.Read(entryArray); |
4305 test (r == KErrEof); |
4310 test_Value(r, r == KErrEof); |
4306 |
4311 |
4307 test.Next(_L("Check the count\n")); |
4312 test.Next(_L("Check the count\n")); |
4308 test(entryArray.Count() == gFilesInDirectory); |
4313 test(entryArray.Count() == gFilesInDirectory); |
4309 |
4314 |
4310 test.Next(_L("Close using RDir\n")); |
4315 test.Next(_L("Close using RDir\n")); |
4466 file3GB.Append(gDriveToTest); |
4471 file3GB.Append(gDriveToTest); |
4467 file3GB.Append(KTestPath); |
4472 file3GB.Append(KTestPath); |
4468 file3GB.Append(_L("File3GB.txt")); |
4473 file3GB.Append(_L("File3GB.txt")); |
4469 |
4474 |
4470 TInt r = TheFs.Delete(file4GBMinusOne); |
4475 TInt r = TheFs.Delete(file4GBMinusOne); |
4471 test(r == KErrNone); |
4476 test_KErrNone(r); |
4472 r = TheFs.Delete(file2GBMinusOne); |
4477 r = TheFs.Delete(file2GBMinusOne); |
4473 test(r == KErrNone); |
4478 test_KErrNone(r); |
4474 r = TheFs.Delete(file2GB); |
4479 r = TheFs.Delete(file2GB); |
4475 test(r == KErrNone); |
4480 test_KErrNone(r); |
4476 r = TheFs.Delete(file3GB); |
4481 r = TheFs.Delete(file3GB); |
4477 test(r == KErrNone); |
4482 test_KErrNone(r); |
4478 } |
4483 } |
4479 |
4484 |
4480 /** |
4485 /** |
4481 @SYMTestCaseID PBASE-T_FILE64BIT-0788 |
4486 @SYMTestCaseID PBASE-T_FILE64BIT-0788 |
4482 @SYMTestPriority High |
4487 @SYMTestPriority High |
4519 RFile64 file64; |
4524 RFile64 file64; |
4520 TInt64 sizeK3GB = K3GB; |
4525 TInt64 sizeK3GB = K3GB; |
4521 |
4526 |
4522 test.Next(_L("Open test file and get the file size using RFile64::Size() and set the file handle to TFileText object\n")); |
4527 test.Next(_L("Open test file and get the file size using RFile64::Size() and set the file handle to TFileText object\n")); |
4523 r = file64.Replace(TheFs,fileName,EFileRead|EFileWrite); |
4528 r = file64.Replace(TheFs,fileName,EFileRead|EFileWrite); |
4524 test(r == KErrNone); |
4529 test_KErrNone(r); |
4525 r = file64.SetSize(sizeK3GB); |
4530 r = file64.SetSize(sizeK3GB); |
4526 test(r == KErrNone); |
4531 test_KErrNone(r); |
4527 TFileText fileText; |
4532 TFileText fileText; |
4528 fileText.Set(file64); |
4533 fileText.Set(file64); |
4529 |
4534 |
4530 test.Next(_L("Seek to the file end using TFileText::Seek()\n")); |
4535 test.Next(_L("Seek to the file end using TFileText::Seek()\n")); |
4531 r = fileText.Seek(ESeekEnd); |
4536 r = fileText.Seek(ESeekEnd); |
4532 test(r == KErrNone); |
4537 test_KErrNone(r); |
4533 |
4538 |
4534 test.Next(_L("Get current file position using RFile64::Seek() and verify it is at file end.\n")); |
4539 test.Next(_L("Get current file position using RFile64::Seek() and verify it is at file end.\n")); |
4535 TInt64 pos = 0; |
4540 TInt64 pos = 0; |
4536 r = file64.Seek(ESeekCurrent, pos); |
4541 r = file64.Seek(ESeekCurrent, pos); |
4537 test(r == KErrNone); |
4542 test_KErrNone(r); |
4538 test(pos == sizeK3GB); |
4543 test(pos == sizeK3GB); |
4539 |
4544 |
4540 test.Next(_L("Write data to the file using RFile64::Write\n")); |
4545 test.Next(_L("Write data to the file using RFile64::Write\n")); |
4541 HBufC* record = HBufC::NewL(10); |
4546 HBufC* record = HBufC::NewL(10); |
4542 record->Des().SetLength(10); |
4547 record->Des().SetLength(10); |
4543 record->Des().Fill('A'); |
4548 record->Des().Fill('A'); |
4544 TPtrC8 bufPtr; |
4549 TPtrC8 bufPtr; |
4545 bufPtr.Set((TUint8*)record->Ptr(),record->Size()); // Size() returns length in bytes |
4550 bufPtr.Set((TUint8*)record->Ptr(),record->Size()); // Size() returns length in bytes |
4546 r = file64.Write(pos,bufPtr); |
4551 r = file64.Write(pos,bufPtr); |
4547 test(r == KErrNone); |
4552 test_KErrNone(r); |
4548 |
4553 |
4549 test.Next(_L("Read data using TFileText::Read\n")); |
4554 test.Next(_L("Read data using TFileText::Read\n")); |
4550 TBuf<20> fileTextReadBuf; |
4555 TBuf<20> fileTextReadBuf; |
4551 file64.Seek(ESeekStart,pos);//seek to the position where the data has been written |
4556 file64.Seek(ESeekStart,pos);//seek to the position where the data has been written |
4552 r = fileText.Read(fileTextReadBuf); |
4557 r = fileText.Read(fileTextReadBuf); |
4553 test(fileTextReadBuf == _L("AAAAAAAAAA")); |
4558 test(fileTextReadBuf == _L("AAAAAAAAAA")); |
4554 |
4559 |
4555 test.Next(_L("Seek to the file end using TFileText::Seek(ESeekEnd)\n")); |
4560 test.Next(_L("Seek to the file end using TFileText::Seek(ESeekEnd)\n")); |
4556 r = fileText.Seek(ESeekEnd); |
4561 r = fileText.Seek(ESeekEnd); |
4557 test(r == KErrNone); |
4562 test_KErrNone(r); |
4558 |
4563 |
4559 test.Next(_L("Write known data using TFileText::Write\n")); |
4564 test.Next(_L("Write known data using TFileText::Write\n")); |
4560 TBuf<20> fileTextWriteBuf(_L("AAAAAAAAAA")); |
4565 TBuf<20> fileTextWriteBuf(_L("AAAAAAAAAA")); |
4561 pos = 0; |
4566 pos = 0; |
4562 r = file64.Seek(ESeekCurrent,pos); |
4567 r = file64.Seek(ESeekCurrent,pos); |
4563 r = fileText.Write(fileTextWriteBuf); |
4568 r = fileText.Write(fileTextWriteBuf); |
4564 test(r == KErrNone); |
4569 test_KErrNone(r); |
4565 |
4570 |
4566 test.Next(_L("Read the data using RFile64::Read\n")); |
4571 test.Next(_L("Read the data using RFile64::Read\n")); |
4567 TBuf8<20> file64ReadBuf; |
4572 TBuf8<20> file64ReadBuf; |
4568 file64ReadBuf.Zero(); |
4573 file64ReadBuf.Zero(); |
4569 r = file64.Read(pos,file64ReadBuf); |
4574 r = file64.Read(pos,file64ReadBuf); |
4570 r = bufPtr.Compare(file64ReadBuf); |
4575 r = bufPtr.Compare(file64ReadBuf); |
4571 test (r == KErrNone); |
4576 test_KErrNone(r); |
4572 |
4577 |
4573 file64.Close(); |
4578 file64.Close(); |
4574 |
4579 |
4575 r = TheFs.Delete(fileName); |
4580 r = TheFs.Delete(fileName); |
4576 test(r == KErrNone); |
4581 test_KErrNone(r); |
4577 User::Free(record); |
4582 User::Free(record); |
4578 } |
4583 } |
4579 |
4584 |
4580 |
4585 |
4581 /** |
4586 /** |
4744 fileName1.Append(gDriveToTest); |
4749 fileName1.Append(gDriveToTest); |
4745 fileName1.Append(KTestPath); |
4750 fileName1.Append(KTestPath); |
4746 fileName1.Append(_L("File2GB.txt")); |
4751 fileName1.Append(_L("File2GB.txt")); |
4747 RFile64 file; |
4752 RFile64 file; |
4748 TInt r = file.Replace(TheFs, fileName1, EFileWrite); |
4753 TInt r = file.Replace(TheFs, fileName1, EFileWrite); |
4749 test (r == KErrNone); |
4754 test_KErrNone(r); |
4750 file.SetSize(K2GB); |
4755 file.SetSize(K2GB); |
4751 test (r == KErrNone); |
4756 test_KErrNone(r); |
4752 file.Close(); |
4757 file.Close(); |
4753 TestRFs.ReadFileSection(fileName1,0,readBuf,100); |
4758 TestRFs.ReadFileSection(fileName1,0,readBuf,100); |
4754 r = TheFs.Delete(fileName1); |
4759 r = TheFs.Delete(fileName1); |
4755 test (r == KErrNone); |
4760 test_KErrNone(r); |
4756 test.Next(_L("Creating test pattern")); |
4761 test.Next(_L("Creating test pattern")); |
4757 |
4762 |
4758 TBuf8<0x63> writeBuf63; |
4763 TBuf8<0x63> writeBuf63; |
4759 TBuf8<0x63> readBuf63; |
4764 TBuf8<0x63> readBuf63; |
4760 for (TInt count = 0; count < 0x63; count++) |
4765 for (TInt count = 0; count < 0x63; count++) |
5585 TestRFile1.Write(_L8("1234567891")); |
5590 TestRFile1.Write(_L8("1234567891")); |
5586 TestRFile1.Close(); |
5591 TestRFile1.Close(); |
5587 |
5592 |
5588 test.Next(_L("Copy the files from one folder to another using CFileMan::Copy()\n")); |
5593 test.Next(_L("Copy the files from one folder to another using CFileMan::Copy()\n")); |
5589 TInt r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5594 TInt r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5590 test(r == KErrNone || r == KErrTooBig); |
5595 test_Value(r, r == KErrNone || r == KErrTooBig); |
5591 |
5596 |
5592 test.Next(_L("Get the directory entry and find how many files are copied\n")); |
5597 test.Next(_L("Get the directory entry and find how many files are copied\n")); |
5593 // check SMALL and LARGE files have been copied |
5598 // check SMALL and LARGE files have been copied |
5594 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5599 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5595 test (r == KErrNone); |
5600 test_KErrNone(r); |
5596 r = dir.Read(entryArray); |
5601 r = dir.Read(entryArray); |
5597 test (r == KErrEof); |
5602 test_Value(r, r == KErrEof); |
5598 test(entryArray.Count() == gFilesInDirectory); |
5603 test(entryArray.Count() == gFilesInDirectory); |
5599 dir.Close(); |
5604 dir.Close(); |
5600 |
5605 |
5601 // then delete the new directory |
5606 // then delete the new directory |
5602 r = fileMan->Delete(filePathNew); |
5607 r = fileMan->Delete(filePathNew); |
5603 test(r == KErrNone); |
5608 test_KErrNone(r); |
5604 |
5609 |
5605 test.Next(_L("Set file man observer\n")); |
5610 test.Next(_L("Set file man observer\n")); |
5606 // attempt to copy to new directory again - this time with an observer |
5611 // attempt to copy to new directory again - this time with an observer |
5607 fileMan->SetObserver(observer); |
5612 fileMan->SetObserver(observer); |
5608 |
5613 |
5609 test.Next(_L("Copy the files from one folder to another, source folder has 3 small files and a large file\n")); |
5614 test.Next(_L("Copy the files from one folder to another, source folder has 3 small files and a large file\n")); |
5610 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5615 r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5611 test(r == KErrNone || r == KErrTooBig); |
5616 test_Value(r, r == KErrNone || r == KErrTooBig); |
5612 |
5617 |
5613 test.Next(_L("Check observer for number of successful copy and failed copy\n")); |
5618 test.Next(_L("Check observer for number of successful copy and failed copy\n")); |
5614 // test that 3 small files and 1 large file were copied |
5619 // test that 3 small files and 1 large file were copied |
5615 // (For 8 GB disk, the 4GB file is missing) |
5620 // (For 8 GB disk, the 4GB file is missing) |
5616 test(observer->iNotifyEndedSuccesses == gFilesInDirectory); |
5621 test(observer->iNotifyEndedSuccesses == gFilesInDirectory); |
5617 test(observer->iNotifyEndedFailures == 0); |
5622 test(observer->iNotifyEndedFailures == 0); |
5618 |
5623 |
5619 test.Next(_L("Get the directory entry and find how many files copied\n")); |
5624 test.Next(_L("Get the directory entry and find how many files copied\n")); |
5620 // check SMALL files have been copied |
5625 // check SMALL files have been copied |
5621 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5626 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5622 test (r == KErrNone); |
5627 test_KErrNone(r); |
5623 r = dir.Read(entryArray); |
5628 r = dir.Read(entryArray); |
5624 test (r == KErrEof); |
5629 test_Value(r, r == KErrEof); |
5625 |
5630 |
5626 test(entryArray.Count() == gFilesInDirectory); |
5631 test(entryArray.Count() == gFilesInDirectory); |
5627 dir.Close(); |
5632 dir.Close(); |
5628 |
5633 |
5629 // then delete the new directory |
5634 // then delete the new directory |
5630 r = fileMan->Delete(filePathNew); |
5635 r = fileMan->Delete(filePathNew); |
5631 test(r == KErrNone); |
5636 test_KErrNone(r); |
5632 |
5637 |
5633 delete observer; |
5638 delete observer; |
5634 delete fileMan; |
5639 delete fileMan; |
5635 |
5640 |
5636 r = TheFs.Delete(fileSmall1); |
5641 r = TheFs.Delete(fileSmall1); |
5637 test(r == KErrNone); |
5642 test_KErrNone(r); |
5638 r = TheFs.Delete(fileSmall2); |
5643 r = TheFs.Delete(fileSmall2); |
5639 test(r == KErrNone); |
5644 test_KErrNone(r); |
5640 r = TheFs.Delete(fileSmall3); |
5645 r = TheFs.Delete(fileSmall3); |
5641 test(r == KErrNone); |
5646 test_KErrNone(r); |
5642 r = TheFs.Delete(fileLarge1); |
5647 r = TheFs.Delete(fileLarge1); |
5643 test(r == KErrNone); |
5648 test_KErrNone(r); |
5644 } |
5649 } |
5645 /** |
5650 /** |
5646 @SYMTestCaseID PBASE-T_FILE64BIT-2355 |
5651 @SYMTestCaseID PBASE-T_FILE64BIT-2355 |
5647 @SYMTestPriority High |
5652 @SYMTestPriority High |
5648 @SYMTestRequirement REQ9532 |
5653 @SYMTestRequirement REQ9532 |
5716 TestRFile1.Close(); |
5721 TestRFile1.Close(); |
5717 |
5722 |
5718 |
5723 |
5719 // move to new directory |
5724 // move to new directory |
5720 TInt r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5725 TInt r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite); |
5721 test(r == KErrNone || r == KErrTooBig); |
5726 test_Value(r, r == KErrNone || r == KErrTooBig); |
5722 |
5727 |
5723 // check SMALL and LARGE files have been moved |
5728 // check SMALL and LARGE files have been moved |
5724 RDir dir; |
5729 RDir dir; |
5725 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5730 r = dir.Open(TheFs, filePathNew, KEntryAttNormal); |
5726 test (r == KErrNone); |
5731 test_KErrNone(r); |
5727 TEntryArray entryArray; |
5732 TEntryArray entryArray; |
5728 r = dir.Read(entryArray); |
5733 r = dir.Read(entryArray); |
5729 test (r == KErrEof); |
5734 test_Value(r, r == KErrEof); |
5730 test(entryArray.Count() == 4); |
5735 test(entryArray.Count() == 4); |
5731 dir.Close(); |
5736 dir.Close(); |
5732 |
5737 |
5733 // then delete the new directory |
5738 // then delete the new directory |
5734 r = fileMan->Delete(filePathNew); |
5739 r = fileMan->Delete(filePathNew); |
5735 test(r == KErrNone); |
5740 test_KErrNone(r); |
5736 delete fileMan; |
5741 delete fileMan; |
5737 } |
5742 } |
5738 |
5743 |
5739 |
5744 |
5740 static void TestOpenFiles() |
5745 static void TestOpenFiles() |
5900 TRequestStatus status1=KRequestPending; |
5905 TRequestStatus status1=KRequestPending; |
5901 TRequestStatus status2=KRequestPending; |
5906 TRequestStatus status2=KRequestPending; |
5902 |
5907 |
5903 // If a zero length is passed into the Write function, KErrNone should be returned. |
5908 // If a zero length is passed into the Write function, KErrNone should be returned. |
5904 r=aFile.Write(aPos,gBuf); |
5909 r=aFile.Write(aPos,gBuf); |
5905 test(r==KErrNone); |
5910 test_KErrNone(r); |
5906 |
5911 |
5907 // If the length is a negative, KErrArgument should be returned. |
5912 // If the length is a negative, KErrArgument should be returned. |
5908 r=aFile.Write(aPos,gBuf,aLen); |
5913 r=aFile.Write(aPos,gBuf,aLen); |
5909 test(r==KErrArgument); |
5914 test_Value(r, r == KErrArgument); |
5910 |
5915 |
5911 // Test the asynchronous requests |
5916 // Test the asynchronous requests |
5912 aFile.Write(aPos,gBuf,aLen,status1); |
5917 aFile.Write(aPos,gBuf,aLen,status1); |
5913 aFile.Write(aPos,gBuf,aLen,status2); |
5918 aFile.Write(aPos,gBuf,aLen,status2); |
5914 User::WaitForRequest(status1); |
5919 User::WaitForRequest(status1); |
5954 //-- decide if we need to test files >= 4G. As soon as there is no appropriate API yet, this way is dodgy.. |
5959 //-- decide if we need to test files >= 4G. As soon as there is no appropriate API yet, this way is dodgy.. |
5955 if(Is_Fat(TheFs, aDrive)) |
5960 if(Is_Fat(TheFs, aDrive)) |
5956 { |
5961 { |
5957 KFileSizeMaxLargerThan4GBMinusOne = EFalse; //-- FAT doesn't support >= 4G files |
5962 KFileSizeMaxLargerThan4GBMinusOne = EFalse; //-- FAT doesn't support >= 4G files |
5958 } |
5963 } |
5959 else if(Is_Win32(TheFs, aDrive)) |
5964 else if(Is_SimulatedSystemDrive(TheFs, aDrive)) |
5960 {//-- this is the emulator's windows drive. The maximal file size depends on the Windows FS used for this drive. |
5965 { |
5961 //-- if it is NTFS, files >= 4G are supported. |
5966 //-- This is the emulator's windows drive or PlatSim's HVFS. |
|
5967 //-- The maximal file size depends on the Windows FS used for this drive. |
|
5968 //-- If it is NTFS, files >= 4G are supported. |
5962 r = CreateEmptyFile(TheFs, _L("\\test_file"), K4GB); |
5969 r = CreateEmptyFile(TheFs, _L("\\test_file"), K4GB); |
5963 |
5970 |
5964 KFileSizeMaxLargerThan4GBMinusOne = (r == KErrNone); |
5971 KFileSizeMaxLargerThan4GBMinusOne = (r == KErrNone); |
5965 r = TheFs.Delete(_L("\\test_file")); |
5972 r = TheFs.Delete(_L("\\test_file")); |
5966 |
5973 |