本文整理汇总了C++中nsCOMPtr::GetInputStreamWithSpec方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetInputStreamWithSpec方法的具体用法?C++ nsCOMPtr::GetInputStreamWithSpec怎么用?C++ nsCOMPtr::GetInputStreamWithSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetInputStreamWithSpec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
nsresult
nsJARInputThunk::Init()
{
nsresult rv;
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
// A directory stream also needs the Spec of the FullJarURI
// because is included in the stream data itself.
NS_ENSURE_STATE(!mJarDirSpec.IsEmpty());
rv = mJarReader->GetInputStreamWithSpec(mJarDirSpec,
mJarEntry,
getter_AddRefs(mJarStream));
}
else {
rv = mJarReader->GetInputStream(mJarEntry,
getter_AddRefs(mJarStream));
}
if (NS_FAILED(rv)) {
// convert to the proper result if the entry wasn't found
// so that error pages work
if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
rv = NS_ERROR_FILE_NOT_FOUND;
return rv;
}
// ask the JarStream for the content length
uint64_t avail;
rv = mJarStream->Available((uint64_t *) &avail);
if (NS_FAILED(rv)) return rv;
mContentLength = avail < INT64_MAX ? (int64_t) avail : -1;
return NS_OK;
}
示例2:
nsresult
nsJARInputThunk::EnsureJarStream()
{
if (mJarStream)
return NS_OK;
nsresult rv;
if (mJarCache)
rv = mJarCache->GetZip(mJarFile, getter_AddRefs(mJarReader));
else {
// create an uncached jar reader
mJarReader = do_CreateInstance(kZipReaderCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = mJarReader->Open(mJarFile);
}
if (NS_FAILED(rv)) return rv;
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
// A directory stream also needs the Spec of the FullJarURI
// because is included in the stream data itself.
NS_ENSURE_STATE(!mJarDirSpec.IsEmpty());
rv = mJarReader->GetInputStreamWithSpec(mJarDirSpec,
mJarEntry.get(),
getter_AddRefs(mJarStream));
}
else {
rv = mJarReader->GetInputStream(mJarEntry.get(),
getter_AddRefs(mJarStream));
}
if (NS_FAILED(rv)) {
// convert to the proper result if the entry wasn't found
// so that error pages work
if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
rv = NS_ERROR_FILE_NOT_FOUND;
return rv;
}
// ask the JarStream for the content length
// XXX want a 64-bit value from nsIInputStream::Available()
PRUint32 contentLength;
rv = mJarStream->Available(&contentLength);
if (NS_FAILED(rv)) return rv;
mContentLength = contentLength;
return NS_OK;
}