> ## 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 데이터를 읽습니다.

## 구문

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

### 매개 변수

*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을 저장할 메모리가 할당되어 있어야 합니다.

### 반환값

형식: HRESULT

함수 결과입니다.

#### 일반적인 오류

* 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

## 설명

<Note>이 함수는 시간에 민감한 스레드에서 호출해도 안전하지 않습니다. 자세한 내용은 [시간에 민감한 스레드](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; 
    } 
} 
```

## 요구 사항

**헤더:** XGameSave.h

**라이브러리:** xgameruntime.lib

**지원되는 플랫폼:** Windows, XBOX One 계열 콘솔 및 XBOX Series 콘솔

## 개념 설명서

* [시간에 민감한 스레드](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 함께 보기

[XGameSave](/reference/system/xgamesave/xgamesave_members)\
[XGameSaveBlobInfo](/reference/system/xgamesave/structs/xgamesaveblobinfo)\
[XGameSaveReadBlobDataAsync](/reference/system/xgamesave/functions/xgamesavereadblobdataasync)\
[게임 저장 디버깅](/build/core-features/common/game-save/game-saves-debugging)


## Related topics

- [XGameSaveReadBlobDataAsync](/ko/reference/system/xgamesave/functions/xgamesavereadblobdataasync.md)
- [XGameSaveBlob](/ko/reference/system/xgamesave/structs/xgamesaveblob.md)
- [XGameSave](/ko/reference/system/xgamesave/xgamesave_members.md)
- [GDK용 Unity C# API 래퍼](/ko/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XGameSaveReadBlobDataResult](/ko/reference/system/xgamesave/functions/xgamesavereadblobdataresult.md)
