|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <f32fsys.h> |
|
20 #include <f32ver.h> |
|
21 #include <e32uid.h> |
|
22 |
|
23 #include "svphostfsy.h" |
|
24 |
|
25 ////////////////////////////////////////////////////////////////////////// |
|
26 // CSVPHostDirCB // |
|
27 ////////////////////////////////////////////////////////////////////////// |
|
28 |
|
29 CSVPHostDirCB::CSVPHostDirCB(/*CSessionFs* aSession*/) |
|
30 // |
|
31 // Constructor |
|
32 // |
|
33 : CDirCB(/*aSession*/),iEntry() |
|
34 { |
|
35 __DECLARE_NAME(_S("CSVPHostDirCB")); |
|
36 } |
|
37 |
|
38 CSVPHostDirCB::~CSVPHostDirCB() |
|
39 // |
|
40 // Destructor |
|
41 // |
|
42 { |
|
43 DP(_L("** (SVPHOSTDIR) CSVPHostDirCB::~CSVPHostDirCB")); |
|
44 |
|
45 if ((TInt)iHandle == KErrBadHandle) return; |
|
46 |
|
47 SVP_HOST_FS_DEVICE().DirClose(Drive().DriveNumber(), iHandle); |
|
48 } |
|
49 |
|
50 TBool CSVPHostDirCB::MatchUid() |
|
51 // |
|
52 // Match the uid ? |
|
53 // |
|
54 { |
|
55 if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null()) |
|
56 return(ETrue); |
|
57 return(EFalse); |
|
58 } |
|
59 |
|
60 void fileTimeToTime(TUint32 t,TTime& aTime, TFileTimeType aType) |
|
61 // |
|
62 // Convert a time (in seconds from the epoc) into a TTIME |
|
63 // |
|
64 { |
|
65 TInt64 at =((TInt64)t) * 1000000; |
|
66 TTime time = TTime(at); |
|
67 if (aType == EWindows) |
|
68 { |
|
69 time += TTimeIntervalYears(1970); |
|
70 time += TTimeIntervalDays(1); |
|
71 } |
|
72 aTime=time; |
|
73 } |
|
74 |
|
75 LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor) |
|
76 // |
|
77 // Compare the suitor to the target pattern |
|
78 // |
|
79 { |
|
80 |
|
81 if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0]) |
|
82 return(EFalse); |
|
83 if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1]) |
|
84 return(EFalse); |
|
85 if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2]) |
|
86 return(EFalse); |
|
87 return(ETrue); |
|
88 } |
|
89 |
|
90 |
|
91 void CSVPHostDirCB::ReadL(TEntry& anEntry) |
|
92 // |
|
93 // Read the next entry from the directory |
|
94 // |
|
95 { |
|
96 DP(_L("** (SVPHOSTDIR) CSVPHostDirCB::ReadL")); |
|
97 |
|
98 TUint driveNumber = Drive().DriveNumber() ; |
|
99 FOREVER |
|
100 { |
|
101 if (!iPending) |
|
102 { |
|
103 TSVPHostFsDirReadInfo info(driveNumber, iHandle); |
|
104 User::LeaveIfError(SVP_HOST_FS_DEVICE().DirRead(info)); |
|
105 |
|
106 TPtr name((TUint16 *)&info.iName[0], info.iLength, KMaxPath); |
|
107 |
|
108 if (name==_L(".") || name==_L("..")) |
|
109 continue; |
|
110 |
|
111 iEntry.iName = name; |
|
112 iEntry.iAtt=info.iAtt&KEntryAttMaskSupported; |
|
113 iEntry.iSize=info.iSize; |
|
114 fileTimeToTime(info.iModified,iEntry.iModified, info.iTimeType); |
|
115 DP(_L("%S %d %x %x"), &name, iEntry.iAtt, iEntry.iSize, iEntry.iModified); |
|
116 } |
|
117 iPending=EFalse; |
|
118 anEntry=iEntry; |
|
119 if ((iFullName.NameAndExt()==_L("*.*") || anEntry.iName.MatchF(iFullName.NameAndExt())!=KErrNotFound) |
|
120 && Mount().MatchEntryAtt(anEntry.iAtt&KEntryAttMaskSupported,iAtt)) |
|
121 { |
|
122 if (MatchUid()) |
|
123 { |
|
124 TParse fileName; |
|
125 TBuf<KMaxFileName> path=iFullName.Path(); |
|
126 fileName.Set(anEntry.iName,&path,NULL); |
|
127 (*(CSVPHostMountCB*)&Mount()).ReadUidL(fileName.FullName(),anEntry); |
|
128 if (CompareUid(iUidType,anEntry.iType)) |
|
129 break; |
|
130 } |
|
131 else |
|
132 break; |
|
133 } |
|
134 break; |
|
135 } |
|
136 |
|
137 if ((iAtt&KEntryAttAllowUid)==0 || anEntry.iAtt&KEntryAttDir || MatchUid()) |
|
138 return; |
|
139 TParse fileName; |
|
140 TBuf<KMaxFileName> path=iFullName.Path(); |
|
141 fileName.Set(anEntry.iName,&path,NULL); |
|
142 (*(CSVPHostMountCB*)&Mount()).ReadUidL(fileName.FullName(),anEntry); |
|
143 |
|
144 return; |
|
145 } |
|
146 |
|
147 |
|
148 ////////////////////////////////////////////////////////////////////////// |
|
149 // CSVPHostFormatCB // |
|
150 ////////////////////////////////////////////////////////////////////////// |
|
151 |
|
152 CSVPHostFormatCB::CSVPHostFormatCB(/*CSessionFs* aSession*/)//???JCS |
|
153 // |
|
154 // Constructor |
|
155 // |
|
156 : CFormatCB(/*aSession*/) |
|
157 { |
|
158 __DECLARE_NAME(_S("CSVPHostFormatCB")); |
|
159 } |
|
160 |
|
161 CSVPHostFormatCB::~CSVPHostFormatCB() |
|
162 // |
|
163 // Destructor |
|
164 // |
|
165 {} |
|
166 |
|
167 void CSVPHostFormatCB::DoFormatStepL() |
|
168 // |
|
169 // Do Formatting |
|
170 // |
|
171 { |
|
172 iCurrentStep=0; |
|
173 User::Leave(KErrNotSupported); |
|
174 } |
|
175 |