From 32bdbdd8937bad023c0d8504ba997be3fa6ce74c Mon Sep 17 00:00:00 2001 From: Bidhya Date: Mon, 14 Feb 2022 21:53:48 +0000 Subject: GD: Delete snooz log files older than 12 hrs Test: atest bluetooth_test_gd Bug: 204123010 Tag: #refactor BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines Change-Id: Ie73674246a8c5923fe2ac086db85ebe094f108b8 --- system/gd/os/linux_generic/files.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'system/gd/os/linux_generic/files.cc') diff --git a/system/gd/os/linux_generic/files.cc b/system/gd/os/linux_generic/files.cc index bb018bf374..cf1a4aade8 100644 --- a/system/gd/os/linux_generic/files.cc +++ b/system/gd/os/linux_generic/files.cc @@ -195,5 +195,19 @@ bool RemoveFile(const std::string& path) { return true; } +std::optional> FileCreatedTime( + const std::string& path) { + struct stat file_info; + if (stat(path.c_str(), &file_info) != 0) { + LOG_ERROR("unable to read '%s' file metadata, error: %s", path.c_str(), strerror(errno)); + return std::nullopt; + } + using namespace std::chrono; + using namespace std::chrono_literals; + auto created_ts = file_info.st_ctim; + auto d = seconds{created_ts.tv_sec} + nanoseconds{created_ts.tv_nsec}; + return time_point(duration_cast(d)); +} + } // namespace os } // namespace bluetooth \ No newline at end of file -- cgit v1.2.3