1 //-------------------------------------------------------------------------
2 //
3 // For conditions of distribution and use, see copyright notice
4 // in Flashpix.h
5 //
6 // Copyright (c) 1999 Digital Imaging Group, Inc.
7 //
8 // Contents: Iterator code for MSF
9 //
10 // Classes: None. (Defined in iter.hxx)
11 //
12 //--------------------------------------------------------------------------
13
14 #include "msfhead.cxx"
15
16
17 #include "h/dirfunc.hxx"
18 #include "h/msfiter.hxx"
19
20 //+-------------------------------------------------------------------------
21 //
22 // Member: CMSFIterator::GetNext, public
23 //
24 // Synposis: Fill in a stat buffer for the next iteration entry
25 //
26 // Effects: Modifies _sidCurrent
27 //
28 // Arguments: [pstat] - Stat buffer
29 //
30 // Returns: S_OK if call completed OK.
31 // STG_E_NOMOREFILES if no next entry was found.
32 //
33 // Notes:
34 //
35 //---------------------------------------------------------------------------
36
37
GetNext(STATSTGW * pstat)38 SCODE CMSFIterator::GetNext(STATSTGW *pstat)
39 {
40 SCODE sc;
41 SID sidNext;
42 msfDebugOut((DEB_TRACE,"In CMSFIterator::GetNext()\n"));
43
44 if (_sidChildRoot == NOSTREAM)
45 msfChk(STG_E_NOMOREFILES);
46
47 msfChk(_pdir->FindGreaterEntry(_sidChildRoot, &_dfnCurrent, &sidNext));
48
49 // We found another child
50 CDirEntry *pde;
51
52 msfChk(_pdir->GetDirEntry(sidNext, FB_NONE, &pde));
53 pstat->type = pde->GetFlags();
54
55 //Note: The casting below assumes that DfName is always a
56 // wide character string. If we at some point in
57 // the future convert to a system where this is not
58 // true, this code needs to be updated.
59
60 msfChk(DfAllocWCS((WCHAR *)pde->GetName()->GetBuffer(), &pstat->pwcsName));
61 wcscpy(pstat->pwcsName, (WCHAR *)pde->GetName()->GetBuffer());
62
63 pstat->ctime = pde->GetTime(WT_CREATION);
64 pstat->mtime = pde->GetTime(WT_MODIFICATION);
65
66 //Don't currently keep access times
67 pstat->atime = pstat->mtime;
68
69 if ((pstat->type & STGTY_REAL) == STGTY_STORAGE)
70 {
71 ULISet32(pstat->cbSize, 0);
72 pstat->clsid = pde->GetClassId();
73 pstat->grfStateBits = pde->GetUserFlags();
74 }
75 else
76 {
77 ULISet32(pstat->cbSize, pde->GetSize());
78 pstat->clsid = CLSID_NULL;
79 pstat->grfStateBits = 0;
80 }
81
82 // update our iterator
83 _dfnCurrent.Set(pde->GetName());
84
85 _pdir->ReleaseEntry(sidNext);
86
87 msfDebugOut((DEB_TRACE,"Leaving CMSFIterator::GetNext()\n"));
88 // Fall through
89 Err:
90 return sc;
91 }
92
93 //+--------------------------------------------------------------
94 //
95 // Member: CMSFIterator::BufferGetNext, public
96 //
97 // Synopsis: Fast, fixed-size buffer version of GetNext
98 // for iterations that don't care about having
99 // full stat info and an allocated name
100 //
101 // Arguments: [pib] - Buffer to fill in
102 //
103 // Returns: Appropriate status code
104 //
105 // Modifies: [pib]
106 //
107 //---------------------------------------------------------------
108
109
BufferGetNext(SIterBuffer * pib)110 SCODE CMSFIterator::BufferGetNext(SIterBuffer *pib)
111 {
112 SCODE sc;
113 SID sidNext;
114 CDirEntry *pdeNext;
115
116 msfDebugOut((DEB_ITRACE, "In CMSFIterator::BufferGetNext(%p)\n", pib));
117
118 if (_sidChildRoot == NOSTREAM)
119 msfChk(STG_E_NOMOREFILES);
120
121 msfChk(_pdir->FindGreaterEntry(_sidChildRoot, &_dfnCurrent, &sidNext));
122
123 msfChk(_pdir->GetDirEntry(sidNext, FB_NONE, &pdeNext));
124 pib->type = pdeNext->GetFlags();
125 pib->dfnName = *(pdeNext->GetName());
126
127 // update our iterator
128 _dfnCurrent.Set(pdeNext->GetName());
129
130 _pdir->ReleaseEntry(sidNext);
131 msfDebugOut((DEB_ITRACE, "Out CMSFIterator::BufferGetNext\n"));
132 // Fall through
133 Err:
134 return sc;
135 }
136