sl@0
|
1 |
// Copyright (c) 1995-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <f32file.h>
|
sl@0
|
17 |
#include <e32test.h>
|
sl@0
|
18 |
#include "t_server.h"
|
sl@0
|
19 |
#include "t_chlffs.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
GLDEF_D RTest test(_L("T_NMBS"));
|
sl@0
|
22 |
|
sl@0
|
23 |
LOCAL_C void testMkDirRmDir()
|
sl@0
|
24 |
//
|
sl@0
|
25 |
// Test the MkDir functions.
|
sl@0
|
26 |
//
|
sl@0
|
27 |
{
|
sl@0
|
28 |
|
sl@0
|
29 |
test.Next(_L("Test MkDir"));
|
sl@0
|
30 |
|
sl@0
|
31 |
TInt r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
32 |
test(r==KErrNone);
|
sl@0
|
33 |
r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
34 |
test(r==KErrPathNotFound);
|
sl@0
|
35 |
r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
36 |
test(r==KErrNone);
|
sl@0
|
37 |
r=TheFs.MkDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
38 |
test(r==KErrNone);
|
sl@0
|
39 |
|
sl@0
|
40 |
test.Next(_L("Test RmDir 1.0"));
|
sl@0
|
41 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
42 |
test(r==KErrNone);
|
sl@0
|
43 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
44 |
test(r==KErrNone);
|
sl@0
|
45 |
|
sl@0
|
46 |
test.Next(_L("Test MkDirAll 1.0"));
|
sl@0
|
47 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
48 |
test(r==KErrNone);
|
sl@0
|
49 |
|
sl@0
|
50 |
test.Next(_L("Test RmDir 2.0"));
|
sl@0
|
51 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
52 |
test(r==KErrNone);
|
sl@0
|
53 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
54 |
test(r==KErrNone);
|
sl@0
|
55 |
|
sl@0
|
56 |
test.Next(_L("Test MkDirAll 2.0"));
|
sl@0
|
57 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
58 |
test(r==KErrNone);
|
sl@0
|
59 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
60 |
test(r==KErrNone);
|
sl@0
|
61 |
|
sl@0
|
62 |
test.Next(_L("Test RmDir 3.0"));
|
sl@0
|
63 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\TEST\\"));
|
sl@0
|
64 |
test(r==KErrNone);
|
sl@0
|
65 |
r=TheFs.RmDir(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
66 |
test(r==KErrNone);
|
sl@0
|
67 |
|
sl@0
|
68 |
test.Next(_L("Test mkdir and rmdir on root"));
|
sl@0
|
69 |
r=TheFs.RmDir(_L("\\File.TXT"));
|
sl@0
|
70 |
test(r==KErrInUse);
|
sl@0
|
71 |
r=TheFs.MkDir(_L("\\asdf.ere"));
|
sl@0
|
72 |
test(r==KErrAlreadyExists);
|
sl@0
|
73 |
r=TheFs.MkDirAll(_L("\\asdf.ere"));
|
sl@0
|
74 |
test(r==KErrAlreadyExists);
|
sl@0
|
75 |
|
sl@0
|
76 |
test.Next(_L("Test error code return values"));
|
sl@0
|
77 |
r=TheFs.MkDir(_L("\\F32-TST\\\\ABCDEF\\"));
|
sl@0
|
78 |
|
sl@0
|
79 |
test(r==KErrBadName);
|
sl@0
|
80 |
|
sl@0
|
81 |
test.Next(_L("Test MkDir with trailing spaces"));
|
sl@0
|
82 |
r=TheFs.MkDir(_L("\\F32-TST\\TESTMKDIR \\"));
|
sl@0
|
83 |
test(r==KErrNone);
|
sl@0
|
84 |
r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\"));
|
sl@0
|
85 |
test(r==KErrNone);
|
sl@0
|
86 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TESTMKDIR \\NOTCREATED\\NORTHIS \\"));
|
sl@0
|
87 |
test(r==KErrPathNotFound);
|
sl@0
|
88 |
r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\NOTCREATED\\"));
|
sl@0
|
89 |
test(r==KErrNotFound);
|
sl@0
|
90 |
r=TheFs.RmDir(_L("\\F32-TST\\TESTMKDIR\\"));
|
sl@0
|
91 |
test(r==KErrNone);
|
sl@0
|
92 |
|
sl@0
|
93 |
r=TheFs.MkDirAll(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
94 |
test(r==KErrNone);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
LOCAL_C void testRename()
|
sl@0
|
98 |
//
|
sl@0
|
99 |
// Test the rename function.
|
sl@0
|
100 |
//
|
sl@0
|
101 |
{
|
sl@0
|
102 |
|
sl@0
|
103 |
test.Next(_L("Test rename directories"));
|
sl@0
|
104 |
TInt r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\GPQ\\"));
|
sl@0
|
105 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
106 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\"),_L("\\F32-TST\\ABCDEF\\LMED"));
|
sl@0
|
107 |
test(r==KErrInUse);
|
sl@0
|
108 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\GPQ"),_L("\\F32-TST\\LMED"));
|
sl@0
|
109 |
test(r==KErrNone);
|
sl@0
|
110 |
r=TheFs.RmDir(_L("\\F32-TST\\LMED\\"));
|
sl@0
|
111 |
test(r==KErrNone);
|
sl@0
|
112 |
|
sl@0
|
113 |
MakeDir(_L("\\F32-TST\\ABC\\"));
|
sl@0
|
114 |
MakeFile(_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"));
|
sl@0
|
115 |
MakeFile(_L("\\F32-TST\\asdf.txt"));
|
sl@0
|
116 |
|
sl@0
|
117 |
test.Next(_L("Test rename directory while subfile is open"));
|
sl@0
|
118 |
RFile f;
|
sl@0
|
119 |
r=f.Open(TheFs,_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"),EFileRead);
|
sl@0
|
120 |
test(r==KErrNone);
|
sl@0
|
121 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
|
sl@0
|
122 |
test(r==KErrInUse);
|
sl@0
|
123 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
|
sl@0
|
124 |
test(r==KErrInUse);
|
sl@0
|
125 |
r=TheFs.Rename(_L("\\F32-TST\\ABC"),_L("\\F32-TST\\XXX"));
|
sl@0
|
126 |
test(r==KErrNone);
|
sl@0
|
127 |
f.Close();
|
sl@0
|
128 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\xxxyyy"));
|
sl@0
|
129 |
test(r==KErrNone);
|
sl@0
|
130 |
r=TheFs.Rename(_L("\\F32-TST\\XXX"),_L("\\F32-TST\\ABC"));
|
sl@0
|
131 |
test(r==KErrNone);
|
sl@0
|
132 |
r=TheFs.Rename(_L("\\"),_L("\\BLARG"));
|
sl@0
|
133 |
test(r==KErrBadName);
|
sl@0
|
134 |
|
sl@0
|
135 |
r=f.Open(TheFs,_L("\\F32-TST\\asdf.txt"),EFileRead);
|
sl@0
|
136 |
test(r==KErrNone);
|
sl@0
|
137 |
r=TheFs.Rename(_L("\\F32-TST\\xxxyyy"),_L("\\F32-TST\\ABCDEF"));
|
sl@0
|
138 |
test(r==KErrNone);
|
sl@0
|
139 |
r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\ABCDEF"));
|
sl@0
|
140 |
test(r==KErrInUse);
|
sl@0
|
141 |
f.Close();
|
sl@0
|
142 |
|
sl@0
|
143 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\GPQ\\asdf.txt"));
|
sl@0
|
144 |
test(r==KErrNone);
|
sl@0
|
145 |
r=TheFs.Delete(_L("\\F32-TST\\asdf.txt"));
|
sl@0
|
146 |
test(r==KErrNone);
|
sl@0
|
147 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\GPQ\\"));
|
sl@0
|
148 |
test(r==KErrNone);
|
sl@0
|
149 |
r=TheFs.RmDir(_L("\\F32-TST\\ABC\\"));
|
sl@0
|
150 |
test(r==KErrNone);
|
sl@0
|
151 |
|
sl@0
|
152 |
r=TheFs.Rename(_L("\\TST-E32\\123456"),_L("\\F32-TST\\ABCDEF"));
|
sl@0
|
153 |
test(r==KErrPathNotFound);
|
sl@0
|
154 |
r=TheFs.Rename(_L("\\F32-TST\\123456"),_L("\\F32-TST\\ABCDEF"));
|
sl@0
|
155 |
test(r==KErrNotFound);
|
sl@0
|
156 |
r=TheFs.Rename(_L("\\TST-E32\\123456"),_L("\\F32-TST\\FEDCBA"));
|
sl@0
|
157 |
test(r==KErrPathNotFound);
|
sl@0
|
158 |
r=TheFs.Rename(_L("\\F32-TST\\FEDCBA"),_L("\\TST-E32\\123456"));
|
sl@0
|
159 |
test(r==KErrNotFound);
|
sl@0
|
160 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\123456"));
|
sl@0
|
161 |
test(r==KErrNone);
|
sl@0
|
162 |
r=TheFs.Rename(_L("\\F32-TST\\123456"),_L("\\F32-TST\\XYZABC"));
|
sl@0
|
163 |
test(r==KErrNone);
|
sl@0
|
164 |
|
sl@0
|
165 |
test.Next(_L("Test rename files"));
|
sl@0
|
166 |
r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),EFileRead|EFileWrite);
|
sl@0
|
167 |
test(r==KErrNone);
|
sl@0
|
168 |
f.Close();
|
sl@0
|
169 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
|
sl@0
|
170 |
test(r==KErrNone);
|
sl@0
|
171 |
r=TheFs.Delete(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
|
sl@0
|
172 |
test(r==KErrNone);
|
sl@0
|
173 |
|
sl@0
|
174 |
test.Next(_L("Test rename checks for duplicate entries"));
|
sl@0
|
175 |
r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\"));
|
sl@0
|
176 |
test(r==KErrNone);
|
sl@0
|
177 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\XYZABC"));
|
sl@0
|
178 |
test(r==KErrAlreadyExists);
|
sl@0
|
179 |
r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),EFileRead|EFileWrite);
|
sl@0
|
180 |
test(r==KErrNone);
|
sl@0
|
181 |
f.Close();
|
sl@0
|
182 |
r=f.Create(TheFs,_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),EFileRead|EFileWrite);
|
sl@0
|
183 |
test(r==KErrNone);
|
sl@0
|
184 |
f.Close();
|
sl@0
|
185 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"));
|
sl@0
|
186 |
test(r==KErrAlreadyExists);
|
sl@0
|
187 |
|
sl@0
|
188 |
test.Next(_L("Test rename across directories"));
|
sl@0
|
189 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
|
sl@0
|
190 |
test(r==KErrNone);
|
sl@0
|
191 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
|
sl@0
|
192 |
test(r==KErrNotFound);
|
sl@0
|
193 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC\\NEWNAME.TXT"),_L("\\F32-TST\\ABCDEF\\DIFNAME.TXT"));
|
sl@0
|
194 |
test(r==KErrNotFound);
|
sl@0
|
195 |
r=TheFs.Rename(_L("\\F32-TST\\XYZABC"),_L("\\F32-TST\\ABCDEF\\XYZABC"));
|
sl@0
|
196 |
test(r==KErrNone);
|
sl@0
|
197 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
|
sl@0
|
198 |
test(r==KErrNone);
|
sl@0
|
199 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\NewNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"));
|
sl@0
|
200 |
test(r==KErrNone);
|
sl@0
|
201 |
test.Next(_L("Test rename across drive error code"));
|
sl@0
|
202 |
r=TheFs.Rename(_L("Z:\\BLEG"),_L("C:\\FRUM"));
|
sl@0
|
203 |
test(r==KErrArgument);
|
sl@0
|
204 |
test.Next(_L("Test rename to identical names"));
|
sl@0
|
205 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"));
|
sl@0
|
206 |
test(r==KErrNone);
|
sl@0
|
207 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),KErrNone);
|
sl@0
|
208 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\XYZABC\\OLdnAME.TXT"));
|
sl@0
|
209 |
test(r==KErrNone);
|
sl@0
|
210 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),KErrNone,EFalse);
|
sl@0
|
211 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLdnAME.TXT"),KErrNone,ETrue);
|
sl@0
|
212 |
|
sl@0
|
213 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\XYZABC\\OLDNAME.TXT"),_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
|
sl@0
|
214 |
test(r==KErrNone);
|
sl@0
|
215 |
test.Next(_L("Test RmDir"));
|
sl@0
|
216 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\NEWNAME.TXT"));
|
sl@0
|
217 |
test(r==KErrNone);
|
sl@0
|
218 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\OLDNAME.TXT"));
|
sl@0
|
219 |
test(r==KErrNone);
|
sl@0
|
220 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\XYZABC\\"));
|
sl@0
|
221 |
test(r==KErrNone);
|
sl@0
|
222 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
|
sl@0
|
223 |
test(r==KErrNone);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
LOCAL_C void TestLongFileName()
|
sl@0
|
226 |
{
|
sl@0
|
227 |
#ifndef __EPOC32__ //emulator
|
sl@0
|
228 |
if (gDriveToTest.GetLowerCase()=='c')
|
sl@0
|
229 |
return;//don't perform this test for c: in emulator as emulator uses windows system calls
|
sl@0
|
230 |
//windows doesn't create a directory with length more than 244 characters
|
sl@0
|
231 |
#endif
|
sl@0
|
232 |
|
sl@0
|
233 |
test.Next(_L("Test renaming 257 characters directories"));
|
sl@0
|
234 |
_LIT(KLongFileName256, "256dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
sl@0
|
235 |
_LIT(KLongFileName257, "257dir_IncludingBackslash_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
sl@0
|
236 |
TBuf<260> Path;
|
sl@0
|
237 |
TBuf<10> baseDir;
|
sl@0
|
238 |
|
sl@0
|
239 |
baseDir.Format(_L("%c:\\"),(TUint)(gDriveToTest));
|
sl@0
|
240 |
Path.Copy(baseDir);
|
sl@0
|
241 |
Path.Append(KLongFileName256);
|
sl@0
|
242 |
Path.Append(_L("\\"));
|
sl@0
|
243 |
|
sl@0
|
244 |
TInt result = KErrNone;
|
sl@0
|
245 |
//-- 1. create directory in Root which total path length is 256 symbols. result = TheFs.MkDirAll(Path);
|
sl@0
|
246 |
result=TheFs.MkDirAll(Path);
|
sl@0
|
247 |
test((result==KErrNone)||(result==KErrAlreadyExists));
|
sl@0
|
248 |
|
sl@0
|
249 |
test.Next(_L("Renaming a 265 char directory to a 257 char directory"));
|
sl@0
|
250 |
result=TheFs.SetSessionPath(baseDir);
|
sl@0
|
251 |
test(result==KErrNone);
|
sl@0
|
252 |
TheFs.SessionPath(baseDir);
|
sl@0
|
253 |
test.Printf(_L("Session path was set to: %S"), &baseDir);
|
sl@0
|
254 |
|
sl@0
|
255 |
//-- 2. try to rename this directory to one with 257 character total path length
|
sl@0
|
256 |
test.Printf(_L("Renaming 256-char directory to 257"));
|
sl@0
|
257 |
result = KErrNone;
|
sl@0
|
258 |
Path.Copy(KLongFileName257);
|
sl@0
|
259 |
result = TheFs.Rename(KLongFileName256, Path);
|
sl@0
|
260 |
test(result==KErrBadName);
|
sl@0
|
261 |
//-- 3. try to rename this directory to one with 258 character total path length
|
sl@0
|
262 |
|
sl@0
|
263 |
Path.Append(_L("z"));
|
sl@0
|
264 |
result = TheFs.Rename(KLongFileName256, Path);
|
sl@0
|
265 |
test(result==KErrBadName);
|
sl@0
|
266 |
|
sl@0
|
267 |
}
|
sl@0
|
268 |
LOCAL_C void testRenameCase()
|
sl@0
|
269 |
//
|
sl@0
|
270 |
// Test renaming "AGENDA" to "agenda"
|
sl@0
|
271 |
//
|
sl@0
|
272 |
{
|
sl@0
|
273 |
|
sl@0
|
274 |
test.Next(_L("Test rename case"));
|
sl@0
|
275 |
MakeDir(_L("\\F32-TST\\RENAMECASE\\"));
|
sl@0
|
276 |
TInt r=TheFs.SetSessionPath(_L("\\F32-TST\\RENAMECASE\\"));
|
sl@0
|
277 |
test(r==KErrNone);
|
sl@0
|
278 |
|
sl@0
|
279 |
MakeFile(_L("file1.txt"));
|
sl@0
|
280 |
MakeFile(_L("FILE2.TXT"));
|
sl@0
|
281 |
MakeFile(_L("AGENDA"));
|
sl@0
|
282 |
MakeFile(_L("agenda.one"));
|
sl@0
|
283 |
|
sl@0
|
284 |
TEntry entry;
|
sl@0
|
285 |
r=TheFs.Rename(_L("FILE1.TXT"),_L("FILE1.TXT"));
|
sl@0
|
286 |
test(r==KErrNone);
|
sl@0
|
287 |
r=TheFs.Entry(_L("File1.txt"),entry);
|
sl@0
|
288 |
test(r==KErrNone);
|
sl@0
|
289 |
test(entry.iName==_L("FILE1.TXT"));
|
sl@0
|
290 |
|
sl@0
|
291 |
r=TheFs.Rename(_L("file2.txt"),_L("file2.txt"));
|
sl@0
|
292 |
test(r==KErrNone);
|
sl@0
|
293 |
r=TheFs.Entry(_L("File2.txt"),entry);
|
sl@0
|
294 |
test(r==KErrNone);
|
sl@0
|
295 |
test(entry.iName==_L("file2.txt"));
|
sl@0
|
296 |
|
sl@0
|
297 |
r=TheFs.Rename(_L("agenda."),_L("agenda.two"));
|
sl@0
|
298 |
test(r==KErrNone);
|
sl@0
|
299 |
r=TheFs.Entry(_L("Agenda.two"),entry);
|
sl@0
|
300 |
test(r==KErrNone);
|
sl@0
|
301 |
test(entry.iName==_L("agenda.two"));
|
sl@0
|
302 |
|
sl@0
|
303 |
r=TheFs.Rename(_L("AGENDA.ONE"),_L("AGENDA.ONE"));
|
sl@0
|
304 |
test(r==KErrNone);
|
sl@0
|
305 |
r=TheFs.Entry(_L("Agenda.one"),entry);
|
sl@0
|
306 |
test(r==KErrNone);
|
sl@0
|
307 |
test(entry.iName==_L("AGENDA.ONE"));
|
sl@0
|
308 |
|
sl@0
|
309 |
r=TheFs.Rename(_L("FILE1.TXT"),_L("file1.txt"));
|
sl@0
|
310 |
test(r==KErrNone);
|
sl@0
|
311 |
r=TheFs.Entry(_L("File1.txt"),entry);
|
sl@0
|
312 |
test(r==KErrNone);
|
sl@0
|
313 |
test(entry.iName==_L("file1.txt"));
|
sl@0
|
314 |
|
sl@0
|
315 |
r=TheFs.Rename(_L("file2.txt"),_L("FILE2.TXT"));
|
sl@0
|
316 |
test(r==KErrNone);
|
sl@0
|
317 |
r=TheFs.Entry(_L("File2.txt"),entry);
|
sl@0
|
318 |
test(r==KErrNone);
|
sl@0
|
319 |
test(entry.iName==_L("FILE2.TXT"));
|
sl@0
|
320 |
|
sl@0
|
321 |
r=TheFs.Rename(_L("agenda.two"),_L("AGENDA"));
|
sl@0
|
322 |
test(r==KErrNone);
|
sl@0
|
323 |
r=TheFs.Entry(_L("Agenda"),entry);
|
sl@0
|
324 |
test(r==KErrNone);
|
sl@0
|
325 |
test(entry.iName==_L("AGENDA"));
|
sl@0
|
326 |
|
sl@0
|
327 |
r=TheFs.Rename(_L("AGENDA.ONE"),_L("agenda.one"));
|
sl@0
|
328 |
test(r==KErrNone);
|
sl@0
|
329 |
r=TheFs.Entry(_L("Agenda.one"),entry);
|
sl@0
|
330 |
test(r==KErrNone);
|
sl@0
|
331 |
test(entry.iName==_L("agenda.one"));
|
sl@0
|
332 |
|
sl@0
|
333 |
r=TheFs.Rename(_L("FILE1.TXT"),_L("FILe1.txt"));
|
sl@0
|
334 |
test(r==KErrNone);
|
sl@0
|
335 |
r=TheFs.Entry(_L("File1.txt"),entry);
|
sl@0
|
336 |
test(r==KErrNone);
|
sl@0
|
337 |
test(entry.iName==_L("FILe1.txt"));
|
sl@0
|
338 |
|
sl@0
|
339 |
r=TheFs.Rename(_L("file2.txt"),_L("FILE3.TXT"));
|
sl@0
|
340 |
test(r==KErrNone);
|
sl@0
|
341 |
r=TheFs.Entry(_L("File3.txt"),entry);
|
sl@0
|
342 |
test(r==KErrNone);
|
sl@0
|
343 |
test(entry.iName==_L("FILE3.TXT"));
|
sl@0
|
344 |
|
sl@0
|
345 |
r=TheFs.Rename(_L("agenda."),_L("AGENDA1"));
|
sl@0
|
346 |
test(r==KErrNone);
|
sl@0
|
347 |
r=TheFs.Entry(_L("Agenda1"),entry);
|
sl@0
|
348 |
test(r==KErrNone);
|
sl@0
|
349 |
test(entry.iName==_L("AGENDA1"));
|
sl@0
|
350 |
|
sl@0
|
351 |
r=TheFs.Rename(_L("AGENDA.ONE"),_L("Agenda.One"));
|
sl@0
|
352 |
test(r==KErrNone);
|
sl@0
|
353 |
r=TheFs.Entry(_L("Agenda.one"),entry);
|
sl@0
|
354 |
test(r==KErrNone);
|
sl@0
|
355 |
test(entry.iName==_L("Agenda.One"));
|
sl@0
|
356 |
|
sl@0
|
357 |
r=TheFs.Delete(_L("file1.txt"));
|
sl@0
|
358 |
test(r==KErrNone);
|
sl@0
|
359 |
r=TheFs.Delete(_L("file3.txt"));
|
sl@0
|
360 |
test(r==KErrNone);
|
sl@0
|
361 |
r=TheFs.Delete(_L("Agenda1"));
|
sl@0
|
362 |
test(r==KErrNone);
|
sl@0
|
363 |
r=TheFs.Delete(_L("AGENDA.ONE"));
|
sl@0
|
364 |
test(r==KErrNone);
|
sl@0
|
365 |
r=TheFs.RmDir(_L("\\F32-TST\\RENAMECASE\\"));
|
sl@0
|
366 |
test(r==KErrNone);
|
sl@0
|
367 |
r=TheFs.SetSessionPath(gSessionPath);
|
sl@0
|
368 |
test(r==KErrNone);
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
LOCAL_C void testReplace()
|
sl@0
|
372 |
//
|
sl@0
|
373 |
// Test the replace function
|
sl@0
|
374 |
//
|
sl@0
|
375 |
{
|
sl@0
|
376 |
|
sl@0
|
377 |
test.Next(_L("Test Replace"));
|
sl@0
|
378 |
TInt r=TheFs.MkDirAll(_L("\\F32-TST\\ABCDEF\\"));
|
sl@0
|
379 |
test(r==KErrNone);
|
sl@0
|
380 |
r=TheFs.Replace(_L("\\TST-E32\\123456"),_L("\\F32-TST\\ABCDEF"));
|
sl@0
|
381 |
test(r==KErrAccessDenied); // Do not replace directories
|
sl@0
|
382 |
r=TheFs.Replace(_L("\\F32-TST\\123456"),_L("\\F32-TST\\ABCDEF"));
|
sl@0
|
383 |
test(r==KErrAccessDenied);
|
sl@0
|
384 |
r=TheFs.Replace(_L("\\TST-E32\\123456"),_L("\\F32-TST\\FEDCBA"));
|
sl@0
|
385 |
test(r==KErrPathNotFound);
|
sl@0
|
386 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF"),_L("\\F32-TST\\123456"));
|
sl@0
|
387 |
test(r==KErrAccessDenied);
|
sl@0
|
388 |
|
sl@0
|
389 |
test.Next(_L("Replace a file with itself (8.3 filename)"));
|
sl@0
|
390 |
MakeFile(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
|
sl@0
|
391 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
|
sl@0
|
392 |
test(r==KErrNone);
|
sl@0
|
393 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),KErrNone);
|
sl@0
|
394 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\test1.spr"));
|
sl@0
|
395 |
test(r==KErrNone);
|
sl@0
|
396 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"),KErrNone,ETrue); // Replace does not rename existing file
|
sl@0
|
397 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\test1.spr"),KErrNone,EFalse);
|
sl@0
|
398 |
|
sl@0
|
399 |
test.Next(_L("Replace a file with itself (vfat filename)"));
|
sl@0
|
400 |
MakeFile(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
|
sl@0
|
401 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
|
sl@0
|
402 |
test(r==KErrNone);
|
sl@0
|
403 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),KErrNone);
|
sl@0
|
404 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),_L("\\F32-TST\\ABCDEF\\test_sheet(01).spr"));
|
sl@0
|
405 |
test(r==KErrNone);
|
sl@0
|
406 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"),KErrNone,ETrue); // Replace does not rename existing file
|
sl@0
|
407 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\test_sheet(01).spr"),KErrNone,EFalse);
|
sl@0
|
408 |
|
sl@0
|
409 |
test.Next(_L("Replace preserves file contents (8.3 filename)"));
|
sl@0
|
410 |
MakeFile(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("Original Data"));
|
sl@0
|
411 |
MakeFile(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L8("NewData"));
|
sl@0
|
412 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
|
sl@0
|
413 |
test(r==KErrNone);
|
sl@0
|
414 |
CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("NewData"));
|
sl@0
|
415 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),KErrNotFound);
|
sl@0
|
416 |
|
sl@0
|
417 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"));
|
sl@0
|
418 |
test(r==KErrNone);
|
sl@0
|
419 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
|
sl@0
|
420 |
test(r==KErrNone);
|
sl@0
|
421 |
CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"),_L8("NewData"));
|
sl@0
|
422 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\TEMP0001.SPR"),KErrNotFound);
|
sl@0
|
423 |
|
sl@0
|
424 |
test.Next(_L("Replace preserves file contents (vfat fileName)"));
|
sl@0
|
425 |
MakeFile(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("Original Data"));
|
sl@0
|
426 |
MakeFile(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L8("NewData"));
|
sl@0
|
427 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
|
sl@0
|
428 |
test(r==KErrNone);
|
sl@0
|
429 |
CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("NewData"));
|
sl@0
|
430 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),KErrNotFound);
|
sl@0
|
431 |
|
sl@0
|
432 |
r=TheFs.Rename(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"));
|
sl@0
|
433 |
test(r==KErrNone);
|
sl@0
|
434 |
r=TheFs.Replace(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
|
sl@0
|
435 |
test(r==KErrNone);
|
sl@0
|
436 |
CheckFileContents(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"),_L8("NewData"));
|
sl@0
|
437 |
CheckFileExists(_L("\\F32-TST\\ABCDEF\\NEW_TEMP0001.SPR"),KErrNotFound);
|
sl@0
|
438 |
|
sl@0
|
439 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
|
sl@0
|
440 |
test(r==KErrInUse);
|
sl@0
|
441 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR\\"));
|
sl@0
|
442 |
test(r==KErrPathNotFound);
|
sl@0
|
443 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\SHEET1.SPR"));
|
sl@0
|
444 |
test(r==KErrNone);
|
sl@0
|
445 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\SHEET_TEST1.SPR"));
|
sl@0
|
446 |
test(r==KErrNone);
|
sl@0
|
447 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\TEST1.SPR"));
|
sl@0
|
448 |
test(r==KErrNone);
|
sl@0
|
449 |
r=TheFs.Delete(_L("\\F32-TST\\ABCDEF\\TEST_SHEET(01).SPR"));
|
sl@0
|
450 |
test(r==KErrNone);
|
sl@0
|
451 |
r=TheFs.RmDir(_L("\\F32-TST\\ABCDEF\\"));
|
sl@0
|
452 |
test(r==KErrNone);
|
sl@0
|
453 |
|
sl@0
|
454 |
test.Next(_L("Check file date is retained"));
|
sl@0
|
455 |
MakeFile(_L("OldFile.Old"));
|
sl@0
|
456 |
MakeFile(_L("NewFile.new"));
|
sl@0
|
457 |
|
sl@0
|
458 |
TDateTime newDate(1998,(TMonth)2,3,11,12,0,0);
|
sl@0
|
459 |
TTime newTime(newDate);
|
sl@0
|
460 |
|
sl@0
|
461 |
r=TheFs.SetEntry(_L("NewFile.new"),newTime,0,0);
|
sl@0
|
462 |
test(r==KErrNone);
|
sl@0
|
463 |
|
sl@0
|
464 |
TEntry entry;
|
sl@0
|
465 |
r=TheFs.Entry(_L("NewFile.new"),entry);
|
sl@0
|
466 |
test(r==KErrNone);
|
sl@0
|
467 |
|
sl@0
|
468 |
TTime checkReturnedTime=entry.iModified;
|
sl@0
|
469 |
TDateTime dateTime=checkReturnedTime.DateTime();
|
sl@0
|
470 |
|
sl@0
|
471 |
test(entry.iModified==newTime);
|
sl@0
|
472 |
|
sl@0
|
473 |
TDateTime oldDate(1996,(TMonth)2,3,23,0,0,0);
|
sl@0
|
474 |
TTime oldTime(oldDate);
|
sl@0
|
475 |
r=TheFs.SetEntry(_L("OldFile.old"),oldTime,0,0);
|
sl@0
|
476 |
test(r==KErrNone);
|
sl@0
|
477 |
|
sl@0
|
478 |
TheFs.Replace(_L("NewFile.new"),_L("OldFile.old"));
|
sl@0
|
479 |
test(r==KErrNone);
|
sl@0
|
480 |
TTime check;
|
sl@0
|
481 |
r=TheFs.Modified(_L("OldFile.old"),check);
|
sl@0
|
482 |
test(r==KErrNone);
|
sl@0
|
483 |
TDateTime checkDateTime=check.DateTime();
|
sl@0
|
484 |
|
sl@0
|
485 |
test(checkDateTime.Year()==dateTime.Year());
|
sl@0
|
486 |
test(checkDateTime.Month()==dateTime.Month());
|
sl@0
|
487 |
test(checkDateTime.Day()==dateTime.Day());
|
sl@0
|
488 |
test(checkDateTime.Hour()==dateTime.Hour());
|
sl@0
|
489 |
test(checkDateTime.Minute()==dateTime.Minute());
|
sl@0
|
490 |
test(checkDateTime.Second()==dateTime.Second());
|
sl@0
|
491 |
|
sl@0
|
492 |
test.Next(_L("Replace 'Agenda' with 'Agenda.'"));
|
sl@0
|
493 |
MakeFile(_L("Agenda"));
|
sl@0
|
494 |
r=TheFs.Replace(_L("Agenda"),_L("Agenda."));
|
sl@0
|
495 |
test(r==KErrNone);
|
sl@0
|
496 |
CheckFileExists(_L("Agenda"),KErrNone,ETrue);
|
sl@0
|
497 |
CheckFileExists(_L("Agenda."),KErrNone,ETrue);
|
sl@0
|
498 |
CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
|
sl@0
|
499 |
CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
|
sl@0
|
500 |
|
sl@0
|
501 |
r=TheFs.Replace(_L("Agenda"),_L("Agenda."));
|
sl@0
|
502 |
test(r==KErrNone);
|
sl@0
|
503 |
CheckFileExists(_L("Agenda"),KErrNone,ETrue);
|
sl@0
|
504 |
CheckFileExists(_L("Agenda."),KErrNone,ETrue);
|
sl@0
|
505 |
CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
|
sl@0
|
506 |
CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
|
sl@0
|
507 |
|
sl@0
|
508 |
r=TheFs.Replace(_L("Agenda."),_L("AGENDA"));
|
sl@0
|
509 |
test(r==KErrNone);
|
sl@0
|
510 |
CheckFileExists(_L("Agenda"),KErrNone,ETrue); // Replace does not rename existing file
|
sl@0
|
511 |
CheckFileExists(_L("Agenda."),KErrNone,ETrue);
|
sl@0
|
512 |
CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
|
sl@0
|
513 |
CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
|
sl@0
|
514 |
|
sl@0
|
515 |
r=TheFs.Replace(_L("AGENDA."),_L("AGENDA.")); // Unchanged, ie still 'Agenda'
|
sl@0
|
516 |
test(r==KErrNone);
|
sl@0
|
517 |
CheckFileExists(_L("Agenda"),KErrNone,ETrue);
|
sl@0
|
518 |
CheckFileExists(_L("Agenda."),KErrNone,ETrue);
|
sl@0
|
519 |
CheckFileExists(_L("AGENDA"),KErrNone,EFalse);
|
sl@0
|
520 |
CheckFileExists(_L("AGENDA."),KErrNone,EFalse);
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
LOCAL_C void testEntry()
|
sl@0
|
524 |
//
|
sl@0
|
525 |
// Test RFs::Entry(..) function
|
sl@0
|
526 |
//
|
sl@0
|
527 |
{
|
sl@0
|
528 |
|
sl@0
|
529 |
test.Next(_L("Get directory entry"));
|
sl@0
|
530 |
TEntry entry;
|
sl@0
|
531 |
TInt r=TheFs.Entry(_L("\\BLEERRG\\"),entry);
|
sl@0
|
532 |
test(r==KErrNotFound); // BLEERRG does not exist
|
sl@0
|
533 |
r=TheFs.Entry(_L("\\F32-TST"),entry);
|
sl@0
|
534 |
test(r==KErrNone);
|
sl@0
|
535 |
test(entry.iName==_L("F32-TST")||entry.iName==_L("F32-TST."));
|
sl@0
|
536 |
if (IsTestingLFFS())
|
sl@0
|
537 |
{
|
sl@0
|
538 |
r=TheFs.Rename(_L("\\F32-TST.\\"),_L("\\F32-TST\\"));
|
sl@0
|
539 |
test(r==KErrBadName);
|
sl@0
|
540 |
r=TheFs.Entry(_L("\\F32-TST"),entry);
|
sl@0
|
541 |
test(r==KErrNone);
|
sl@0
|
542 |
}
|
sl@0
|
543 |
test(entry.iName==_L("F32-TST"));
|
sl@0
|
544 |
test(entry.IsDir());
|
sl@0
|
545 |
|
sl@0
|
546 |
test.Next(_L("Get file entry"));
|
sl@0
|
547 |
RFile f;
|
sl@0
|
548 |
r=f.Replace(TheFs,_L("ENTRY.TXT"),EFileStream);
|
sl@0
|
549 |
test(r==KErrNone);
|
sl@0
|
550 |
r=f.Write(_L8("Entry data"));
|
sl@0
|
551 |
test(r==KErrNone);
|
sl@0
|
552 |
f.Close();
|
sl@0
|
553 |
r=TheFs.Entry(_L("\\F32-TST\\TNMBS\\ENTRY.TXT"),entry);
|
sl@0
|
554 |
test(r==KErrNone);
|
sl@0
|
555 |
test(entry.iName==_L("ENTRY.TXT"));
|
sl@0
|
556 |
test(!entry.IsDir());
|
sl@0
|
557 |
|
sl@0
|
558 |
test.Next(_L("Get the root directory"));
|
sl@0
|
559 |
r=TheFs.Entry(_L("\\"),entry);
|
sl@0
|
560 |
test(r==KErrBadName);
|
sl@0
|
561 |
}
|
sl@0
|
562 |
|
sl@0
|
563 |
LOCAL_C void testRenameRegression()
|
sl@0
|
564 |
//
|
sl@0
|
565 |
// Regression tests for rename
|
sl@0
|
566 |
//
|
sl@0
|
567 |
{
|
sl@0
|
568 |
|
sl@0
|
569 |
test.Next(_L("More rename tests"));
|
sl@0
|
570 |
MakeFile(_L("\\F32-TST\\asdf"));
|
sl@0
|
571 |
TInt r=TheFs.Rename(_L("\\F32-TST\\asdf"),_L("*"));
|
sl@0
|
572 |
test(r==KErrBadName);
|
sl@0
|
573 |
r=TheFs.Rename(_L("\\F32-TST\\"),_L("*"));
|
sl@0
|
574 |
test(r==KErrBadName);
|
sl@0
|
575 |
r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\F32-TST.\\"));
|
sl@0
|
576 |
test(r==KErrBadName);
|
sl@0
|
577 |
CheckFileExists(_L("\\F32-TST\\asdf"),KErrNone);
|
sl@0
|
578 |
r=TheFs.Rename(_L("\\F32-TST\\asdf"),_L("\\F32-TST\\Asdf."));
|
sl@0
|
579 |
test(r==KErrNone);
|
sl@0
|
580 |
CheckFileExists(_L("\\F32-TST\\asdf"),KErrNone,EFalse);
|
sl@0
|
581 |
CheckFileExists(_L("\\F32-TST\\Asdf"),KErrNone,ETrue);
|
sl@0
|
582 |
|
sl@0
|
583 |
TBuf<4> shortName;
|
sl@0
|
584 |
shortName.SetLength(1);
|
sl@0
|
585 |
shortName[0]=0xff;
|
sl@0
|
586 |
r=TheFs.Rename(_L("\\F32-TST\\asdf"),shortName);
|
sl@0
|
587 |
test(r==KErrNone);
|
sl@0
|
588 |
r=TheFs.Delete(_L("\\F32-TST\\Asdf"));
|
sl@0
|
589 |
test(r==KErrNotFound);
|
sl@0
|
590 |
r=TheFs.Delete(shortName);
|
sl@0
|
591 |
test(r==KErrNone);
|
sl@0
|
592 |
}
|
sl@0
|
593 |
|
sl@0
|
594 |
LOCAL_C void testMaxNameLength()
|
sl@0
|
595 |
//
|
sl@0
|
596 |
// Create files and directories with the maximum name length
|
sl@0
|
597 |
//
|
sl@0
|
598 |
{
|
sl@0
|
599 |
|
sl@0
|
600 |
test.Next(_L("Test max name length"));
|
sl@0
|
601 |
TBuf<128> longNameBase=_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
sl@0
|
602 |
TFullName longName=_L("\\F32-TST\\MAXNAMELEN\\");
|
sl@0
|
603 |
|
sl@0
|
604 |
longName.Append(longNameBase);
|
sl@0
|
605 |
longName.Append(_L("\\"));
|
sl@0
|
606 |
longName.Append(longNameBase);
|
sl@0
|
607 |
longName.Append(_L("\\"));
|
sl@0
|
608 |
|
sl@0
|
609 |
TInt r=TheFs.MkDirAll(longName);
|
sl@0
|
610 |
test(r==KErrNone);
|
sl@0
|
611 |
|
sl@0
|
612 |
TInt i=0;
|
sl@0
|
613 |
FOREVER
|
sl@0
|
614 |
{
|
sl@0
|
615 |
longName.Append(_L("X"));
|
sl@0
|
616 |
longName.Append(_L("\\"));
|
sl@0
|
617 |
r=TheFs.MkDirAll(longName);
|
sl@0
|
618 |
if (r!=KErrNone)
|
sl@0
|
619 |
break;
|
sl@0
|
620 |
i++;
|
sl@0
|
621 |
}
|
sl@0
|
622 |
|
sl@0
|
623 |
longName.SetLength(longName.Length()-2);
|
sl@0
|
624 |
r=TheFs.RmDir(longName);
|
sl@0
|
625 |
test(r==KErrNone); // Make room for file
|
sl@0
|
626 |
longName.SetLength(longName.Length()-2);
|
sl@0
|
627 |
|
sl@0
|
628 |
TFullName oldSessionPath;
|
sl@0
|
629 |
r=TheFs.SessionPath(oldSessionPath);
|
sl@0
|
630 |
test(r==KErrNone);
|
sl@0
|
631 |
r=TheFs.SetSessionPath(longName);
|
sl@0
|
632 |
test(r==KErrNone);
|
sl@0
|
633 |
r=TheFs.SessionPath(longName);
|
sl@0
|
634 |
test(r==KErrNone);
|
sl@0
|
635 |
|
sl@0
|
636 |
test.Printf(_L("MaxPathLength achieved = %d chars\n"),longName.Length());
|
sl@0
|
637 |
TBuf<32> fileName=_L("012345678901234567890");
|
sl@0
|
638 |
RFile f;
|
sl@0
|
639 |
while (fileName.Length())
|
sl@0
|
640 |
{
|
sl@0
|
641 |
r=f.Replace(TheFs,fileName,EFileWrite);
|
sl@0
|
642 |
if (r==KErrNone)
|
sl@0
|
643 |
break;
|
sl@0
|
644 |
fileName.SetLength(fileName.Length()-1);
|
sl@0
|
645 |
}
|
sl@0
|
646 |
|
sl@0
|
647 |
f.Close();
|
sl@0
|
648 |
test.Printf(_L("Added filename %S\n"),&fileName);
|
sl@0
|
649 |
r=f.Open(TheFs,fileName,EFileRead);
|
sl@0
|
650 |
test(r==KErrNone);
|
sl@0
|
651 |
f.Close();
|
sl@0
|
652 |
|
sl@0
|
653 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
654 |
r=fMan->RmDir(_L("\\F32-TST\\MAXNAMELEN\\"));
|
sl@0
|
655 |
test(r==KErrNone);
|
sl@0
|
656 |
delete fMan;
|
sl@0
|
657 |
|
sl@0
|
658 |
r=f.Open(TheFs,fileName,EFileRead);
|
sl@0
|
659 |
test(r==KErrPathNotFound);
|
sl@0
|
660 |
r=TheFs.SetSessionPath(oldSessionPath);
|
sl@0
|
661 |
test(r==KErrNone);
|
sl@0
|
662 |
}
|
sl@0
|
663 |
|
sl@0
|
664 |
LOCAL_C void testErrorReturnValues()
|
sl@0
|
665 |
//
|
sl@0
|
666 |
// Test error return values
|
sl@0
|
667 |
//
|
sl@0
|
668 |
{
|
sl@0
|
669 |
|
sl@0
|
670 |
TInt r;
|
sl@0
|
671 |
test.Next(_L("Create folder with the name of an existing file"));
|
sl@0
|
672 |
MakeFile(_L("\\BLUE"));
|
sl@0
|
673 |
if (!IsTestingLFFS())
|
sl@0
|
674 |
{ //FIXME: Bad error codes from LFFS
|
sl@0
|
675 |
r=TheFs.MkDir(_L("\\BLUE\\"));
|
sl@0
|
676 |
test(r==KErrAccessDenied);
|
sl@0
|
677 |
MakeFile(_L("\\RED\\BLUE"));
|
sl@0
|
678 |
r=TheFs.MkDir(_L("\\RED\\BLUE\\"));
|
sl@0
|
679 |
test(r==KErrAccessDenied);
|
sl@0
|
680 |
r=TheFs.MkDirAll(_L("\\BLUE\\GREEN\\ORANGE\\"));
|
sl@0
|
681 |
test(r==KErrAccessDenied);
|
sl@0
|
682 |
}
|
sl@0
|
683 |
|
sl@0
|
684 |
test.Next(_L("Create folder with the name of an existing folder"));
|
sl@0
|
685 |
MakeDir(_L("\\VOLVO\\"));
|
sl@0
|
686 |
r=TheFs.MkDir(_L("\\VOLVO\\"));
|
sl@0
|
687 |
test(r==KErrAlreadyExists);
|
sl@0
|
688 |
MakeDir(_L("\\FORD\\VOLKSWAGEN\\"));
|
sl@0
|
689 |
r=TheFs.MkDirAll(_L("\\ford\\volkswagen\\"));
|
sl@0
|
690 |
test(r==KErrAlreadyExists);
|
sl@0
|
691 |
|
sl@0
|
692 |
RFile f;
|
sl@0
|
693 |
if (!IsTestingLFFS())
|
sl@0
|
694 |
{ //FIXME Bad error codes from LFFS
|
sl@0
|
695 |
test.Next(_L("Create a file with the name of an existing folder"));
|
sl@0
|
696 |
r=f.Create(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
|
sl@0
|
697 |
test(r==KErrAccessDenied);
|
sl@0
|
698 |
r=f.Replace(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
|
sl@0
|
699 |
test(r==KErrAccessDenied);
|
sl@0
|
700 |
r=f.Open(TheFs,_L("\\VOLVO"),EFileRead|EFileWrite);
|
sl@0
|
701 |
test(r==KErrAccessDenied);
|
sl@0
|
702 |
r=f.Create(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
|
sl@0
|
703 |
test(r==KErrAccessDenied);
|
sl@0
|
704 |
r=f.Replace(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
|
sl@0
|
705 |
test(r==KErrAccessDenied);
|
sl@0
|
706 |
r=f.Open(TheFs,_L("\\FORD\\VOLKSWAGEN"),EFileRead|EFileWrite);
|
sl@0
|
707 |
test(r==KErrAccessDenied);
|
sl@0
|
708 |
}
|
sl@0
|
709 |
|
sl@0
|
710 |
test.Next(_L("Create a file with the name of an existing file"));
|
sl@0
|
711 |
r=f.Create(TheFs,_L("\\BLUE"),EFileRead|EFileWrite);
|
sl@0
|
712 |
test(r==KErrAlreadyExists);
|
sl@0
|
713 |
}
|
sl@0
|
714 |
|
sl@0
|
715 |
LOCAL_C void testSetEntry()
|
sl@0
|
716 |
//
|
sl@0
|
717 |
// Test set entry
|
sl@0
|
718 |
//
|
sl@0
|
719 |
{
|
sl@0
|
720 |
|
sl@0
|
721 |
test.Next(_L("Test SetEntry"));
|
sl@0
|
722 |
// TDateTime dateTime(1968,ENovember,19,12,59,0,0); Year must be > 1980
|
sl@0
|
723 |
TDateTime dateTime(1981,ENovember,19,12,59,0,0);
|
sl@0
|
724 |
TTime time(dateTime);
|
sl@0
|
725 |
MakeFile(_L("DUMENTRY."));
|
sl@0
|
726 |
|
sl@0
|
727 |
RFile f;
|
sl@0
|
728 |
TInt r=f.Open(TheFs,_L("dumentry"),EFileRead);
|
sl@0
|
729 |
test(r==KErrNone);
|
sl@0
|
730 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttReadOnly,KEntryAttArchive);
|
sl@0
|
731 |
test(r==KErrInUse);
|
sl@0
|
732 |
f.Close();
|
sl@0
|
733 |
|
sl@0
|
734 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttReadOnly,KEntryAttArchive);
|
sl@0
|
735 |
test(r==KErrNone);
|
sl@0
|
736 |
CheckEntry(_L("DUMEntry"),KEntryAttReadOnly,TTime(dateTime));
|
sl@0
|
737 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttReadOnly);
|
sl@0
|
738 |
test(r==KErrNone);
|
sl@0
|
739 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
740 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,0);
|
sl@0
|
741 |
test(r==KErrNone);
|
sl@0
|
742 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
743 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,0);
|
sl@0
|
744 |
test(r==KErrNone);
|
sl@0
|
745 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
746 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,0);
|
sl@0
|
747 |
test(r==KErrNone);
|
sl@0
|
748 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
749 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttVolume,0);
|
sl@0
|
750 |
test(r==KErrNone);
|
sl@0
|
751 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
752 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttRemote,0);
|
sl@0
|
753 |
test(r==KErrNone);
|
sl@0
|
754 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
755 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume|KEntryAttRemote,0);
|
sl@0
|
756 |
test(r==KErrNone);
|
sl@0
|
757 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
758 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir|KEntryAttVolume|KEntryAttRemote,0);
|
sl@0
|
759 |
test(r==KErrNone);
|
sl@0
|
760 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
761 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir);
|
sl@0
|
762 |
test(r==KErrNone);
|
sl@0
|
763 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
764 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttVolume);
|
sl@0
|
765 |
test(r==KErrNone);
|
sl@0
|
766 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
767 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttRemote);
|
sl@0
|
768 |
test(r==KErrNone);
|
sl@0
|
769 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
770 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttVolume);
|
sl@0
|
771 |
test(r==KErrNone);
|
sl@0
|
772 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
773 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttRemote);
|
sl@0
|
774 |
test(r==KErrNone);
|
sl@0
|
775 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
776 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttVolume|KEntryAttRemote);
|
sl@0
|
777 |
test(r==KErrNone);
|
sl@0
|
778 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
779 |
r=TheFs.SetEntry(_L("dumentry."),time,0,KEntryAttDir|KEntryAttVolume|KEntryAttRemote);
|
sl@0
|
780 |
test(r==KErrNone);
|
sl@0
|
781 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
782 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,KEntryAttVolume);
|
sl@0
|
783 |
test(r==KErrNone);
|
sl@0
|
784 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
785 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttDir,KEntryAttRemote);
|
sl@0
|
786 |
test(r==KErrNone);
|
sl@0
|
787 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
788 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,KEntryAttDir);
|
sl@0
|
789 |
test(r==KErrNone);
|
sl@0
|
790 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
791 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttVolume,KEntryAttRemote);
|
sl@0
|
792 |
test(r==KErrNone);
|
sl@0
|
793 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
794 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,KEntryAttDir);
|
sl@0
|
795 |
test(r==KErrNone);
|
sl@0
|
796 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
797 |
r=TheFs.SetEntry(_L("dumentry."),time,KEntryAttRemote,KEntryAttVolume);
|
sl@0
|
798 |
test(r==KErrNone);
|
sl@0
|
799 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
800 |
|
sl@0
|
801 |
r=f.Open(TheFs,_L("dumentry"),EFileWrite);
|
sl@0
|
802 |
test(r==KErrNone);
|
sl@0
|
803 |
|
sl@0
|
804 |
r=f.SetAtt(KEntryAttDir,0);
|
sl@0
|
805 |
test(r==KErrNone);
|
sl@0
|
806 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
807 |
r=f.SetAtt(KEntryAttVolume,KEntryAttDir);
|
sl@0
|
808 |
test(r==KErrNone);
|
sl@0
|
809 |
CheckEntry(_L("DUMEntry"),0,TTime(dateTime));
|
sl@0
|
810 |
f.Close();
|
sl@0
|
811 |
r=TheFs.Delete(_L("dumEntry."));
|
sl@0
|
812 |
test(r==KErrNone);
|
sl@0
|
813 |
|
sl@0
|
814 |
MakeDir(_L("\\DumEntry\\"));
|
sl@0
|
815 |
r=TheFs.SetEntry(_L("\\dumentry\\"),time,KEntryAttReadOnly,KEntryAttArchive);
|
sl@0
|
816 |
test(r==KErrNone);
|
sl@0
|
817 |
CheckEntry(_L("\\DUMEntry"),KEntryAttReadOnly|KEntryAttDir,TTime(dateTime));
|
sl@0
|
818 |
r=TheFs.SetEntry(_L("\\dumentry."),time,0,KEntryAttReadOnly);
|
sl@0
|
819 |
test(r==KErrNone);
|
sl@0
|
820 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
821 |
r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttDir,0);
|
sl@0
|
822 |
test(r==KErrNone);
|
sl@0
|
823 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
824 |
r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume,0);
|
sl@0
|
825 |
test(r==KErrNone);
|
sl@0
|
826 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
827 |
r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume|KEntryAttDir,0);
|
sl@0
|
828 |
test(r==KErrNone);
|
sl@0
|
829 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
830 |
r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttVolume|KEntryAttDir);
|
sl@0
|
831 |
test(r==KErrNone);
|
sl@0
|
832 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
833 |
r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttVolume);
|
sl@0
|
834 |
test(r==KErrNone);
|
sl@0
|
835 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
836 |
r=TheFs.SetEntry(_L("\\dumentry"),time,0,KEntryAttDir);
|
sl@0
|
837 |
test(r==KErrNone);
|
sl@0
|
838 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
839 |
r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttVolume,KEntryAttDir);
|
sl@0
|
840 |
test(r==KErrNone);
|
sl@0
|
841 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
842 |
r=TheFs.SetEntry(_L("\\dumentry"),time,KEntryAttDir,KEntryAttVolume);
|
sl@0
|
843 |
test(r==KErrNone);
|
sl@0
|
844 |
CheckEntry(_L("\\DUMEntry"),KEntryAttDir,TTime(dateTime));
|
sl@0
|
845 |
r=TheFs.RmDir(_L("\\dumEntry\\"));
|
sl@0
|
846 |
test(r==KErrNone);
|
sl@0
|
847 |
}
|
sl@0
|
848 |
|
sl@0
|
849 |
|
sl@0
|
850 |
LOCAL_C void testSetFileAttributes()
|
sl@0
|
851 |
//
|
sl@0
|
852 |
// Test RFile::SetAtt() and RFile::Set()
|
sl@0
|
853 |
//
|
sl@0
|
854 |
{
|
sl@0
|
855 |
// First test RFile::SetAtt() function
|
sl@0
|
856 |
|
sl@0
|
857 |
test.Next(_L("Test RFile::SetAtt()"));
|
sl@0
|
858 |
|
sl@0
|
859 |
// Create a file "TEMPFILE.TMP" and set attributes to hidden
|
sl@0
|
860 |
RFile file;
|
sl@0
|
861 |
TInt r=file.Replace(TheFs,_L("TEMPFILE.TMP"),0);
|
sl@0
|
862 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
863 |
r=file.SetAtt(KEntryAttHidden,0);
|
sl@0
|
864 |
test(r==KErrNone);
|
sl@0
|
865 |
file.Close();
|
sl@0
|
866 |
|
sl@0
|
867 |
// Check attributes are as set
|
sl@0
|
868 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
869 |
TUint atts;
|
sl@0
|
870 |
r=file.Att(atts);
|
sl@0
|
871 |
test(r==KErrNone);
|
sl@0
|
872 |
file.Close();
|
sl@0
|
873 |
test(atts&KEntryAttHidden);
|
sl@0
|
874 |
|
sl@0
|
875 |
// Change attributes from hidden to system
|
sl@0
|
876 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
877 |
r=file.SetAtt(KEntryAttSystem,KEntryAttHidden);
|
sl@0
|
878 |
test(r==KErrNone);
|
sl@0
|
879 |
file.Close();
|
sl@0
|
880 |
|
sl@0
|
881 |
// Check attributes have been changed
|
sl@0
|
882 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
883 |
r=file.Att(atts);
|
sl@0
|
884 |
test(r==KErrNone);
|
sl@0
|
885 |
file.Close();
|
sl@0
|
886 |
test(atts&KEntryAttSystem);
|
sl@0
|
887 |
|
sl@0
|
888 |
// Change attributes to normal
|
sl@0
|
889 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
890 |
r=file.SetAtt(KEntryAttNormal,KEntryAttSystem|KEntryAttArchive);
|
sl@0
|
891 |
test(r==KErrNone);
|
sl@0
|
892 |
file.Close();
|
sl@0
|
893 |
|
sl@0
|
894 |
// Check attributes have been changed
|
sl@0
|
895 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
896 |
r=file.Att(atts);
|
sl@0
|
897 |
test(r==KErrNone);
|
sl@0
|
898 |
file.Close();
|
sl@0
|
899 |
test(atts==KEntryAttNormal);
|
sl@0
|
900 |
|
sl@0
|
901 |
// Attempt to change attributes from normal file to directory
|
sl@0
|
902 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
903 |
r=file.SetAtt(KEntryAttDir,KEntryAttNormal);
|
sl@0
|
904 |
test(r==KErrNone); // Returns KErrNone but DOESN'T change the file to a directory
|
sl@0
|
905 |
file.Close();
|
sl@0
|
906 |
|
sl@0
|
907 |
// Check the file has not been changed to a directory
|
sl@0
|
908 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
909 |
r=file.Att(atts);
|
sl@0
|
910 |
test(r==KErrNone);
|
sl@0
|
911 |
file.Close();
|
sl@0
|
912 |
test((TInt)(atts&KEntryAttDir)==KErrNone);
|
sl@0
|
913 |
|
sl@0
|
914 |
// Change the attributes from normal file to hidden file
|
sl@0
|
915 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
916 |
r=file.SetAtt(KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
917 |
test(r==KErrNone);
|
sl@0
|
918 |
file.Close();
|
sl@0
|
919 |
|
sl@0
|
920 |
// Check the attributes have been changed
|
sl@0
|
921 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
922 |
r=file.Att(atts);
|
sl@0
|
923 |
test(r==KErrNone);
|
sl@0
|
924 |
file.Close();
|
sl@0
|
925 |
test(atts&KEntryAttHidden);
|
sl@0
|
926 |
|
sl@0
|
927 |
// Try to change the attributes from hidden file to volume
|
sl@0
|
928 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
929 |
r=file.SetAtt(KEntryAttVolume,KEntryAttHidden);
|
sl@0
|
930 |
test(r==KErrNone); // Returns KErrNone but DOESN'T change the file to a volume
|
sl@0
|
931 |
file.Close();
|
sl@0
|
932 |
|
sl@0
|
933 |
// Check that the hidden file has not been changed to a volume
|
sl@0
|
934 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
935 |
r=file.Att(atts);
|
sl@0
|
936 |
test(r==KErrNone);
|
sl@0
|
937 |
file.Close();
|
sl@0
|
938 |
test((TInt)(atts&KEntryAttVolume)==KErrNone);
|
sl@0
|
939 |
|
sl@0
|
940 |
// Test RFile::Set() function
|
sl@0
|
941 |
|
sl@0
|
942 |
test.Next(_L("Test RFile::Set()"));
|
sl@0
|
943 |
|
sl@0
|
944 |
// Check attributes
|
sl@0
|
945 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
946 |
r=file.Att(atts);
|
sl@0
|
947 |
test(r==KErrNone);
|
sl@0
|
948 |
file.Close();
|
sl@0
|
949 |
test(atts==KEntryAttNormal);
|
sl@0
|
950 |
|
sl@0
|
951 |
// Change attributes from hidden to system - and change modification time
|
sl@0
|
952 |
TDateTime dateTime(1998,EMay,25,18,23,0,0);
|
sl@0
|
953 |
TTime modTime1(dateTime);
|
sl@0
|
954 |
TTime retTime;
|
sl@0
|
955 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
956 |
r=file.Set(modTime1,KEntryAttSystem,KEntryAttNormal);
|
sl@0
|
957 |
test(r==KErrNone);
|
sl@0
|
958 |
file.Close();
|
sl@0
|
959 |
|
sl@0
|
960 |
// Check attributes have been changed
|
sl@0
|
961 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
962 |
r=file.Att(atts);
|
sl@0
|
963 |
test(r==KErrNone);
|
sl@0
|
964 |
r=file.Modified(retTime);
|
sl@0
|
965 |
test(r==KErrNone);
|
sl@0
|
966 |
file.Close();
|
sl@0
|
967 |
test(atts&KEntryAttSystem);
|
sl@0
|
968 |
test(retTime==modTime1);
|
sl@0
|
969 |
|
sl@0
|
970 |
// Change attributes to normal - and change modification time
|
sl@0
|
971 |
dateTime.Set(1997,EMay,24,17,25,0,0);
|
sl@0
|
972 |
TTime modTime2(dateTime);
|
sl@0
|
973 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
974 |
r=file.Set(modTime2,KEntryAttNormal,KEntryAttSystem|KEntryAttArchive);
|
sl@0
|
975 |
test(r==KErrNone);
|
sl@0
|
976 |
file.Close();
|
sl@0
|
977 |
|
sl@0
|
978 |
// Check attributes have been changed
|
sl@0
|
979 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
980 |
r=file.Att(atts);
|
sl@0
|
981 |
test(r==KErrNone);
|
sl@0
|
982 |
r=file.Modified(retTime);
|
sl@0
|
983 |
test(r==KErrNone);
|
sl@0
|
984 |
file.Close();
|
sl@0
|
985 |
test(atts==KEntryAttNormal);
|
sl@0
|
986 |
test(retTime==modTime2);
|
sl@0
|
987 |
|
sl@0
|
988 |
// Attempt to change attributes from normal file to directory
|
sl@0
|
989 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
990 |
r=file.Set(modTime1,KEntryAttDir,KEntryAttNormal);
|
sl@0
|
991 |
test(r==KErrNone); // Returns KErrNone but DOESN'T change the file to a directory
|
sl@0
|
992 |
file.Close();
|
sl@0
|
993 |
|
sl@0
|
994 |
// Check the file has not been changed to a directory
|
sl@0
|
995 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
996 |
r=file.Att(atts);
|
sl@0
|
997 |
test(r==KErrNone);
|
sl@0
|
998 |
r=file.Modified(retTime);
|
sl@0
|
999 |
test(r==KErrNone);
|
sl@0
|
1000 |
file.Close();
|
sl@0
|
1001 |
test((TInt)(atts&KEntryAttDir)==KErrNone);
|
sl@0
|
1002 |
test(retTime==modTime1);// Modification time should have been set successfully
|
sl@0
|
1003 |
|
sl@0
|
1004 |
// Change the attributes from normal file to hidden file - and change modification time
|
sl@0
|
1005 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
1006 |
r=file.Set(modTime1,KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
1007 |
test(r==KErrNone);
|
sl@0
|
1008 |
file.Close();
|
sl@0
|
1009 |
|
sl@0
|
1010 |
// Check the attributes have been changed
|
sl@0
|
1011 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
1012 |
r=file.Att(atts);
|
sl@0
|
1013 |
test(r==KErrNone);
|
sl@0
|
1014 |
r=file.Modified(retTime);
|
sl@0
|
1015 |
file.Close();
|
sl@0
|
1016 |
test(atts&KEntryAttHidden);
|
sl@0
|
1017 |
test(retTime==modTime1);
|
sl@0
|
1018 |
|
sl@0
|
1019 |
// Try to change the attributes from hidden file to volume
|
sl@0
|
1020 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
1021 |
r=file.Set(modTime2,KEntryAttVolume,KEntryAttHidden);
|
sl@0
|
1022 |
test(r==KErrNone); // Returns KErrNone but DOESN'T change the file to a volume
|
sl@0
|
1023 |
file.Close();
|
sl@0
|
1024 |
|
sl@0
|
1025 |
// Check that the hidden file has not been changed to a volume
|
sl@0
|
1026 |
file.Open(TheFs,_L("TEMPFILE.TMP"),EFileWrite);
|
sl@0
|
1027 |
r=file.Att(atts);
|
sl@0
|
1028 |
test(r==KErrNone);
|
sl@0
|
1029 |
r=file.Modified(retTime);
|
sl@0
|
1030 |
test(r==KErrNone);
|
sl@0
|
1031 |
file.Close();
|
sl@0
|
1032 |
test((TInt)(atts&KEntryAttVolume)==KErrNone);
|
sl@0
|
1033 |
test(retTime==modTime2); // Modification time should have been set successfully
|
sl@0
|
1034 |
|
sl@0
|
1035 |
r=TheFs.Delete(_L("TEMPFILE.TMP"));
|
sl@0
|
1036 |
|
sl@0
|
1037 |
}
|
sl@0
|
1038 |
|
sl@0
|
1039 |
|
sl@0
|
1040 |
GLDEF_C void CallTestsL()
|
sl@0
|
1041 |
//
|
sl@0
|
1042 |
// Do tests relative to session path
|
sl@0
|
1043 |
//
|
sl@0
|
1044 |
{
|
sl@0
|
1045 |
|
sl@0
|
1046 |
TurnAllocFailureOff();
|
sl@0
|
1047 |
CreateTestDirectory(_L("\\F32-TST\\TNMBS\\"));
|
sl@0
|
1048 |
testMkDirRmDir(); // Must come first
|
sl@0
|
1049 |
testSetEntry();
|
sl@0
|
1050 |
testSetFileAttributes();
|
sl@0
|
1051 |
testRename();
|
sl@0
|
1052 |
TestLongFileName();
|
sl@0
|
1053 |
testRenameRegression();
|
sl@0
|
1054 |
testRenameCase();
|
sl@0
|
1055 |
testMaxNameLength();
|
sl@0
|
1056 |
testEntry();
|
sl@0
|
1057 |
testReplace();
|
sl@0
|
1058 |
testErrorReturnValues();
|
sl@0
|
1059 |
DeleteTestDirectory();
|
sl@0
|
1060 |
}
|
sl@0
|
1061 |
|