> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameSaveReadBlobData

> XGameSaveReadBlobData

# XGameSaveReadBlobData

コンテナーの BLOB データを読み取ります。

## Syntax

```cpp theme={null}
HRESULT XGameSaveReadBlobData(  
         XGameSaveContainerHandle container,  
         const char** blobNames,  
         uint32_t* countOfBlobs,  
         size_t blobsSize,  
         XGameSaveBlob* blobData  
)  
```

### Parameters

*container*   \_In\_\
型: XGameSaveContainerHandle

XGameSaveBlob データを含む **XGameSaveContainer** のハンドル。

*blobNames*   \_In\_opt\_z\_count\_(*countOfBlobs)\
型: char*\*

[XGameSaveBlob](/reference/system/xgamesave/structs/xgamesaveblob) 名を表す文字列の配列へのポインター。

*countOfBlobs*   \_Inout\_\
型: uint32\_t\*

読み取る BLOB の数。

*blobsSize*   \_In\_\
型: size\_t

割り当てられた BLOB データのサイズ。BLOB メタデータの読み取りから推定できます。

*blobData*   \_Out\_writes\_bytes\_(blobsSize)\
型: [XGameSaveBlob\*](/reference/system/xgamesave/structs/xgamesaveblob)

BLOB データを含む [XGameSaveBlob](/reference/system/xgamesave/structs/xgamesaveblob) ポインター。コンテナーから要求されたすべての BLOB を格納するためのメモリを割り当てておく必要があります。

### Return value

型: HRESULT

関数の結果。

#### Common errors

* E\_GS\_INVALID\_CONTAINER\_NAME
* E\_GS\_PROVIDED\_BUFFER\_TOO\_SMALL
* E\_GS\_BLOB\_NOT\_FOUND
* E\_GS\_CONTAINER\_NOT\_IN\_SYNC
* E\_GS\_CONTAINER\_SYNC\_FAILED
* E\_GS\_HANDLE\_EXPIRED

## Remarks

<Note>この関数は、時間依存スレッドから呼び出しても安全ではありません。詳細については、[Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads) を参照してください。</Note>

この関数を使用して、ゲーム セーブ BLOB のデータを読み取ります。関数は、BLOB コンテナー内の BLOB の数とデータを返します。これらを使用してコンテナー内の BLOB を反復処理し、適切な情報を読み取ることができます。この関数には、[XGameSaveReadBlobDataAsync](/reference/system/xgamesave/functions/xgamesavereadblobdataasync) と呼ばれる非同期バージョンがあります。

```cpp theme={null}
// SYNC Read - should not be called on time sensitive thread 
//             as this will block until the operation is complete 
void Sample::_ReadContainerBlobsSync(const XGameSaveContainerInfo* container) 
{ 
    const char* blobNames[] = { 
        "WorldState", 
        "PlayerState", 
        "PlayerInventory" 
    }; 
  
    XGameSaveContainerHandle containerContext = nullptr; 
    size_t allocSize; 
    uint32_t countOfBlobs = _countof(blobNames); 
    XGameSaveBlob* blobs = nullptr; 
    HRESULT hr = XGameSaveCreateContainer(_provider, container->name, &containerContext); 
  
    if (SUCCEEDED(hr)) 
    { 
        // this method finds the size for only the blobs in the container 
        // that we are requesting to read right now 
        hr = _GetContainerBlobsDataSize(container, blobNames, _countof(blobNames), &allocSize); 
    } 
    if (SUCCEEDED(hr)) 
    { 
        blobs = reinterpret_cast<XGameSaveBlob*>(malloc(allocSize)); 
        if (blobs == nullptr) 
        { 
            hr = E_OUTOFMEMORY; 
        } 
    } 
    if (SUCCEEDED(hr)) 
    { 
        hr = XGameSaveReadBlobData(containerContext, blobNames, &countOfBlobs, allocSize, blobs); 
    } 
    if (SUCCEEDED(hr)) 
    { 
        if (countOfBlobs == _countof(blobNames)) 
        { 
            for (uint32_t i = 0; i < countOfBlobs; i++) 
            { 
                XGameSaveBlob* currentBlob = blobs + i; 
                if (strcmp(currentBlob->info.name, "WorldState") == 0) 
                { 
                    hr = _LoadSaveBlob(currentBlob, _worldState); 
                } 
                else if (strcmp(currentBlob->info.name, "PlayerState") == 0) 
                { 
                    hr = _LoadSaveBlob(currentBlob, _playerState); 
                } 
                else if (strcmp(currentBlob->info.name, "PlayerInventory") == 0) 
                { 
                    hr = _LoadSaveBlob(currentBlob, _playerInventory); 
                } 
                if (FAILED(hr)) 
                { 
                    break; 
                } 
            } 
        } 
        else 
        { 
            hr = E_UNEXPECTED; 
        } 
    } 
  
    _HandleContainerBlobErrors(hr); 
  
    if (blobs != nullptr) 
    { 
        free(blobs); 
    } 
    if (containerContext != nullptr) 
    { 
        XGameSaveCloseContainer(containerContext); 
    } 
} 
  
  
void Sample::_HandleContainerBlobErrors(HRESULT hr) 
{ 
    // set some state 
    switch (hr) 
    { 
    case E_GS_INVALID_CONTAINER_NAME: 
        // tried to access a container with an invalid name 
        break; 
    case E_GS_PROVIDED_BUFFER_TOO_SMALL: 
        // shouldn't ever happen unless our math is wrong!! 
        break; 
    case E_GS_BLOB_NOT_FOUND: 
        // we asked for a blob that isn't in the container 
        break; 
    case E_GS_CONTAINER_NOT_IN_SYNC: 
    case E_GS_CONTAINER_SYNC_FAILED: 
        // need to sync and we are offline ? 
        break; 
    case E_GS_HANDLE_EXPIRED: 
        // need to re-initialize since another device has taken 
        // ownership while we were suspended and/or busy  
        break; 
    } 
} 
```

## Requirements

**ヘッダー:** XGameSave.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XGameSave](/reference/system/xgamesave/xgamesave_members)\
[XGameSaveBlobInfo](/reference/system/xgamesave/structs/xgamesaveblobinfo)\
[XGameSaveReadBlobDataAsync](/reference/system/xgamesave/functions/xgamesavereadblobdataasync)\
[Debugging Game Saves](/build/core-features/common/game-save/game-saves-debugging)


## Related topics

- [XGameSaveReadBlobDataAsync](/ja-jp/reference/system/xgamesave/functions/xgamesavereadblobdataasync.md)
- [XGameSaveBlob](/ja-jp/reference/system/xgamesave/structs/xgamesaveblob.md)
- [XGameSave](/ja-jp/reference/system/xgamesave/xgamesave_members.md)
- [GDK 向け Unity C# API ラッパー](/ja-jp/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XGameSaveReadBlobDataResult](/ja-jp/reference/system/xgamesave/functions/xgamesavereadblobdataresult.md)
