Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
b
c
d
e
h
i
l
m
n
p
r
s
u
x
Typedefs
b
c
d
e
f
g
i
m
p
r
u
v
Enumerations
Enumerator
a
b
f
g
i
m
n
r
s
u
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
h
i
m
n
p
q
r
s
t
u
v
x
Enumerations
a
c
d
e
f
k
l
m
p
r
s
t
v
w
Enumerator
a
b
d
f
g
h
i
l
m
n
o
p
r
s
u
v
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
b
c
d
e
f
g
m
o
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
w
Typedefs
Enumerations
Enumerator
Macros
_
d
f
i
m
n
p
s
t
u
src
utility
Files.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <spdlog/spdlog.h>
4
5
#include <fstream>
6
#include <
tl/optional.hpp
>
7
8
#include "
Platform.hpp
"
9
10
namespace
dai
{
11
12
tl::optional<std::string>
saveFileToTemporaryDirectory
(std::vector<uint8_t>
data
, std::string filename, std::string fpath =
""
) {
13
if
(fpath.empty()) {
14
fpath =
platform::getTempPath
();
15
}
16
std::string path = std::string(fpath);
17
if
(path.back() !=
'/'
&& path.back() !=
'\\'
) {
18
path +=
'/'
;
19
}
20
path += filename;
21
22
std::ofstream file(path, std::ios::binary);
23
if
(!file.is_open()) {
24
spdlog::error
(
"Couldn't open file {} for writing"
, path);
25
return
tl::nullopt
;
26
}
27
28
file.write(
reinterpret_cast<
char
*
>
(
data
.data()),
data
.size());
29
file.close();
30
if
(!file.good()) {
31
spdlog::error
(
"Couldn't write to file {}"
, path);
32
return
tl::nullopt
;
33
}
34
spdlog::debug
(
"Saved file {} to {}"
, filename, path);
35
return
std::string(path);
36
}
37
38
}
// namespace dai
optional.hpp
tl::nullopt
static constexpr nullopt_t nullopt
Represents an empty optional.
Definition:
3rdparty/tl/optional.hpp:663
dai::logger::debug
void debug(const FormatString &fmt, Args &&...args)
Definition:
Logging.hpp:72
DAI_SPAN_NAMESPACE_NAME::detail::data
constexpr auto data(C &c) -> decltype(c.data())
Definition:
span.hpp:177
dai::logger::error
void error(const FormatString &fmt, Args &&...args)
Definition:
Logging.hpp:90
dai::platform::getTempPath
std::string getTempPath()
Definition:
Platform.cpp:59
Platform.hpp
tl::optional< std::string >
dai
Definition:
CameraExposureOffset.hpp:6
dai::saveFileToTemporaryDirectory
tl::optional< std::string > saveFileToTemporaryDirectory(std::vector< uint8_t > data, std::string filename, std::string fpath="")
Definition:
Files.hpp:12
depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19