13 // Description: |
13 // Description: |
14 // f32\sfat\sl_dir.cpp |
14 // f32\sfat\sl_dir.cpp |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
|
18 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
19 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
20 //!! |
|
21 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it |
|
22 //!! |
|
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
25 |
18 #include "sl_std.h" |
26 #include "sl_std.h" |
19 |
27 |
20 CFatDirCB* CFatDirCB::NewL() |
28 CFatDirCB* CFatDirCB::NewL() |
21 // |
29 // |
22 // Static constructor |
30 // Static constructor |
23 // |
31 // |
24 { |
32 { |
25 |
33 |
26 CFatDirCB* fatDirCB=new(ELeave) CFatDirCB; |
34 CFatDirCB* fatDirCB=new(ELeave) CFatDirCB; |
27 return fatDirCB; |
35 return fatDirCB; |
28 } |
36 } |
29 |
37 |
30 CFatDirCB::CFatDirCB() |
38 CFatDirCB::CFatDirCB() |
31 // |
39 // |
32 // Constructor |
40 // Constructor |
33 // |
41 // |
34 { |
42 { |
35 } |
43 } |
36 |
44 |
37 CFatDirCB::~CFatDirCB() |
45 CFatDirCB::~CFatDirCB() |
38 // |
46 // |
39 // Destructor |
47 // Destructor |
40 // |
48 // |
41 { |
49 { |
42 |
50 |
43 delete iMatch; |
51 delete iMatch; |
44 delete iLongNameBuf; |
52 delete iLongNameBuf; |
45 } |
53 } |
46 |
54 |
47 void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName) |
55 void CFatDirCB::SetDirL(const TFatDirEntry& anEntry,const TDesC& aName) |
48 // |
56 // |
49 // Set the current entry to anEntryAddr |
57 // Set the current entry to anEntryAddr |
50 // |
58 // |
51 { |
59 { |
52 |
60 |
53 __PRINT(_L("CFatDirCB::SetDirL")); |
61 __PRINT(_L("CFatDirCB::SetDirL")); |
54 // iEntryAddr=0; |
62 // iEntryAddr=0; |
55 // iPending=EFalse; |
63 // iPending=EFalse; |
56 iEntry=anEntry; |
64 iEntry=anEntry; |
57 iCurrentPos.iCluster= FatMount().StartCluster(iEntry); |
65 iCurrentPos.iCluster= FatMount().StartCluster(iEntry); |
58 iMatch=aName.AllocL(); |
66 iMatch=aName.AllocL(); |
59 if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null()) |
67 if (iUidType[0]!=TUid::Null() || iUidType[1]!=TUid::Null() || iUidType[2]!=TUid::Null()) |
60 iMatchUid=ETrue; |
68 iMatchUid=ETrue; |
61 } |
69 } |
62 |
70 |
63 LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor) |
71 LOCAL_C TBool CompareUid(const TUidType& aUidTrg, const TUidType& aUidSuitor) |
64 // |
72 // |
65 // Compare the suitor to the target pattern |
73 // Compare the suitor to the target pattern |
66 // |
74 // |
67 { |
75 { |
68 |
76 |
69 if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0]) |
77 if (aUidTrg[0]!=TUid::Null() && aUidTrg[0]!=aUidSuitor[0]) |
70 return(EFalse); |
78 return(EFalse); |
71 if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1]) |
79 if (aUidTrg[1]!=TUid::Null() && aUidTrg[1]!=aUidSuitor[1]) |
72 return(EFalse); |
80 return(EFalse); |
73 if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2]) |
81 if (aUidTrg[2]!=TUid::Null() && aUidTrg[2]!=aUidSuitor[2]) |
74 return(EFalse); |
82 return(EFalse); |
75 return(ETrue); |
83 return(ETrue); |
76 } |
84 } |
77 |
85 |
78 void CFatDirCB::ReadL(TEntry &anEntry) |
86 void CFatDirCB::ReadL(TEntry &anEntry) |
79 // |
87 // |
80 // Read the next entry from the directory. |
88 // Read the next entry from the directory. |
81 // |
89 // |
82 { |
90 { |
83 |
91 |
84 __PRINT(_L("CFatDirCB::ReadL")); |
92 __PRINT(_L("CFatDirCB::ReadL")); |
85 |
93 |
86 FatMount().CheckStateConsistentL(); |
94 FatMount().CheckStateConsistentL(); |
87 |
95 |
88 |
96 |
89 Mem::FillZ(&anEntry.iType,sizeof(TUidType)); |
97 Mem::FillZ(&anEntry.iType,sizeof(TUidType)); |
90 |
98 |
91 TPtr entryName(anEntry.iName.Des()); |
99 TPtr entryName(anEntry.iName.Des()); |
92 FOREVER |
100 FOREVER |
93 { |
101 { |
94 if (iPending) |
102 if (iPending) |
95 entryName=(*iLongNameBuf); |
103 entryName=(*iLongNameBuf); |
96 else |
104 else |
97 { |
105 { |
98 FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof); |
106 FatMount().FindDosNameL(*iMatch,iAtt,iCurrentPos,iEntry,entryName,KErrEof); |
99 FatMount().MoveToNextEntryL(iCurrentPos); |
107 FatMount().MoveToNextEntryL(iCurrentPos); |
100 } |
108 } |
101 iPending=EFalse; |
109 iPending=EFalse; |
102 if (iEntry.Attributes()&~KEntryAttMaskSupported) |
110 if (iEntry.Attributes()&~KEntryAttMaskSupported) |
103 continue; // Ignore illegal entries |
111 continue; // Ignore illegal entries |
104 anEntry.iAtt=iEntry.Attributes(); |
112 anEntry.iAtt=iEntry.Attributes(); |
105 anEntry.iSize=iEntry.Size(); |
113 anEntry.iSize=iEntry.Size(); |
106 anEntry.iModified=iEntry.Time(FatMount().TimeOffset() ); |
114 anEntry.iModified=iEntry.Time(FatMount().TimeOffset() ); |
107 |
115 |
108 if (entryName.Length()==0) |
116 if (entryName.Length()==0) |
109 { |
117 { |
110 // VFAT entry names are always created for UNICODE at an earlier stage |
118 // VFAT entry names are always created for UNICODE at an earlier stage |
111 // However, UNICODE builds may still encounter genuine FAT filenames through |
119 // However, UNICODE builds may still encounter genuine FAT filenames through |
112 // the introduction of files created using a narrow (ASCII) build |
120 // the introduction of files created using a narrow (ASCII) build |
113 TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name())); |
121 TBuf8<0x20> dosName(DosNameFromStdFormat(iEntry.Name())); |
114 LocaleUtils::ConvertToUnicodeL(entryName, dosName); |
122 LocaleUtils::ConvertToUnicodeL(entryName, dosName); |
115 } |
123 } |
116 TBool matchedUid=ETrue; |
124 TBool matchedUid=ETrue; |
117 if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse) |
125 if (iMatchUid && (anEntry.iAtt&KEntryAttDir)==EFalse) |
118 { |
126 { |
119 if ((TUint)anEntry.iSize>=sizeof(TCheckedUid)) |
127 if ((TUint)anEntry.iSize>=sizeof(TCheckedUid)) |
120 FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry); |
128 FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry); |
121 if (CompareUid(iUidType,anEntry.iType)==EFalse) |
129 if (CompareUid(iUidType,anEntry.iType)==EFalse) |
122 matchedUid=EFalse; |
130 matchedUid=EFalse; |
123 } |
131 } |
124 |
132 |
125 if (matchedUid) |
133 if (matchedUid) |
126 break; |
134 break; |
127 } |
135 } |
128 if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid)) |
136 if ((iAtt&KEntryAttAllowUid)==0 || (anEntry.iAtt&KEntryAttDir) || (TUint)anEntry.iSize<sizeof(TCheckedUid)) |
129 return; |
137 return; |
130 if (iMatchUid==EFalse) |
138 if (iMatchUid==EFalse) |
131 { |
139 { |
132 TInt r; |
140 TInt r; |
133 TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry)); |
141 TRAP(r,FatMount().ReadUidL(FatMount().StartCluster(iEntry),anEntry)); |
134 if(r!=KErrNone && r!=KErrCorrupt) |
142 if(r!=KErrNone && r!=KErrCorrupt) |
135 User::Leave(r); |
143 User::Leave(r); |
136 } |
144 } |
137 } |
145 } |
138 |
146 |
139 void CFatDirCB::StoreLongEntryNameL(const TDesC& aName) |
147 void CFatDirCB::StoreLongEntryNameL(const TDesC& aName) |
140 // |
148 // |
141 // Store aName while next read is pending |
149 // Store aName while next read is pending |
142 // |
150 // |
143 { |
151 { |
144 |
152 |
145 AllocBufferL(iLongNameBuf,aName); |
153 AllocBufferL(iLongNameBuf,aName); |
146 } |
154 } |