mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-24 04:45:32 -04:00
universal7885: parts-hidl: Use libFileIO
- Also fix compile errors
This commit is contained in:
parent
840e252b72
commit
3e5e571267
15 changed files with 150 additions and 210 deletions
|
|
@ -1,7 +1,9 @@
|
|||
cc_library_shared {
|
||||
name: "libfileio",
|
||||
srcs: ["FileIO.cpp"],
|
||||
include_dirs: ["include"],
|
||||
cppflags: ["-fexceptions"],
|
||||
local_include_dirs: ["include"],
|
||||
export_include_dirs: ["include"],
|
||||
shared_libs: ["liblog"],
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,15 +25,14 @@ int readline(const char *path) {
|
|||
try {
|
||||
return stoi(value);
|
||||
} catch (std::invalid_argument const &ex) {
|
||||
ALOGE("%s: stoi(): invalid argument: for %s", __func__, value);
|
||||
ALOGE("%s: stoi(): invalid argument: for %s", __func__, value.c_str());
|
||||
} catch (std::out_of_range const &ex) {
|
||||
ALOGE("%s: stoi(): out of range: for %s", __func__, value);
|
||||
ALOGE("%s: stoi(): out of range: for %s", __func__, value.c_str());
|
||||
}
|
||||
return EXIT_ERR;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void writeline(const char *path, const T data) {
|
||||
void writeline(const char *path, const std::string& data) {
|
||||
std::ofstream file;
|
||||
file.open(path);
|
||||
ALOGD("%s: Opening %s", __func__, path);
|
||||
|
|
@ -45,4 +44,8 @@ void writeline(const char *path, const T data) {
|
|||
ALOGE("%s: Failed to open %s", __func__, path);
|
||||
}
|
||||
|
||||
void writeline(const char *path, const int data) {
|
||||
writeline(path, std::to_string(data));
|
||||
}
|
||||
|
||||
} // namespace FileIO
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace FileIO {
|
||||
int readline(const char *path);
|
||||
|
||||
template <typename T>
|
||||
void writeline(const char *path, const T data);
|
||||
void writeline(const char *path, const std::string& data);
|
||||
void writeline(const char *path, const int data);
|
||||
} // namespace FileIO
|
||||
|
|
|
|||
Loading…
Reference in a new issue