MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / GetData

Method GetData

src/Git/GitDataObject.cpp:101–383  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////// IDataObject /////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

99// IDataObject
100//////////////////////////////////////////////////////////////////////////
101STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
102{
103 if (!pformatetcIn)
104 return E_INVALIDARG;
105 if (!pmedium)
106 return E_POINTER;
107 pmedium->hGlobal = nullptr;
108
109 if ((pformatetcIn->tymed & TYMED_ISTREAM) && (pformatetcIn->dwAspect == DVASPECT_CONTENT) && (pformatetcIn->cfFormat == CF_FILECONTENTS))
110 {
111 // supports the IStream format.
112 // The lindex param is the index of the file to return
113 CString filepath;
114 IStream* pIStream = nullptr;
115
116 // Note: we don't get called for directories since those are simply created and don't
117 // need to be fetched.
118
119 // Note2: It would be really nice if we could get a stream from the subversion library
120 // from where we could read the file contents. But the Subversion lib is not implemented
121 // to *read* from a remote stream but so that the library *writes* to a stream we pass.
122 // Since we can't get such a read stream, we have to fetch the file in whole first to
123 // a temp location and then pass the shell an IStream for that temp file.
124
125 if (m_revision.IsEmpty())
126 {
127 if (pformatetcIn->lindex >= 0 && pformatetcIn->lindex < static_cast<LONG>(m_allPaths.size()))
128 filepath = g_Git.CombinePath(m_allPaths[pformatetcIn->lindex]);
129 }
130 else
131 {
132 filepath = CTempFiles::Instance().GetTempFilePath(true).GetWinPathString();
133 if (pformatetcIn->lindex >= 0 && pformatetcIn->lindex < static_cast<LONG>(m_allPaths.size()))
134 {
135 if (g_Git.GetOneFile(m_revision.ToString(), m_allPaths[pformatetcIn->lindex], filepath))
136 {
137 DeleteFile(filepath);
138 return STG_E_ACCESSDENIED;
139 }
140 }
141 }
142
143 HRESULT res = SHCreateStreamOnFileEx(filepath, STGM_READ, FILE_ATTRIBUTE_NORMAL, FALSE, nullptr, &pIStream);
144 if (res == S_OK)
145 {
146 // http://blogs.msdn.com/b/oldnewthing/archive/2014/09/18/10558763.aspx
147 LARGE_INTEGER liZero = { 0, 0 };
148 pIStream->Seek(liZero, STREAM_SEEK_END, nullptr);
149
150 pmedium->pstm = pIStream;
151 pmedium->tymed = TYMED_ISTREAM;
152 return S_OK;
153 }
154 return res;
155 }
156 else if ((pformatetcIn->tymed & TYMED_HGLOBAL) && (pformatetcIn->dwAspect == DVASPECT_CONTENT) && (pformatetcIn->cfFormat == CF_FILEDESCRIPTOR))
157 {
158 for (int i = 0; i < m_gitPaths.GetCount(); ++i)

Callers 7

CBaseViewClass · 0.45
AddViewLineFromViewMethod · 0.45
DoMethod · 0.45
RemoveViewDataMethod · 0.45
SetViewDataMethod · 0.45
InitializeMethod · 0.45
DrawConnectionsMethod · 0.45

Calls 14

CombinePathMethod · 0.80
GetOneFileMethod · 0.80
SeekMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
IsEmptyMethod · 0.45
sizeMethod · 0.45
GetTempFilePathMethod · 0.45
ToStringMethod · 0.45
GetCountMethod · 0.45
IsDirectoryMethod · 0.45

Tested by

no test coverage detected