sl@0
|
1 |
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test\server\t_rename.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include "t_server.h"
|
sl@0
|
21 |
#include "f32_test_utils.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
using namespace F32_Test_Utils;
|
sl@0
|
24 |
TInt gDriveNum = -1;
|
sl@0
|
25 |
|
sl@0
|
26 |
RTest test(_L("T_RENAME"));
|
sl@0
|
27 |
|
sl@0
|
28 |
TBuf8<26> alphaBuffer=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
sl@0
|
29 |
TPtr8 alphaPtr((TText8*)alphaBuffer.Ptr(),alphaBuffer.Size(),alphaBuffer.Size());
|
sl@0
|
30 |
|
sl@0
|
31 |
TBuf8<17> BeckBuffer=_L8("A Devil's Haircut");
|
sl@0
|
32 |
TPtr8 BeckPtr((TText8*)BeckBuffer.Ptr(),BeckBuffer.Size(),BeckBuffer.Size());
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
static void CreateTestFiles()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
test.Next(_L("Create test files"));
|
sl@0
|
38 |
TInt r=TheFs.MkDir(_L("\\F32-TST\\"));
|
sl@0
|
39 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
40 |
|
sl@0
|
41 |
RFile file;
|
sl@0
|
42 |
|
sl@0
|
43 |
// Create \\SessionPath\\testfile
|
sl@0
|
44 |
r=file.Replace(TheFs,_L("\\F32-TST\\testfile"),EFileRead|EFileWrite);
|
sl@0
|
45 |
test(r==KErrNone);
|
sl@0
|
46 |
r=file.Write(BeckPtr);
|
sl@0
|
47 |
test(r==KErrNone);
|
sl@0
|
48 |
file.Close();
|
sl@0
|
49 |
|
sl@0
|
50 |
// Create \\SessionPath\\rfsfile
|
sl@0
|
51 |
r=file.Replace(TheFs,_L("\\F32-TST\\rfsfile"),EFileRead|EFileWrite);
|
sl@0
|
52 |
test(r==KErrNone);
|
sl@0
|
53 |
r=file.Write(BeckPtr);
|
sl@0
|
54 |
test(r==KErrNone);
|
sl@0
|
55 |
file.Close();
|
sl@0
|
56 |
|
sl@0
|
57 |
// Create \\SessionPath\\eikfile
|
sl@0
|
58 |
r=file.Replace(TheFs,_L("\\F32-TST\\eikfile"),EFileRead|EFileWrite);
|
sl@0
|
59 |
test(r==KErrNone);
|
sl@0
|
60 |
r=file.Write(BeckPtr);
|
sl@0
|
61 |
test(r==KErrNone);
|
sl@0
|
62 |
file.Close();
|
sl@0
|
63 |
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
static TInt CountFiles(TPtrC aDirectory, TPtrC aFileName)
|
sl@0
|
67 |
//
|
sl@0
|
68 |
// Return the number of files of aFileName found in aDirectory
|
sl@0
|
69 |
//
|
sl@0
|
70 |
{
|
sl@0
|
71 |
|
sl@0
|
72 |
RDir dir;
|
sl@0
|
73 |
TFileName sessionPath;
|
sl@0
|
74 |
TInt r=TheFs.SessionPath(sessionPath);
|
sl@0
|
75 |
test(r==KErrNone);
|
sl@0
|
76 |
TFileName path=_L("?:");
|
sl@0
|
77 |
path[0]=sessionPath[0];
|
sl@0
|
78 |
path+=aDirectory;
|
sl@0
|
79 |
if (path[path.Length()-1]==KPathDelimiter)
|
sl@0
|
80 |
path.Append('*');
|
sl@0
|
81 |
else
|
sl@0
|
82 |
path.Append(_L("\\*"));
|
sl@0
|
83 |
|
sl@0
|
84 |
r=dir.Open(TheFs,path,KEntryAttMaskSupported);
|
sl@0
|
85 |
test(r==KErrNone);
|
sl@0
|
86 |
|
sl@0
|
87 |
CDir* anEntryList;
|
sl@0
|
88 |
r=TheFs.GetDir(path,KEntryAttMaskSupported,ESortByName,anEntryList);
|
sl@0
|
89 |
test(r==KErrNone);
|
sl@0
|
90 |
|
sl@0
|
91 |
// Sets the new length of path to the position of the last path delimiter +1
|
sl@0
|
92 |
path.SetLength(path.LocateReverse(KPathDelimiter)+1);
|
sl@0
|
93 |
TInt fileCount=0;
|
sl@0
|
94 |
TEntry entry;
|
sl@0
|
95 |
|
sl@0
|
96 |
TInt count=anEntryList->Count();
|
sl@0
|
97 |
for (TInt j=0;j<count;j++)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
entry=anEntryList->operator[](j);
|
sl@0
|
100 |
if ((entry.iName)==(aFileName))
|
sl@0
|
101 |
fileCount++;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
dir.Close();
|
sl@0
|
105 |
delete anEntryList;
|
sl@0
|
106 |
return(fileCount);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
static void TestRFileRename()
|
sl@0
|
110 |
//
|
sl@0
|
111 |
// Test RFile::Rename() function
|
sl@0
|
112 |
//
|
sl@0
|
113 |
{
|
sl@0
|
114 |
test.Next(_L("Rename file with DOS compatible name using RFile function"));
|
sl@0
|
115 |
TInt r;
|
sl@0
|
116 |
RFile file;
|
sl@0
|
117 |
|
sl@0
|
118 |
r=file.Open(TheFs,_L("\\F32-TST\\testfile"),EFileRead|EFileWrite);
|
sl@0
|
119 |
test(r==KErrNone);
|
sl@0
|
120 |
|
sl@0
|
121 |
r=file.Rename(_L("\\F32-TST\\TESTFILE"));
|
sl@0
|
122 |
test(r==KErrNone);
|
sl@0
|
123 |
|
sl@0
|
124 |
file.Close();
|
sl@0
|
125 |
|
sl@0
|
126 |
test.Next(_L("Write in some data"));
|
sl@0
|
127 |
r=file.Open(TheFs,_L("\\F32-TST\\TESTFILE"),EFileRead|EFileWrite);
|
sl@0
|
128 |
test(r==KErrNone);
|
sl@0
|
129 |
|
sl@0
|
130 |
r=file.Write(alphaPtr);
|
sl@0
|
131 |
test(r==KErrNone);
|
sl@0
|
132 |
|
sl@0
|
133 |
file.Close();
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
|
sl@0
|
137 |
static void TestRFsRename()
|
sl@0
|
138 |
//
|
sl@0
|
139 |
// Test RFs::Rename() function
|
sl@0
|
140 |
//
|
sl@0
|
141 |
{
|
sl@0
|
142 |
test.Next(_L("Rename file with DOS compatible name using RFs function"));
|
sl@0
|
143 |
TInt r;
|
sl@0
|
144 |
|
sl@0
|
145 |
r=TheFs.Rename(_L("\\F32-TST\\rfsfile"),_L("\\F32-TST\\RFSFILE"));
|
sl@0
|
146 |
test(r==KErrNone);
|
sl@0
|
147 |
|
sl@0
|
148 |
RFile file;
|
sl@0
|
149 |
test.Next(_L("Write in some data"));
|
sl@0
|
150 |
r=file.Open(TheFs,_L("\\F32-TST\\RFSFILE"),EFileRead|EFileWrite);
|
sl@0
|
151 |
test(r==KErrNone);
|
sl@0
|
152 |
|
sl@0
|
153 |
r=file.Write(alphaPtr);
|
sl@0
|
154 |
test(r==KErrNone);
|
sl@0
|
155 |
|
sl@0
|
156 |
file.Close();
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
static void TestEikonRename()
|
sl@0
|
160 |
//
|
sl@0
|
161 |
// Test EIKON style rename by creating a new file, and copying old data into new file
|
sl@0
|
162 |
//
|
sl@0
|
163 |
{
|
sl@0
|
164 |
test.Next(_L("Rename file with DOS compatible name simulating EIKON"));
|
sl@0
|
165 |
TInt r;
|
sl@0
|
166 |
RFile file;
|
sl@0
|
167 |
|
sl@0
|
168 |
test.Next(_L("Create a new file with DOS compatible equivalent name"));
|
sl@0
|
169 |
r=file.Create(TheFs,_L("\\F32-TST\\EIKFILE"),EFileRead|EFileWrite);
|
sl@0
|
170 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
171 |
file.Close();
|
sl@0
|
172 |
|
sl@0
|
173 |
test.Next(_L("Copy data from original file into new file"));
|
sl@0
|
174 |
r=TheFs.Replace(_L("\\F32-TST\\eikfile"),_L("\\F32-TST\\EIKFILE"));
|
sl@0
|
175 |
test(r==KErrNone);
|
sl@0
|
176 |
|
sl@0
|
177 |
test.Next(_L("Open the new file and write into it"));
|
sl@0
|
178 |
r=file.Open(TheFs,_L("\\F32-TST\\EIKFILE"),EFileRead|EFileWrite);
|
sl@0
|
179 |
test(r==KErrNone);
|
sl@0
|
180 |
|
sl@0
|
181 |
r=file.Write(alphaPtr);
|
sl@0
|
182 |
test(r==KErrNone);
|
sl@0
|
183 |
|
sl@0
|
184 |
file.Close();
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
static void TestReplaceAndRename()
|
sl@0
|
189 |
//
|
sl@0
|
190 |
// Tests the bug which allows 2 files of the same name to be created has been fixed
|
sl@0
|
191 |
//
|
sl@0
|
192 |
{
|
sl@0
|
193 |
TInt r;
|
sl@0
|
194 |
RFile file;
|
sl@0
|
195 |
|
sl@0
|
196 |
// *************************************************************************
|
sl@0
|
197 |
// First test with a non DOS compatible name renamed to a DOS compatible name
|
sl@0
|
198 |
test.Next(_L("Rename test to TEST and replace temp with TEST"));
|
sl@0
|
199 |
r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite);
|
sl@0
|
200 |
test(r==KErrNone);
|
sl@0
|
201 |
r=file.Write(BeckPtr);
|
sl@0
|
202 |
test(r==KErrNone);
|
sl@0
|
203 |
file.Close();
|
sl@0
|
204 |
|
sl@0
|
205 |
r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST"));
|
sl@0
|
206 |
test(r==KErrNone);
|
sl@0
|
207 |
r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite);
|
sl@0
|
208 |
test(r==KErrNone);
|
sl@0
|
209 |
r=file.Write(alphaPtr);
|
sl@0
|
210 |
test(r==KErrNone);
|
sl@0
|
211 |
file.Close();
|
sl@0
|
212 |
|
sl@0
|
213 |
// Replace(oldName, newName)
|
sl@0
|
214 |
// Copy oldName to newName (ie temp to TEST)
|
sl@0
|
215 |
// If TEST does not exist, it is created and then temp's attributes etc are copied into it
|
sl@0
|
216 |
// then temp is deleted. If it does exist, it must be closed
|
sl@0
|
217 |
// The bug created a second file of the same name
|
sl@0
|
218 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST"));
|
sl@0
|
219 |
test(r==KErrNone);
|
sl@0
|
220 |
|
sl@0
|
221 |
// Check that there's only one file named TEST
|
sl@0
|
222 |
TInt fileCount=0;
|
sl@0
|
223 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST"));
|
sl@0
|
224 |
test(fileCount==1);
|
sl@0
|
225 |
r=TheFs.Delete(_L("\\F32-TST\\TEST"));
|
sl@0
|
226 |
test(r==KErrNone);
|
sl@0
|
227 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST"));
|
sl@0
|
228 |
test(fileCount==0);
|
sl@0
|
229 |
test(r==KErrNone);
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
//*****************************************************
|
sl@0
|
233 |
// The same test but with different source directories
|
sl@0
|
234 |
test.Next(_L("Rename test to and replace \\SYSTEM\\temp with TEST"));
|
sl@0
|
235 |
r=file.Replace(TheFs,_L("\\F32-TST\\test"),EFileWrite);
|
sl@0
|
236 |
test(r==KErrNone);
|
sl@0
|
237 |
r=file.Write(BeckPtr);
|
sl@0
|
238 |
test(r==KErrNone);
|
sl@0
|
239 |
file.Close();
|
sl@0
|
240 |
|
sl@0
|
241 |
r=TheFs.Rename(_L("\\F32-TST\\test"),_L("\\F32-TST\\TEST"));
|
sl@0
|
242 |
test(r==KErrNone);
|
sl@0
|
243 |
r=file.Replace(TheFs,_L("\\F32-TST\\SYSTEM\\temp"),EFileWrite);
|
sl@0
|
244 |
test(r==KErrNone);
|
sl@0
|
245 |
r=file.Write(alphaPtr);
|
sl@0
|
246 |
test(r==KErrNone);
|
sl@0
|
247 |
file.Close();
|
sl@0
|
248 |
|
sl@0
|
249 |
// The bug created a second file of the same name
|
sl@0
|
250 |
r=TheFs.Replace(_L("\\F32-TST\\SYSTEM\\temp"),_L("\\F32-TST\\TEST"));
|
sl@0
|
251 |
test(r==KErrNone);
|
sl@0
|
252 |
|
sl@0
|
253 |
fileCount=0;
|
sl@0
|
254 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST"));
|
sl@0
|
255 |
test(fileCount==1);
|
sl@0
|
256 |
r=TheFs.Delete(_L("\\F32-TST\\TEST"));
|
sl@0
|
257 |
test(r==KErrNone);
|
sl@0
|
258 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST"));
|
sl@0
|
259 |
test(fileCount==0);
|
sl@0
|
260 |
// Test that system directory is now empty
|
sl@0
|
261 |
fileCount=0;
|
sl@0
|
262 |
fileCount=CountFiles(_L("\\F32-TST\\SYSTEM\\"),_L("temp"));
|
sl@0
|
263 |
test(fileCount==0);
|
sl@0
|
264 |
test(r==KErrNone);
|
sl@0
|
265 |
|
sl@0
|
266 |
// *************************************************************************
|
sl@0
|
267 |
// Test with a DOS compatible name renamed to a different DOS compatible name
|
sl@0
|
268 |
test.Next(_L("Rename little to BIG and replace temp with BIG"));
|
sl@0
|
269 |
r=file.Replace(TheFs,_L("\\F32-TST\\little"),EFileWrite);
|
sl@0
|
270 |
test(r==KErrNone);
|
sl@0
|
271 |
r=file.Write(BeckPtr);
|
sl@0
|
272 |
test(r==KErrNone);
|
sl@0
|
273 |
file.Close();
|
sl@0
|
274 |
|
sl@0
|
275 |
// Test a long path (>250 chrs)
|
sl@0
|
276 |
r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\0495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\PLATTEST\\FileStore\\TestData\\20495_Folder\\middle.gif"));
|
sl@0
|
277 |
test(r==KErrBadName);
|
sl@0
|
278 |
|
sl@0
|
279 |
r=TheFs.Rename(_L("\\F32-TST\\little"),_L("\\F32-TST\\BIG"));
|
sl@0
|
280 |
test(r==KErrNone);
|
sl@0
|
281 |
r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite);
|
sl@0
|
282 |
test(r==KErrNone);
|
sl@0
|
283 |
r=file.Write(alphaPtr);
|
sl@0
|
284 |
test(r==KErrNone);
|
sl@0
|
285 |
file.Close();
|
sl@0
|
286 |
|
sl@0
|
287 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\BIG"));
|
sl@0
|
288 |
test(r==KErrNone);
|
sl@0
|
289 |
|
sl@0
|
290 |
fileCount=0;
|
sl@0
|
291 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG"));
|
sl@0
|
292 |
test(fileCount==1);
|
sl@0
|
293 |
r=TheFs.Delete(_L("\\F32-TST\\BIG"));
|
sl@0
|
294 |
test(r==KErrNone);
|
sl@0
|
295 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("BIG"));
|
sl@0
|
296 |
test(fileCount==0);
|
sl@0
|
297 |
test(r==KErrNone);
|
sl@0
|
298 |
|
sl@0
|
299 |
// ***********************************
|
sl@0
|
300 |
// Test with a non-DOS compatible name
|
sl@0
|
301 |
test.Next(_L("Rename veryLongFileName to VERYLONGFILENAME"));
|
sl@0
|
302 |
r=file.Replace(TheFs,_L("\\F32-TST\\veryLongFileName"),EFileWrite);
|
sl@0
|
303 |
test(r==KErrNone);
|
sl@0
|
304 |
r=file.Write(BeckPtr);
|
sl@0
|
305 |
test(r==KErrNone);
|
sl@0
|
306 |
file.Close();
|
sl@0
|
307 |
|
sl@0
|
308 |
r=TheFs.Rename(_L("\\F32-TST\\veryLongFileName"),_L("\\F32-TST\\VERYLONGFILENAME"));
|
sl@0
|
309 |
test(r==KErrNone);
|
sl@0
|
310 |
r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite);
|
sl@0
|
311 |
test(r==KErrNone);
|
sl@0
|
312 |
r=file.Write(alphaPtr);
|
sl@0
|
313 |
test(r==KErrNone);
|
sl@0
|
314 |
file.Close();
|
sl@0
|
315 |
|
sl@0
|
316 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\VERYLONGFILENAME"));
|
sl@0
|
317 |
test(r==KErrNone);
|
sl@0
|
318 |
|
sl@0
|
319 |
fileCount=0;
|
sl@0
|
320 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME"));
|
sl@0
|
321 |
test(fileCount==1);
|
sl@0
|
322 |
r=TheFs.Delete(_L("\\F32-TST\\VERYLONGFILENAME"));
|
sl@0
|
323 |
test(r==KErrNone);
|
sl@0
|
324 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("VERYLONGFILENAME"));
|
sl@0
|
325 |
test(fileCount==0);
|
sl@0
|
326 |
test(r==KErrNone);
|
sl@0
|
327 |
|
sl@0
|
328 |
// *******************************
|
sl@0
|
329 |
// Test with a DOS compatible name
|
sl@0
|
330 |
test.Next(_L("Rename FILE to FILE and replace temp with FILE"));
|
sl@0
|
331 |
r=file.Replace(TheFs,_L("\\F32-TST\\FILE"),EFileWrite);
|
sl@0
|
332 |
test(r==KErrNone);
|
sl@0
|
333 |
r=file.Write(BeckPtr);
|
sl@0
|
334 |
test(r==KErrNone);
|
sl@0
|
335 |
file.Close();
|
sl@0
|
336 |
|
sl@0
|
337 |
r=TheFs.Rename(_L("\\F32-TST\\FILE"),_L("\\F32-TST\\FILE"));
|
sl@0
|
338 |
test(r==KErrNone);
|
sl@0
|
339 |
r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite);
|
sl@0
|
340 |
test(r==KErrNone);
|
sl@0
|
341 |
r=file.Write(alphaPtr);
|
sl@0
|
342 |
test(r==KErrNone);
|
sl@0
|
343 |
file.Close();
|
sl@0
|
344 |
|
sl@0
|
345 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\FILE"));
|
sl@0
|
346 |
test(r==KErrNone);
|
sl@0
|
347 |
|
sl@0
|
348 |
fileCount=0;
|
sl@0
|
349 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE"));
|
sl@0
|
350 |
test(fileCount==1);
|
sl@0
|
351 |
r=TheFs.Delete(_L("\\F32-TST\\FILE"));
|
sl@0
|
352 |
test(r==KErrNone);
|
sl@0
|
353 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("FILE"));
|
sl@0
|
354 |
test(fileCount==0);
|
sl@0
|
355 |
test(r==KErrNone);
|
sl@0
|
356 |
|
sl@0
|
357 |
// **************************************************
|
sl@0
|
358 |
// Test with a DOS compatible name which is kept open
|
sl@0
|
359 |
test.Next(_L("Rename test1 to TEST1 and replace temp1 with TEST1 while it's open"));
|
sl@0
|
360 |
r=file.Replace(TheFs,_L("\\F32-TST\\test1"),EFileWrite);
|
sl@0
|
361 |
test(r==KErrNone);
|
sl@0
|
362 |
r=file.Write(BeckPtr);
|
sl@0
|
363 |
test(r==KErrNone);
|
sl@0
|
364 |
file.Close();
|
sl@0
|
365 |
|
sl@0
|
366 |
r=TheFs.Rename(_L("\\F32-TST\\test1"),_L("\\F32-TST\\TEST1"));
|
sl@0
|
367 |
test(r==KErrNone);
|
sl@0
|
368 |
|
sl@0
|
369 |
// Try with the file open
|
sl@0
|
370 |
RFile openFile;
|
sl@0
|
371 |
r=openFile.Open(TheFs,_L("\\F32-TST\\TEST1"),EFileRead|EFileWrite);
|
sl@0
|
372 |
test(r==KErrNone);
|
sl@0
|
373 |
|
sl@0
|
374 |
r=file.Replace(TheFs,_L("\\F32-TST\\temp"),EFileWrite);
|
sl@0
|
375 |
test(r==KErrNone);
|
sl@0
|
376 |
r=file.Write(alphaPtr);
|
sl@0
|
377 |
test(r==KErrNone);
|
sl@0
|
378 |
file.Close();
|
sl@0
|
379 |
|
sl@0
|
380 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1"));
|
sl@0
|
381 |
test(r==KErrInUse); // Fails as it should! But not intuitive bearing in mind the other bug...
|
sl@0
|
382 |
|
sl@0
|
383 |
openFile.Close();
|
sl@0
|
384 |
|
sl@0
|
385 |
r=TheFs.Replace(_L("\\F32-TST\\temp"),_L("\\F32-TST\\TEST1"));
|
sl@0
|
386 |
test(r==KErrNone);
|
sl@0
|
387 |
|
sl@0
|
388 |
fileCount=0;
|
sl@0
|
389 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1"));
|
sl@0
|
390 |
test(fileCount==1);
|
sl@0
|
391 |
r=TheFs.Delete(_L("\\F32-TST\\TEST1"));
|
sl@0
|
392 |
test(r==KErrNone);
|
sl@0
|
393 |
fileCount=CountFiles(_L("\\F32-TST\\"),_L("TEST1"));
|
sl@0
|
394 |
test(fileCount==0);
|
sl@0
|
395 |
test(r==KErrNone);
|
sl@0
|
396 |
|
sl@0
|
397 |
}
|
sl@0
|
398 |
|
sl@0
|
399 |
|
sl@0
|
400 |
void CallTestsL(void)
|
sl@0
|
401 |
{
|
sl@0
|
402 |
|
sl@0
|
403 |
test.Title();
|
sl@0
|
404 |
test.Start(_L("Testing rename"));
|
sl@0
|
405 |
|
sl@0
|
406 |
//-- set up console output
|
sl@0
|
407 |
F32_Test_Utils::SetConsole(test.Console());
|
sl@0
|
408 |
|
sl@0
|
409 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
|
sl@0
|
410 |
test(nRes==KErrNone);
|
sl@0
|
411 |
|
sl@0
|
412 |
PrintDrvInfo(TheFs, gDriveNum);
|
sl@0
|
413 |
|
sl@0
|
414 |
if(!Is_Win32(TheFs, gDriveNum))
|
sl@0
|
415 |
{
|
sl@0
|
416 |
nRes = FormatDrive(TheFs, gDriveNum, ETrue);
|
sl@0
|
417 |
test(nRes==KErrNone);
|
sl@0
|
418 |
}
|
sl@0
|
419 |
|
sl@0
|
420 |
|
sl@0
|
421 |
MakeDir(_L("\\F32-TST\\SYSTEM\\"));
|
sl@0
|
422 |
CreateTestFiles();
|
sl@0
|
423 |
TestRFsRename();
|
sl@0
|
424 |
TestRFileRename();
|
sl@0
|
425 |
TestEikonRename();
|
sl@0
|
426 |
TestReplaceAndRename();
|
sl@0
|
427 |
|
sl@0
|
428 |
if(!Is_Win32(TheFs, gDriveNum))
|
sl@0
|
429 |
{
|
sl@0
|
430 |
nRes = FormatDrive(TheFs, gDriveNum, ETrue);
|
sl@0
|
431 |
test(nRes==KErrNone);
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
test.End();
|
sl@0
|
435 |
test.Close();
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|