-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathObjectStorageProviderExamples.cpp
More file actions
55 lines (49 loc) · 1.78 KB
/
Copy pathObjectStorageProviderExamples.cpp
File metadata and controls
55 lines (49 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "Stdafx.h"
using namespace net::openstack::Core;
using namespace net::openstack::Core::Domain;
using namespace net::openstack::Core::Providers;
using namespace System;
using namespace System::Collections::Generic;
ref class ObjectStorageProviderExamples
{
public:
#pragma region ListObjectsInContainer
void ListObjects(IObjectStorageProvider^ provider, String^ containerName)
{
Console::WriteLine("Objects in container {0}", containerName);
for each (ContainerObject^ containerObject in ListAllObjects(provider, containerName))
Console::WriteLine(" {0}", containerObject->Name);
}
static IEnumerable<ContainerObject^>^ ListAllObjects(IObjectStorageProvider^ provider, String^ containerName)
{
return ListAllObjects(provider, containerName, Nullable<int>(), nullptr, nullptr, false, nullptr);
}
static IEnumerable<ContainerObject^>^ ListAllObjects(
IObjectStorageProvider^ provider,
String^ containerName,
Nullable<int> blockSize,
String^ prefix,
String^ region,
bool useInternalUrl,
CloudIdentity^ identity)
{
if (blockSize.HasValue && blockSize.Value <= 0)
throw gcnew ArgumentOutOfRangeException("blockSize");
List<ContainerObject^>^ result = gcnew List<ContainerObject^>();
ContainerObject^ lastContainerObject = nullptr;
do
{
String^ marker = lastContainerObject ? lastContainerObject->Name : nullptr;
IEnumerable<ContainerObject^>^ containerObjects =
provider->ListObjects(containerName, blockSize, marker, nullptr, prefix, region, useInternalUrl, identity);
int previousCount = result->Count;
result->AddRange(containerObjects);
if (result->Count > previousCount)
lastContainerObject = result[result->Count - 1];
else
lastContainerObject = nullptr;
} while (lastContainerObject);
return result;
}
#pragma endregion
};