diff options
author | Shobhit Adlakha <ShobhitAd@users.noreply.github.com> | 2019-03-06 13:36:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 13:36:58 -0500 |
commit | 222ec0566594288744d73ef30174e714bd6f29ce (patch) | |
tree | d92070464b2cb41f989ddb32595ceedc06674cff /src/components/utils/src/file_system.cc | |
parent | 2e433d4810c1a9a4a78550b6caa0a27ff03259ef (diff) | |
download | sdl_core-222ec0566594288744d73ef30174e714bd6f29ce.tar.gz |
GetFile RPC (#2811)
* Implemented GetFile rpc in MOBILE API
* Initial implementation of GetFile rpc
* Implemented GetFile RPC
* Fixed binary data param in GetFile response
* Added case for handling SmartType UInteger in SmartObject::duplicate function
* Implemented offset and length params
* Implemented GetFile for services published by the HMI
* Switched to events to handle forwarding GetFile request to HMI
* Addressed review comments
* Addressed review comments
* Addressed review comments
* Implemented length parameter
* Changed RPC name from GetFileFromHMI to GetFilePath
* Fix MOBILE_API formatting
* Fix HMI_API formatting
* Addressed review comments
* Checking success rather than result code for hmi response
Diffstat (limited to 'src/components/utils/src/file_system.cc')
-rw-r--r-- | src/components/utils/src/file_system.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc index f98aeda056..430cf40da0 100644 --- a/src/components/utils/src/file_system.cc +++ b/src/components/utils/src/file_system.cc @@ -316,6 +316,26 @@ bool file_system::ReadBinaryFile(const std::string& name, return true; } +bool file_system::ReadBinaryFile(const std::string& name, + std::vector<uint8_t>& result, + uint32_t offset, + uint32_t length) { + if (!FileExists(name) || !IsAccessible(name, R_OK)) { + return false; + } + + std::ifstream file(name.c_str(), std::ios_base::binary); + file.ignore(offset); + std::ostringstream ss; + std::string s; + s.resize(length); + file.read(&s[0], length); + + result.resize(s.length()); + std::copy(s.begin(), s.end(), result.begin()); + return true; +} + bool file_system::ReadFile(const std::string& name, std::string& result) { if (!FileExists(name) || !IsAccessible(name, R_OK)) { return false; |