Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kate Kader
Open VDS
Commits
cbb94c87
Commit
cbb94c87
authored
Nov 13, 2019
by
Jørgen Lind
Browse files
Move rest of code over to standard of having capital first leter
on public Function and public Members
parent
0fb2a2b2
Changes
73
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
cbb94c87
...
...
@@ -2,6 +2,7 @@
Builds
Dist
CMakeSettings.json
CMakeLists.txt.user
python/.eggs
python/_skbuild
python/**/*.pyd
...
...
src/IO/File.cpp
View file @
cbb94c87
...
...
@@ -22,7 +22,7 @@
namespace
OpenVDS
{
FileView
*
FileView
::
a
ddReference
(
FileView
*
pcFileView
)
FileView
*
FileView
::
A
ddReference
(
FileView
*
pcFileView
)
{
assert
(
pcFileView
);
...
...
@@ -32,7 +32,7 @@ FileView * FileView::addReference(FileView *pcFileView)
return
pcFileView
;
}
bool
FileView
::
r
emoveReference
(
FileView
*
pcFileView
)
bool
FileView
::
R
emoveReference
(
FileView
*
pcFileView
)
{
assert
(
pcFileView
);
assert
(
pcFileView
->
m_nReferenceCount
>
0
);
...
...
@@ -55,29 +55,29 @@ File::File()
File
::~
File
()
{
if
(
i
sOpen
())
if
(
I
sOpen
())
{
c
lose
();
C
lose
();
}
}
bool
File
::
i
sWriteable
()
const
bool
File
::
I
sWriteable
()
const
{
return
_isWriteable
;
}
bool
File
::
i
sOpen
()
const
bool
File
::
I
sOpen
()
const
{
assert
(
!!
_pxPlatformHandle
==
!
_cFileName
.
empty
());
return
_pxPlatformHandle
;
}
std
::
string
File
::
f
ileName
()
const
std
::
string
File
::
F
ileName
()
const
{
return
_cFileName
;
}
void
*
File
::
h
andle
()
const
void
*
File
::
H
andle
()
const
{
return
_pxPlatformHandle
;
}
...
...
src/IO/File.h
View file @
cbb94c87
...
...
@@ -56,36 +56,36 @@ public:
class
SystemFileMappingObject
{
public:
static
bool
o
pen
(
SystemFileMappingObject
**
ppcFileMappingObject
,
File
&
file
,
IOError
&
error
);
static
void
c
lose
(
SystemFileMappingObject
**
pcFileMappingObject
);
static
bool
O
pen
(
SystemFileMappingObject
**
ppcFileMappingObject
,
File
&
file
,
IOError
&
error
);
static
void
C
lose
(
SystemFileMappingObject
**
pcFileMappingObject
);
};
OPENVDS_EXPORT
const
void
*
p
ointer
()
const
const
void
*
P
ointer
()
const
{
return
m_pData
;
}
OPENVDS_EXPORT
int64_t
p
os
()
const
int64_t
P
os
()
const
{
return
m_nPos
;
}
OPENVDS_EXPORT
int64_t
s
ize
()
const
int64_t
S
ize
()
const
{
return
m_nSize
;
}
OPENVDS_EXPORT
virtual
bool
p
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
=
0
;
virtual
bool
P
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
=
0
;
OPENVDS_EXPORT
static
FileView
*
a
ddReference
(
FileView
*
pcFileView
);
static
FileView
*
A
ddReference
(
FileView
*
pcFileView
);
OPENVDS_EXPORT
static
bool
r
emoveReference
(
FileView
*
pcFileView
);
static
bool
R
emoveReference
(
FileView
*
pcFileView
);
};
// This class is thread-safe except for the following methods:
...
...
@@ -97,23 +97,23 @@ public:
OPENVDS_EXPORT
File
();
OPENVDS_EXPORT
~
File
();
OPENVDS_EXPORT
static
bool
e
xists
(
const
std
::
string
&
filename
);
OPENVDS_EXPORT
bool
o
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
);
OPENVDS_EXPORT
void
c
lose
();
OPENVDS_EXPORT
static
bool
E
xists
(
const
std
::
string
&
filename
);
OPENVDS_EXPORT
bool
O
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
);
OPENVDS_EXPORT
void
C
lose
();
OPENVDS_EXPORT
int64_t
s
ize
(
IOError
&
error
)
const
;
OPENVDS_EXPORT
int64_t
S
ize
(
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
r
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
w
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
);
OPENVDS_EXPORT
bool
R
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
W
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
);
OPENVDS_EXPORT
bool
f
lush
();
OPENVDS_EXPORT
bool
i
sWriteable
()
const
;
OPENVDS_EXPORT
bool
i
sOpen
()
const
;
OPENVDS_EXPORT
std
::
string
f
ileName
()
const
;
OPENVDS_EXPORT
bool
F
lush
();
OPENVDS_EXPORT
bool
I
sWriteable
()
const
;
OPENVDS_EXPORT
bool
I
sOpen
()
const
;
OPENVDS_EXPORT
std
::
string
F
ileName
()
const
;
OPENVDS_EXPORT
FileView
*
c
reateFileView
(
int64_t
iPos
,
int64_t
nSize
,
bool
isPopulate
,
IOError
&
error
);
OPENVDS_EXPORT
FileView
*
C
reateFileView
(
int64_t
iPos
,
int64_t
nSize
,
bool
isPopulate
,
IOError
&
error
);
OPENVDS_EXPORT
void
*
h
andle
()
const
;
OPENVDS_EXPORT
void
*
H
andle
()
const
;
private:
void
*
_pxPlatformHandle
;
bool
_isWriteable
;
...
...
src/IO/IOManager.cpp
View file @
cbb94c87
...
...
@@ -31,13 +31,13 @@ Request::~Request()
TransferDownloadHandler
::~
TransferDownloadHandler
()
{
}
void
TransferDownloadHandler
::
h
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
)
void
TransferDownloadHandler
::
H
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
)
{
}
IOManager
::~
IOManager
()
{}
IOManager
*
IOManager
::
c
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
)
IOManager
*
IOManager
::
C
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
)
{
switch
(
options
.
connectionType
)
{
...
...
src/IO/IOManager.h
View file @
cbb94c87
...
...
@@ -30,9 +30,9 @@ namespace OpenVDS
{
public:
virtual
~
TransferDownloadHandler
();
virtual
void
h
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
);
virtual
void
h
andleData
(
std
::
vector
<
uint8_t
>
&&
data
)
=
0
;
virtual
void
c
ompleted
(
const
Request
&
request
,
const
Error
&
error
)
=
0
;
virtual
void
H
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
);
virtual
void
H
andleData
(
std
::
vector
<
uint8_t
>
&&
data
)
=
0
;
virtual
void
C
ompleted
(
const
Request
&
request
,
const
Error
&
error
)
=
0
;
};
class
Request
...
...
@@ -40,11 +40,11 @@ namespace OpenVDS
public:
Request
(
const
std
::
string
&
objectName
);
virtual
~
Request
();
virtual
void
w
aitForFinish
()
=
0
;
virtual
bool
i
sDone
()
const
=
0
;
virtual
bool
i
sSuccess
(
Error
&
error
)
const
=
0
;
virtual
void
c
ancel
()
=
0
;
const
std
::
string
&
g
etObjectName
()
const
{
return
m_objectName
;
}
virtual
void
W
aitForFinish
()
=
0
;
virtual
bool
I
sDone
()
const
=
0
;
virtual
bool
I
sSuccess
(
Error
&
error
)
const
=
0
;
virtual
void
C
ancel
()
=
0
;
const
std
::
string
&
G
etObjectName
()
const
{
return
m_objectName
;
}
private:
std
::
string
m_objectName
;
...
...
@@ -60,19 +60,19 @@ namespace OpenVDS
{
public:
virtual
~
IOManager
();
virtual
std
::
shared_ptr
<
Request
>
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
=
0
;
virtual
std
::
shared_ptr
<
Request
>
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
=
0
;
std
::
shared_ptr
<
Request
>
u
ploadBinary
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
virtual
std
::
shared_ptr
<
Request
>
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
=
0
;
virtual
std
::
shared_ptr
<
Request
>
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
=
0
;
std
::
shared_ptr
<
Request
>
U
ploadBinary
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
{
return
u
pload
(
objectName
,
contentDispositionFilename
,
"application/octet-stream"
,
metadataHeader
,
data
,
completedCallback
);
return
U
pload
(
objectName
,
contentDispositionFilename
,
"application/octet-stream"
,
metadataHeader
,
data
,
completedCallback
);
}
std
::
shared_ptr
<
Request
>
u
ploadJson
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
std
::
shared_ptr
<
Request
>
U
ploadJson
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
{
return
u
pload
(
objectName
,
""
,
"application/json"
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
(),
data
,
completedCallback
);
return
U
pload
(
objectName
,
""
,
"application/json"
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
(),
data
,
completedCallback
);
}
static
IOManager
*
c
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
);
static
IOManager
*
C
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
);
};
}
...
...
src/IO/IOManagerAWS.cpp
View file @
cbb94c87
...
...
@@ -112,7 +112,7 @@ namespace OpenVDS
Aws
::
S3
::
Model
::
GetObjectResult
result
=
const_cast
<
Aws
::
S3
::
Model
::
GetObjectOutcome
&>
(
getObjectOutcome
).
GetResultWithOwnership
();
for
(
auto
it
:
result
.
GetMetadata
())
{
objReq
->
m_handler
->
h
andleMetadata
(
convertAwsString
(
it
.
first
),
convertAwsString
(
it
.
second
));
objReq
->
m_handler
->
H
andleMetadata
(
convertAwsString
(
it
.
first
),
convertAwsString
(
it
.
second
));
}
auto
&
retrieved_object
=
result
.
GetBody
();
auto
content_length
=
result
.
GetContentLength
();
...
...
@@ -122,7 +122,7 @@ namespace OpenVDS
{
data
.
resize
(
content_length
);
retrieved_object
.
read
((
char
*
)
&
data
[
0
],
content_length
);
objReq
->
m_handler
->
h
andleData
(
std
::
move
(
data
));
objReq
->
m_handler
->
H
andleData
(
std
::
move
(
data
));
}
lock
.
lock
();
}
...
...
@@ -137,7 +137,7 @@ namespace OpenVDS
objReq
->
m_done
=
true
;
objReq
->
m_waitForFinish
.
notify_all
();
lock
.
unlock
();
objReq
->
m_handler
->
c
ompleted
(
*
objReq
,
objReq
->
m_error
);
objReq
->
m_handler
->
C
ompleted
(
*
objReq
,
objReq
->
m_error
);
}
DownloadRequestAWS
::
DownloadRequestAWS
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
TransferDownloadHandler
>&
handler
)
...
...
@@ -150,14 +150,14 @@ namespace OpenVDS
DownloadRequestAWS
::~
DownloadRequestAWS
()
{
DownloadRequestAWS
::
c
ancel
();
DownloadRequestAWS
::
C
ancel
();
}
void
DownloadRequestAWS
::
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
IORange
&
range
,
std
::
weak_ptr
<
DownloadRequestAWS
>
downloadRequest
)
{
Aws
::
S3
::
Model
::
GetObjectRequest
object_request
;
object_request
.
SetBucket
(
convertStdString
(
bucket
));
object_request
.
SetKey
(
convertStdString
(
g
etObjectName
()));
object_request
.
SetKey
(
convertStdString
(
G
etObjectName
()));
if
(
range
.
end
)
{
object_request
.
SetRange
(
convertStdString
(
fmt
::
format
(
"bytes={}-{}"
,
range
.
start
,
range
.
end
)));
...
...
@@ -169,18 +169,18 @@ namespace OpenVDS
client
.
GetObjectAsync
(
object_request
,
bounded_callback
);
}
void
DownloadRequestAWS
::
w
aitForFinish
()
void
DownloadRequestAWS
::
W
aitForFinish
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
m_waitForFinish
.
wait
(
lock
,
[
this
]{
return
m_done
;
});
}
bool
DownloadRequestAWS
::
i
sDone
()
const
bool
DownloadRequestAWS
::
I
sDone
()
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
return
m_done
;
}
bool
DownloadRequestAWS
::
i
sSuccess
(
Error
&
error
)
const
bool
DownloadRequestAWS
::
I
sSuccess
(
Error
&
error
)
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
!
m_done
)
...
...
@@ -193,7 +193,7 @@ namespace OpenVDS
return
m_error
.
Code
==
0
;
}
void
DownloadRequestAWS
::
c
ancel
()
void
DownloadRequestAWS
::
C
ancel
()
{
m_cancelled
=
true
;
}
...
...
@@ -234,7 +234,7 @@ namespace OpenVDS
Aws
::
S3
::
Model
::
PutObjectRequest
put
;
put
.
SetBucket
(
convertStdString
(
bucket
));
put
.
SetKey
(
convertStdString
(
g
etObjectName
()));
put
.
SetKey
(
convertStdString
(
G
etObjectName
()));
put
.
SetBody
(
m_stream
);
put
.
SetContentType
(
convertStdString
(
contentType
));
put
.
SetContentLength
(
data
->
size
());
...
...
@@ -250,17 +250,17 @@ namespace OpenVDS
}
void
UploadRequestAWS
::
w
aitForFinish
()
void
UploadRequestAWS
::
W
aitForFinish
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
m_waitForFinish
.
wait
(
lock
,
[
this
]{
return
this
->
m_done
;
});
}
bool
UploadRequestAWS
::
i
sDone
()
const
bool
UploadRequestAWS
::
I
sDone
()
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
return
m_done
;
}
bool
UploadRequestAWS
::
i
sSuccess
(
Error
&
error
)
const
bool
UploadRequestAWS
::
I
sSuccess
(
Error
&
error
)
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
!
m_done
)
...
...
@@ -272,7 +272,7 @@ namespace OpenVDS
error
=
m_error
;
return
m_error
.
Code
==
0
;
}
void
UploadRequestAWS
::
c
ancel
()
void
UploadRequestAWS
::
C
ancel
()
{
m_cancelled
=
true
;
}
...
...
@@ -307,7 +307,7 @@ namespace OpenVDS
deinitizlieAWSSDK
();
}
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
)
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
)
{
std
::
string
id
=
objectName
.
empty
()
?
m_objectId
:
m_objectId
+
"/"
+
objectName
;
auto
ret
=
std
::
make_shared
<
DownloadRequestAWS
>
(
id
,
handler
);
...
...
@@ -315,7 +315,7 @@ namespace OpenVDS
return
ret
;
}
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
)
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
)
{
std
::
string
id
=
objectName
.
empty
()
?
m_objectId
:
m_objectId
+
"/"
+
objectName
;
auto
ret
=
std
::
make_shared
<
UploadRequestAWS
>
(
id
,
completedCallback
);
...
...
src/IO/IOManagerAWS.h
View file @
cbb94c87
...
...
@@ -39,10 +39,10 @@ namespace OpenVDS
void
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
IORange
&
range
,
std
::
weak_ptr
<
DownloadRequestAWS
>
request
);
void
w
aitForFinish
()
override
;
bool
i
sDone
()
const
override
;
bool
i
sSuccess
(
Error
&
error
)
const
override
;
void
c
ancel
()
override
;
void
W
aitForFinish
()
override
;
bool
I
sDone
()
const
override
;
bool
I
sSuccess
(
Error
&
error
)
const
override
;
void
C
ancel
()
override
;
std
::
shared_ptr
<
TransferDownloadHandler
>
m_handler
;
std
::
atomic_bool
m_cancelled
;
...
...
@@ -78,10 +78,10 @@ namespace OpenVDS
public:
UploadRequestAWS
(
const
std
::
string
&
id
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
);
void
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
weak_ptr
<
UploadRequestAWS
>
uploadRequest
);
void
w
aitForFinish
()
override
;
bool
i
sDone
()
const
override
;
bool
i
sSuccess
(
Error
&
error
)
const
override
;
void
c
ancel
()
override
;
void
W
aitForFinish
()
override
;
bool
I
sDone
()
const
override
;
bool
I
sSuccess
(
Error
&
error
)
const
override
;
void
C
ancel
()
override
;
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
m_completedCallback
;
std
::
shared_ptr
<
IOStream
>
m_stream
;
...
...
@@ -98,8 +98,8 @@ namespace OpenVDS
IOManagerAWS
(
const
AWSOpenOptions
&
openOptions
,
Error
&
error
);
~
IOManagerAWS
()
override
;
std
::
shared_ptr
<
Request
>
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
override
;
std
::
shared_ptr
<
Request
>
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
override
;
std
::
shared_ptr
<
Request
>
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
override
;
std
::
shared_ptr
<
Request
>
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
override
;
private:
std
::
string
m_region
;
std
::
string
m_bucket
;
...
...
src/IO/IOManagerAzure.cpp
View file @
cbb94c87
...
...
@@ -23,7 +23,7 @@
#include
<fmt/format.h>
void
d
ownloadObject
()
void
D
ownloadObject
()
{
azure
::
storage
::
cloud_storage_account
storage_account
=
azure
::
storage
::
cloud_storage_account
::
parse
(
_XPLATSTR
(
"DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey"
));
azure
::
storage
::
cloud_blob_client
blob_client
=
storage_account
.
create_cloud_blob_client
();
...
...
src/IO/IOManagerAzure.h
View file @
cbb94c87
...
...
@@ -18,6 +18,6 @@
#ifndef IOMANAGERAZURE_H
#define IOMANAGERAZURE_H
void
d
ownloadObject
();
void
D
ownloadObject
();
#endif //IOMANAGERAZURE_H
src/IO/Linux_File.cpp
View file @
cbb94c87
...
...
@@ -35,32 +35,32 @@
namespace
OpenVDS
{
static
std
::
string
e
rror
_to_s
tring
(
int
error
)
static
std
::
string
E
rror
ToS
tring
(
int
error
)
{
return
std
::
string
(
strerror
(
error
));
}
static
void
s
et
_io_e
rror
(
int
error
,
IOError
&
io_error
)
static
void
S
et
IoE
rror
(
int
error
,
IOError
&
io_error
)
{
io_error
.
code
=
error
;
io_error
.
string
=
e
rror
_to_s
tring
(
error
);
io_error
.
string
=
E
rror
ToS
tring
(
error
);
}
static
void
s
et
_io_e
rror
(
int
error
,
std
::
string
&
error_string_prefix
,
IOError
&
io_error
)
static
void
S
et
IoE
rror
(
int
error
,
std
::
string
&
error_string_prefix
,
IOError
&
io_error
)
{
io_error
.
code
=
error
;
io_error
.
string
=
error_string_prefix
+
e
rror
_to_s
tring
(
error
);
io_error
.
string
=
error_string_prefix
+
E
rror
ToS
tring
(
error
);
}
template
<
size_t
N
>
static
void
s
et
_io_e
rror
(
int
error
,
const
char
(
&
error_string_prefix
)[
N
],
IOError
&
io_error
)
static
void
S
et
IoE
rror
(
int
error
,
const
char
(
&
error_string_prefix
)[
N
],
IOError
&
io_error
)
{
io_error
.
code
=
error
;
io_error
.
string
=
std
::
string
(
error_string_prefix
,
N
)
+
e
rror
_to_s
tring
(
error
);
io_error
.
string
=
std
::
string
(
error_string_prefix
,
N
)
+
E
rror
ToS
tring
(
error
);
}
template
<
size_t
N
>
static
void
s
et
_io_e
rror
(
const
char
(
&
error_string_prefix
)[
N
],
IOError
&
io_error
)
static
void
S
et
IoE
rror
(
const
char
(
&
error_string_prefix
)[
N
],
IOError
&
io_error
)
{
io_error
.
code
=
-
1
;
io_error
.
string
=
std
::
string
(
error_string_prefix
,
N
);
...
...
@@ -142,7 +142,7 @@ public:
if
(
m_pxBaseAddress
==
MAP_FAILED
)
{
set_io_e
rror
(
errno
,
"FileView failed "
,
error
);
SetIoE
rror
(
errno
,
"FileView failed "
,
error
);
return
;
}
...
...
@@ -152,7 +152,7 @@ public:
if
(
iRetval
!=
0
)
{
set_io_e
rror
(
errno
,
"FileView failed "
,
error
);
SetIoE
rror
(
errno
,
"FileView failed "
,
error
);
}
}
}
...
...
@@ -168,7 +168,7 @@ public:
}
}
bool
p
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
override
bool
P
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
override
{
int64_t
nDelta
=
(
int64_t
)((
uintptr_t
)
pData
%
s_nPageSize
);
...
...
@@ -179,22 +179,22 @@ public:
if
(
iRetval
!=
0
)
{
set_io_e
rror
(
errno
,
"FileView::prefetch "
,
error
);
SetIoE
rror
(
errno
,
"FileView::prefetch "
,
error
);
return
false
;
}
return
true
;
}
};
bool
File
::
e
xists
(
const
std
::
string
&
filename
)
bool
File
::
E
xists
(
const
std
::
string
&
filename
)
{
struct
stat
buf
;
return
(
lstat
(
filename
.
c_str
(),
&
buf
)
==
0
)
&&
S_ISREG
(
buf
.
st_mode
);
}
bool
File
::
o
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
)
bool
File
::
O
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
)
{
assert
(
!
i
sOpen
());
assert
(
!
I
sOpen
());
assert
(
!
isDestroyExisting
||
isCreate
);
assert
(
!
isCreate
||
isWriteAccess
||
!
"it is meaningless to demand creation with RO access"
);
assert
(
!
_pxPlatformHandle
||
(
"RawFileAccess_c::Open: file already open"
));
...
...
@@ -211,7 +211,7 @@ bool File::open(const std::string& filename, bool isCreate, bool isDestroyExisti
if
(
fd
<
0
)
{
_pxPlatformHandle
=
0
;
s
et
_io_e
rror
(
errno
,
"File::open "
,
error
);
S
et
IoE
rror
(
errno
,
"File::open "
,
error
);
return
false
;
}
...
...
@@ -220,9 +220,9 @@ bool File::open(const std::string& filename, bool isCreate, bool isDestroyExisti
return
true
;
}
void
File
::
c
lose
()
void
File
::
C
lose
()
{
assert
(
i
sOpen
());
assert
(
I
sOpen
());
int
fd
=
(
int
)(
intptr_t
)
_pxPlatformHandle
;
bool
isOK
=
::
close
(
fd
)
==
0
;
...
...
@@ -232,20 +232,20 @@ void File::close()
//return isOK;
}
int64_t
File
::
s
ize
(
IOError
&
error
)
const
int64_t
File
::
S
ize
(
IOError
&
error
)
const
{
int
fd
=
(
int
)(
intptr_t
)
_pxPlatformHandle
;
int64_t
nLength
=
lseek
(
fd
,
0
,
SEEK_END
);
if
(
nLength
<
0
)
{
s
et
_io_e
rror
(
errno
,
"File::size "
,
error
);
S
et
IoE
rror
(
errno
,
"File::size "
,
error
);
return
-
1
;
}
return
nLength
;
}
bool
File
::
r
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
bool
File
::
R
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
{
assert
(
nOffset
>=
0
);
int
fd
=
(
int
)(
intptr_t
)
_pxPlatformHandle
;
...
...
@@ -258,13 +258,13 @@ bool File::read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error)
if
(
nread
<
0
)
{
set_io_e
rror
(
errno
,
"File::read "
,
error
);
SetIoE
rror
(
errno
,
"File::read "
,
error
);
return
false
;
}
if
(
nread
==
0
)
{
set_io_e
rror
(
errno
,
"File::read (zero-length read) "
,
error
);
SetIoE
rror
(
errno
,
"File::read (zero-length read) "
,
error
);
return
false
;
}
...
...
@@ -275,13 +275,13 @@ bool File::read(void* pxData, int64_t nOffset, int32_t nLength, IOError& error)
return
true
;
}
bool
File
::
w
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
bool
File
::
W
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
{
assert
(
nOffset
>=
0
);
if
(
!
_isWriteable
)
{
set_io_e
rror
(
"File::write: file not writeable"
,
error
);
SetIoE
rror
(
"File::write: file not writeable"
,
error
);
return
false
;
}
...
...
@@ -295,12 +295,12 @@ bool File::write(const void* pxData, int64_t nOffset, int32_t nLength, IOError &
if
(
nwritten
<
0
)
{
s
et
_io_e
rror
(
errno
,
"File::write "
,
error
);
S
et
IoE
rror
(
errno
,
"File::write "
,
error
);
return
false
;
}
if
(
nwritten
==
0
)
{
s
et
_io_e
rror
(
errno
,
"File::write (zero-length write)"
,
error
);
S
et
IoE
rror
(
errno
,
"File::write (zero-length write)"
,
error
);
return
false
;
}
...
...
@@ -311,7 +311,7 @@ bool File::write(const void* pxData, int64_t nOffset, int32_t nLength, IOError &
return
true
;
}
bool
File
::
f
lush
()
bool
File
::
F
lush
()
{
#ifdef LINUX
int
fd
=
(
int
)(
intptr_t
)
_pxPlatformHandle
;
...
...
@@ -322,17 +322,17 @@ bool File::flush()
#endif