1 // Copyright 2023 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_system/file_manager.h"
16
17 #if PW_SYSTEM_ENABLE_TRACE_SERVICE
18 #include "pw_system/trace_service.h"
19 #endif
20
21 namespace pw::system {
22
23 namespace {
24 FileManager file_manager;
25 }
26
GetFileManager()27 FileManager& GetFileManager() { return file_manager; }
28
FileManager()29 FileManager::FileManager()
30 #if PW_SYSTEM_ENABLE_TRACE_SERVICE
31 : trace_data_handler_(kTraceTransferHandlerId, GetTraceData()),
32 trace_data_filesystem_entry_(
33 "/trace/0.bin",
34 kTraceTransferHandlerId,
35 file::FlatFileSystemService::Entry::FilePermissions::READ,
36 GetTraceData())
37 #endif
38 {
39 // Every handler & filesystem element must be added to the collections, using
40 // the associated handler ID as the index.
41 #if PW_SYSTEM_ENABLE_TRACE_SERVICE
42 transfer_handlers_[kTraceTransferHandlerId] = &trace_data_handler_;
43 file_system_entries_[kTraceTransferHandlerId] = &trace_data_filesystem_entry_;
44 #endif
45 }
46
47 } // namespace pw::system
48