author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\server\b_osfil.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
23 |
const TInt KSizeExistsFile=26; |
|
24 |
const TInt KSizeExistsFile2=25; |
|
25 |
||
26 |
GLDEF_D RTest test(_L("B_OSFIL")); |
|
27 |
||
28 |
/* these buffers get written to in order to change the file system */ |
|
29 |
//LOCAL_D TBuf<5> fileSystemName =_L("LOC::"); /* default file system name */ |
|
30 |
LOCAL_D TBuf<20> noDevice = _L("L:\\tmpfile.tmp"); |
|
31 |
LOCAL_D TBuf<15> noDevicePath = _L("L:\\"); |
|
32 |
LOCAL_D TBuf<28> noDirectory = _L("C:\\nodirect\\tmpfile.tmp"); |
|
33 |
LOCAL_D TBuf<30> noDirectoryPath = _L("C:\\nodirect\\"); |
|
34 |
LOCAL_D TBuf<20> noFile = _L("C:\\notafile.tmp"); |
|
35 |
LOCAL_D TBuf<19> fileName = _L("C:\\tmpfile.tmp"); |
|
36 |
LOCAL_D TBuf<20> existsFile = _L("C:\\tmpexst1.tmp"); |
|
37 |
LOCAL_D TBuf<20> existsFile2 = _L("C:\\tmpexst2.tmp"); |
|
38 |
LOCAL_D TBuf<21> renameFile1 = _L("C:\\tmpren1.tmp"); |
|
39 |
LOCAL_D TBuf<21> renameFile2 = _L("C:\\tmpren2.tmp"); |
|
40 |
LOCAL_D TBuf<34> directoryFile = _L("C:\\nodirect\\nodirect\\nodirect\\"); |
|
41 |
LOCAL_D TBuf<14> openUniqueDir = _L("C:\\nodir2\\"); |
|
42 |
||
43 |
/*************************************************************************/ |
|
44 |
LOCAL_C void TestInfo() |
|
45 |
/* |
|
46 |
Test the file info function |
|
47 |
*/ |
|
48 |
{ |
|
49 |
TEntry entry; |
|
50 |
TInt r=TheFs.Entry(noDevice,entry); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
test_Value(r, (r == KErrNotReady)||(r==KErrPathNotFound)); |
0 | 52 |
r=TheFs.Entry(noDirectory,entry); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
test_Value(r, r == KErrPathNotFound); |
0 | 54 |
r=TheFs.Entry(noFile,entry); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
test_Value(r, r == KErrNotFound); |
0 | 56 |
r=TheFs.Entry(existsFile,entry); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
test_KErrNone(r); |
0 | 58 |
test(entry.iSize==KSizeExistsFile); |
59 |
test(!entry.IsDir()); |
|
60 |
test(!(entry.iAtt&KEntryAttDir)); |
|
61 |
r=TheFs.Entry(existsFile2,entry); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
test_KErrNone(r); |
0 | 63 |
test(entry.iSize==KSizeExistsFile2); |
64 |
test(!entry.IsDir()); |
|
65 |
test(!(entry.iAtt&KEntryAttDir)); |
|
66 |
} |
|
67 |
||
68 |
LOCAL_C void TestDelete() |
|
69 |
/* |
|
70 |
Test the delete |
|
71 |
*/ |
|
72 |
{ |
|
73 |
TInt r=TheFs.Delete(noDevice); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
test_Value(r, (r == KErrNotReady)||(r==KErrPathNotFound)); |
0 | 75 |
r=TheFs.Delete(noDirectory); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
test_Value(r, r == KErrPathNotFound); |
0 | 77 |
r=TheFs.Delete(noFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
test_Value(r, r == KErrNotFound); |
0 | 79 |
r=TheFs.Delete(existsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
test_KErrNone(r); |
0 | 81 |
r=TheFs.Delete(existsFile2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
test_KErrNone(r); |
0 | 83 |
TEntry entry; |
84 |
r=TheFs.Entry(existsFile,entry); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
test_Value(r, r == KErrNotFound); |
0 | 86 |
r=TheFs.Entry(existsFile2,entry); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
test_Value(r, r == KErrNotFound); |
0 | 88 |
} |
89 |
||
90 |
LOCAL_C void TestRename() |
|
91 |
/* |
|
92 |
Test the rename |
|
93 |
*/ |
|
94 |
{ |
|
95 |
TInt r=TheFs.Rename(noDevice,fileName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
test_Value(r, r == KErrArgument); |
0 | 97 |
r=TheFs.Rename(noDirectory,fileName); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
test_Value(r, r == KErrPathNotFound); |
0 | 99 |
r=TheFs.Rename(noFile,fileName); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
test_Value(r, r == KErrNotFound); |
0 | 101 |
r=TheFs.Rename(existsFile,existsFile2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
test_Value(r, r == KErrAlreadyExists); |
0 | 103 |
r=TheFs.Delete(existsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
test_KErrNone(r); |
0 | 105 |
r=TheFs.Rename(existsFile,existsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
test_Value(r, r == KErrNotFound); |
0 | 107 |
r=TheFs.Rename(existsFile2,existsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
test_KErrNone(r); |
0 | 109 |
TEntry entry; |
110 |
r=TheFs.Entry(existsFile2,entry); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
test_Value(r, r == KErrNotFound); |
0 | 112 |
r=TheFs.Entry(existsFile,entry); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
test_KErrNone(r); |
0 | 114 |
r=TheFs.Delete(existsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
test_KErrNone(r); |
0 | 116 |
} |
117 |
||
118 |
LOCAL_C void TestMkDir() |
|
119 |
{ |
|
120 |
TParse fparse; |
|
121 |
TInt r=TheFs.MkDirAll(directoryFile); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
test_KErrNone(r); |
0 | 123 |
TEntry entry; |
124 |
r=TheFs.Entry(directoryFile.Left(directoryFile.Length()-1),entry); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
test_KErrNone(r); |
0 | 126 |
test(entry.IsDir()); |
127 |
test(entry.iAtt&KEntryAttDir); |
|
128 |
r=TheFs.RmDir(directoryFile); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
test_KErrNone(r); |
0 | 130 |
r=fparse.Set(directoryFile,NULL,NULL); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
test_KErrNone(r); |
0 | 132 |
r=fparse.PopDir(); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
test_KErrNone(r); |
0 | 134 |
r=TheFs.RmDir(fparse.DriveAndPath()); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
test_KErrNone(r); |
0 | 136 |
r=fparse.PopDir(); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
test_KErrNone(r); |
0 | 138 |
r=TheFs.RmDir(fparse.DriveAndPath()); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
test_KErrNone(r); |
0 | 140 |
} |
141 |
||
142 |
||
143 |
LOCAL_C void TestOpenUnique() |
|
144 |
/* |
|
145 |
Test unique file name generator |
|
146 |
*/ |
|
147 |
{ |
|
148 |
RFile p1; |
|
149 |
RFile p2; |
|
150 |
||
151 |
TInt r=p1.Open(TheFs,noDevice,EFileStreamText); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
test_Value(r, (r == KErrNotReady)||(r==KErrPathNotFound)); |
0 | 153 |
r=p1.Open(TheFs,noDirectory,EFileStreamText); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
154 |
test_Value(r, r == KErrPathNotFound); |
0 | 155 |
TFileName generated1; |
156 |
r=p1.Temp(TheFs,noDevicePath,generated1,EFileStreamText); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
test_Value(r, (r == KErrNotReady)||(r==KErrPathNotFound)); |
0 | 158 |
r=p1.Temp(TheFs,noDirectoryPath,generated1,EFileStreamText); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
test_Value(r, r == KErrPathNotFound); |
0 | 160 |
|
161 |
r=p1.Temp(TheFs,_L(""),generated1,EFileStreamText); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
test_KErrNone(r); |
0 | 163 |
TFileName generated2; |
164 |
r=p2.Temp(TheFs,_L(""),generated2,EFileStreamText); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
test_KErrNone(r); |
0 | 166 |
test(generated1!=generated2); |
167 |
p1.Close(); |
|
168 |
TFileName generated3; |
|
169 |
r=p1.Temp(TheFs,_L(""),generated3,EFileStream); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
test_KErrNone(r); |
0 | 171 |
test(generated3!=generated2); |
172 |
test(generated3!=generated1); |
|
173 |
p2.Close(); |
|
174 |
p1.Close(); |
|
175 |
||
176 |
r=TheFs.Delete(generated1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
test_KErrNone(r); |
0 | 178 |
r=TheFs.Delete(generated2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
test_KErrNone(r); |
0 | 180 |
r=TheFs.Delete(generated3); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
test_KErrNone(r); |
0 | 182 |
|
183 |
r=p1.Temp(TheFs,_L(""),generated1,EFileStreamText); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
test_KErrNone(r); |
0 | 185 |
r=p2.Temp(TheFs,_L(""),generated2,EFileStreamText); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
test_KErrNone(r); |
0 | 187 |
test(generated1!=generated2); |
188 |
p1.Close(); |
|
189 |
r=p1.Temp(TheFs,_L(""),generated3,EFileStream); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
test_KErrNone(r); |
0 | 191 |
test(generated3!=generated2); |
192 |
test(generated3!=generated1); |
|
193 |
p2.Close(); |
|
194 |
p1.Close(); |
|
195 |
||
196 |
r=TheFs.Delete(generated1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
test_KErrNone(r); |
0 | 198 |
r=TheFs.Delete(generated2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
test_KErrNone(r); |
0 | 200 |
r=TheFs.Delete(generated3); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
test_KErrNone(r); |
0 | 202 |
|
203 |
r=TheFs.MkDir(openUniqueDir); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
test_KErrNone(r); |
0 | 205 |
r=p1.Temp(TheFs,openUniqueDir,generated1,EFileStream); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
test_KErrNone(r); |
0 | 207 |
r=p2.Temp(TheFs,openUniqueDir,generated2,EFileStreamText|EFileWrite); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
test_KErrNone(r); |
0 | 209 |
r=p1.Write(_L8("junk"),4); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
test_KErrNone(r); |
0 | 211 |
TInt pos=0; |
212 |
r=p1.Seek(ESeekCurrent,pos);//P_FSET |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
test_KErrNone(r); |
0 | 214 |
p1.Close(); |
215 |
p2.Close(); |
|
216 |
||
217 |
r=TheFs.Delete(generated1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
test_KErrNone(r); |
0 | 219 |
r=TheFs.Delete(generated2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
test_KErrNone(r); |
0 | 221 |
|
222 |
r=p1.Temp(TheFs,openUniqueDir,generated1,EFileStream); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
test_KErrNone(r); |
0 | 224 |
r=p2.Temp(TheFs,openUniqueDir,generated2,EFileStreamText); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
test_KErrNone(r); |
0 | 226 |
p1.Close(); |
227 |
||
228 |
pos=0; |
|
229 |
r=p2.Seek(ESeekStart,pos); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
test_KErrNone(r); |
0 | 231 |
p2.Close(); |
232 |
r=TheFs.Delete(generated1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
test_KErrNone(r); |
0 | 234 |
r=TheFs.Delete(generated2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
test_KErrNone(r); |
0 | 236 |
r=TheFs.RmDir(openUniqueDir); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
test_KErrNone(r); |
0 | 238 |
} |
239 |
||
240 |
LOCAL_C void TestPaths() |
|
241 |
{ |
|
242 |
TFileName path1; |
|
243 |
TInt r=TheFs.SessionPath(path1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
test_KErrNone(r); |
0 | 245 |
r=TheFs.SetSessionPath(path1); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
test_KErrNone(r); |
0 | 247 |
TFileName path2; |
248 |
r=TheFs.SessionPath(path2); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
test_KErrNone(r); |
0 | 250 |
test(path1==path2); |
251 |
RDir dir; |
|
252 |
r=dir.Open(TheFs,path1,0); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
test_KErrNone(r); |
0 | 254 |
dir.Close(); |
255 |
} |
|
256 |
||
257 |
LOCAL_C void TestFileStatus() |
|
258 |
{ |
|
259 |
TEntry blk; |
|
260 |
TInt r=TheFs.Entry(existsFile,blk); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
test_KErrNone(r); |
0 | 262 |
TEntry blk1=blk; |
263 |
||
264 |
/* Toggle the write attribute */ |
|
265 |
TUint clear,set; /* were modifying write attrib */ |
|
266 |
if (blk1.IsReadOnly()) |
|
267 |
{ |
|
268 |
clear=KEntryAttReadOnly; |
|
269 |
set=0; |
|
270 |
} |
|
271 |
else |
|
272 |
{ |
|
273 |
clear=0; |
|
274 |
set=KEntryAttReadOnly; |
|
275 |
} |
|
276 |
r=TheFs.SetEntry(existsFile,blk1.iModified,set,clear); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
test_KErrNone(r); |
0 | 278 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
test_KErrNone(r); |
0 | 280 |
if (blk1.IsReadOnly()) |
281 |
test(!blk.IsReadOnly()); |
|
282 |
else |
|
283 |
test(blk.IsReadOnly()); |
|
284 |
||
285 |
/* set write attrib back */ |
|
286 |
r=TheFs.SetEntry(existsFile,blk1.iModified,clear,set); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
test_KErrNone(r); |
0 | 288 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
test_KErrNone(r); |
0 | 290 |
if (blk1.IsReadOnly()) |
291 |
test(blk.IsReadOnly()); |
|
292 |
else |
|
293 |
test(!blk.IsReadOnly()); |
|
294 |
||
295 |
/* toggle the archive bit */ |
|
296 |
if (blk1.IsArchive()) |
|
297 |
{ |
|
298 |
clear=KEntryAttArchive; |
|
299 |
set=0; |
|
300 |
} |
|
301 |
else |
|
302 |
{ |
|
303 |
clear=0; |
|
304 |
set=KEntryAttArchive; |
|
305 |
} |
|
306 |
r=TheFs.SetEntry(existsFile,blk1.iModified,set,clear); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
test_KErrNone(r); |
0 | 308 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
test_KErrNone(r); |
0 | 310 |
if (blk1.IsArchive()) |
311 |
test(!blk.IsArchive()); |
|
312 |
else |
|
313 |
test(blk.IsArchive()); |
|
314 |
/* set archive attrib back */ |
|
315 |
r=TheFs.SetEntry(existsFile,blk1.iModified,clear,set); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
test_KErrNone(r); |
0 | 317 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
test_KErrNone(r); |
0 | 319 |
if (blk1.IsArchive()) |
320 |
test(blk.IsArchive()); |
|
321 |
else |
|
322 |
test(!blk.IsArchive()); |
|
323 |
||
324 |
/* toggle the hidden bit */ |
|
325 |
if (blk1.IsHidden()) |
|
326 |
{ |
|
327 |
clear=KEntryAttHidden; |
|
328 |
set=0; |
|
329 |
} |
|
330 |
else |
|
331 |
{ |
|
332 |
clear=0; |
|
333 |
set=KEntryAttHidden; |
|
334 |
} |
|
335 |
r=TheFs.SetEntry(existsFile,blk1.iModified,set,clear); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
test_KErrNone(r); |
0 | 337 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
test_KErrNone(r); |
0 | 339 |
if (blk1.IsHidden()) |
340 |
test(!blk.IsHidden()); |
|
341 |
else |
|
342 |
test(blk.IsHidden()); |
|
343 |
/* set hidden attrib back */ |
|
344 |
r=TheFs.SetEntry(existsFile,blk1.iModified,clear,set); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
test_KErrNone(r); |
0 | 346 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
test_KErrNone(r); |
0 | 348 |
if (blk1.IsHidden()) |
349 |
test(blk.IsHidden()); |
|
350 |
else |
|
351 |
test(!blk.IsHidden()); |
|
352 |
||
353 |
/* toggle the system bit */ |
|
354 |
if (blk1.IsSystem()) |
|
355 |
{ |
|
356 |
clear=KEntryAttSystem; |
|
357 |
set=0; |
|
358 |
} |
|
359 |
else |
|
360 |
{ |
|
361 |
clear=0; |
|
362 |
set=KEntryAttSystem; |
|
363 |
} |
|
364 |
r=TheFs.SetEntry(existsFile,blk1.iModified,set,clear); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
test_KErrNone(r); |
0 | 366 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
test_KErrNone(r); |
0 | 368 |
if (blk1.IsSystem()) |
369 |
test(!blk.IsSystem()); |
|
370 |
else |
|
371 |
test(blk.IsSystem()); |
|
372 |
/* set system attrib back */ |
|
373 |
r=TheFs.SetEntry(existsFile,blk1.iModified,clear,set); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
test_KErrNone(r); |
0 | 375 |
r=TheFs.Entry(existsFile,blk); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
test_KErrNone(r); |
0 | 377 |
if (blk1.IsSystem()) |
378 |
test(blk.IsSystem()); |
|
379 |
else |
|
380 |
test(!blk.IsSystem()); |
|
381 |
r=TheFs.Delete(existsFile); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
382 |
test_KErrNone(r); |
0 | 383 |
r=TheFs.Delete(existsFile2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
384 |
test_KErrNone(r); |
0 | 385 |
} |
386 |
||
387 |
||
388 |
LOCAL_C void CreateTestFiles() |
|
389 |
{ |
|
390 |
RFile fcb; |
|
391 |
TInt r=fcb.Replace(TheFs,existsFile,EFileWrite); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
test_KErrNone(r); |
0 | 393 |
r=fcb.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),KSizeExistsFile); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
394 |
test_KErrNone(r); |
0 | 395 |
fcb.Close(); |
396 |
||
397 |
r=fcb.Replace(TheFs,existsFile2,EFileWrite); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
test_KErrNone(r); |
0 | 399 |
r=fcb.Write(_L8("bcdefghijklmnopqrstuvwxyz"),KSizeExistsFile2); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
test_KErrNone(r); |
0 | 401 |
fcb.Close(); |
402 |
} |
|
403 |
||
404 |
GLDEF_C void CallTestsL(void) |
|
405 |
// |
|
406 |
// Do testing on aDrive |
|
407 |
// |
|
408 |
{ |
|
409 |
test.Title(); |
|
410 |
||
411 |
TVolumeInfo di; |
|
412 |
TInt r=TheFs.Volume(di); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
test_KErrNone(r); |
0 | 414 |
test.Start(_L("Info()")); |
415 |
CreateTestFiles(); |
|
416 |
TestInfo(); |
|
417 |
test.Next(_L("Delete()")); |
|
418 |
CreateTestFiles(); |
|
419 |
TestDelete(); |
|
420 |
test.Next(_L("Rename()")); |
|
421 |
CreateTestFiles(); |
|
422 |
TestRename(); |
|
423 |
test.Next(_L("MkDir()")); |
|
424 |
TestMkDir(); |
|
425 |
test.Next(_L("Temp()")); |
|
426 |
TestOpenUnique(); |
|
427 |
test.Next(_L("Paths")); |
|
428 |
TestPaths(); |
|
429 |
test.Next(_L("File status")); |
|
430 |
CreateTestFiles(); |
|
431 |
TestFileStatus(); |
|
432 |
test.End(); |
|
433 |
} |