0

Chrome 用の NaCl プラグインに取り組んでおり、URL リソース ファイルをローカルにダウンロードして Chrome の一時キャッシュに保存しようとしていますが、成功しません。

これが私が進める方法です:

// I indicate that I want the resource to be downloaded to a file
m_URLRequestInfo.SetStreamToFile( true );

// I open the request:
m_URLLoader.Open( m_URLRequestInfo, m_CCFactory.NewCallback( &MyClass::OnOpen ) );

...    
// My callback (OnOpen) is eventually called.
// I then check to make sure the status code is 200 using this call:
m_URLLoader.GetResponseInfo().GetStatusCode()

// Then I ask to download the whole file:
m_URLLoader.FinishStreamingToFile( m_CCFactory.NewOptionalCallback( &MyClass::OnFileDownloaded ) );

...
// My other callback (OnFileDownloaded) gets eventually called,
// and again the status code is 200.
// Then I query the FileRef using this call:
pp::FileRef l_FileRef = m_URLLoader.GetResponseInfo().GetBodyAsFileRef();

返された pp::FileRef は問題ないように見えますが、pp::FileRef::GetFileSystemType() は PP_FILESYSTEMTYPE_EXTERNAL を返し、pp::FileRef::GetPath() の呼び出しは失敗します (未定義の pp::Var を返します)。

したがって、この時点から、私は迷っています。ブラウザーのキャッシュ内のローカル ファイルを指す有効な pp::FileRef を取得するために他に何をすべきかわかりません。私の最終的な目標は、fopen() のような標準のシステム ファイル IO を使用して、このローカル ファイル (私の場合はイメージ ファイル) を開くことです。

光をありがとう!

4

2 に答える 2

0

nacl_io代わりにライブラリを使用できない理由はありますか? それを使用すると、次のように書くことができます。

#include <stdio.h>
#include <sys/mount.h>

// Mount an HTTP filesystem that reads files from "http://example.com/path/...".
mount("http://example.com/path/", "/mnt/http", "httpfs", 0, "");

// Performs a URL Request of "http://example.com/path/my_image.png".
FILE* file = fopen("/mnt/http/my_image.png", "r");
...

SDK の nacl_io デモをご覧ください。にあります$NACL_SDK_ROOT/examples/demo/nacl_io

于 2013-10-25T22:57:09.343 に答える