本文整理汇总了C++中CInFileStream::OpenShared方法的典型用法代码示例。如果您正苦于以下问题:C++ CInFileStream::OpenShared方法的具体用法?C++ CInFileStream::OpenShared怎么用?C++ CInFileStream::OpenShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInFileStream
的用法示例。
在下文中一共展示了CInFileStream::OpenShared方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetStream
STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
COM_TRY_BEGIN
const CUpdatePair2 &up = (*UpdatePairs)[index];
if (!up.NewData)
return E_FAIL;
RINOK(Callback->CheckBreak());
RINOK(Callback->Finilize());
if (up.IsAnti)
{
return Callback->GetStream((*ArcItems)[up.ArcIndex].Name, true);
}
const CDirItem &di = DirItems->Items[up.DirIndex];
// RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), false)); // 削除
/* 追加ここから */
UString strLogPath = DirItems->GetLogPath(up.DirIndex);
RINOK(Callback->GetStream(strLogPath, false));
g_StdOut.GetProgressDialog()->AddWorkFile(strLogPath, strLogPath, di.Attrib, false, di.MTime, di.Size, 0, 0, L"");
/* 追加ここまで */
if (di.IsDir())
return S_OK;
if (StdInMode)
{
CStdInFileStream *inStreamSpec = new CStdInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
*inStream = inStreamLoc.Detach();
}
else
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
const UString path = DirItems->GetPhyPath(up.DirIndex);
if (!inStreamSpec->OpenShared(us2fs(path), ShareForWrite))
{
return Callback->OpenFileError(path, ::GetLastError());
}
*inStream = inStreamLoc.Detach();
}
return S_OK;
COM_TRY_END
}
示例2: GetStream
STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
COM_TRY_BEGIN
const CUpdatePair2 &updatePair = (*UpdatePairs)[index];
if(!updatePair.NewData)
return E_FAIL;
RINOK(Callback->CheckBreak());
RINOK(Callback->Finilize());
if(updatePair.IsAnti)
{
return Callback->GetStream((*ArchiveItems)[updatePair.ArchiveItemIndex].Name, true);
}
const CDirItem &dirItem = (*DirItems)[updatePair.DirItemIndex];
RINOK(Callback->GetStream(dirItem.Name, false));
if(dirItem.IsDirectory())
return S_OK;
if (StdInMode)
{
CStdInFileStream *inStreamSpec = new CStdInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
*inStream = inStreamLoc.Detach();
}
else
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
UString path = DirPrefix + dirItem.FullPath;
if(!inStreamSpec->OpenShared(path, ShareForWrite))
{
return Callback->OpenFileError(path, ::GetLastError());
}
*inStream = inStreamLoc.Detach();
}
return S_OK;
COM_TRY_END
}
示例3: if
STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode)
{
COM_TRY_BEGIN
*inStream = NULL;
const CUpdatePair2 &up = (*UpdatePairs)[index];
if (!up.NewData)
return E_FAIL;
RINOK(Callback->CheckBreak());
// RINOK(Callback->Finalize());
bool isDir = IsDir(up);
if (up.IsAnti)
{
UString name;
if (up.ArcIndex >= 0)
name = (*ArcItems)[up.ArcIndex].Name;
else if (up.DirIndex >= 0)
name = DirItems->GetLogPath(up.DirIndex);
RINOK(Callback->GetStream(name, isDir, true, mode));
/* 9.33: fixed. Handlers expect real stream object for files, even for anti-file.
so we return empty stream */
if (!isDir)
{
CBufInStream *inStreamSpec = new CBufInStream();
CMyComPtr<ISequentialInStream> inStreamLoc = inStreamSpec;
inStreamSpec->Init(NULL, 0);
*inStream = inStreamLoc.Detach();
}
return S_OK;
}
RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), isDir, false, mode));
if (isDir)
return S_OK;
if (StdInMode)
{
if (mode != NUpdateNotifyOp::kAdd &&
mode != NUpdateNotifyOp::kUpdate)
return S_OK;
CStdInFileStream *inStreamSpec = new CStdInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
*inStream = inStreamLoc.Detach();
}
else
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
inStreamSpec->SupportHardLinks = StoreHardLinks;
inStreamSpec->Callback = this;
inStreamSpec->CallbackRef = index;
const FString path = DirItems->GetPhyPath(up.DirIndex);
_openFiles_Indexes.Add(index);
_openFiles_Paths.Add(path);
#if defined(_WIN32) && !defined(UNDER_CE)
if (DirItems->Items[up.DirIndex].AreReparseData())
{
if (!inStreamSpec->File.OpenReparse(path))
{
return Callback->OpenFileError(path, ::GetLastError());
}
}
else
#endif
if (!inStreamSpec->OpenShared(path, ShareForWrite))
{
DWORD error = ::GetLastError();
HRESULT hres = Callback->OpenFileError(path, error);
if (StopAfterOpenError)
if (hres == S_OK || hres == S_FALSE)
return HRESULT_FROM_WIN32(error);
return hres;
}
if (StoreHardLinks)
{
CStreamFileProps props;
if (inStreamSpec->GetProps2(&props) == S_OK)
{
if (props.NumLinks > 1)
{
CKeyKeyValPair pair;
pair.Key1 = props.VolID;
pair.Key2 = props.FileID_Low;
pair.Value = index;
unsigned numItems = _map.Size();
unsigned pairIndex = _map.AddToUniqueSorted2(pair);
if (numItems == _map.Size())
{
// const CKeyKeyValPair &pair2 = _map.Pairs[pairIndex];
_hardIndex_From = index;
//.........这里部分代码省略.........