MCPcopy Create free account
hub / github.com/comaps/comaps / GetReader

Method GetReader

libs/platform/platform_android.cpp:45–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#endif
44
45std::unique_ptr<ModelReader> Platform::GetReader(std::string const & file, std::string searchScope) const
46{
47 std::string ext = base::GetFileExtension(file);
48 strings::AsciiToLower(ext);
49 ASSERT(!ext.empty(), ());
50
51 uint32_t const logPageSize = (ext == DATA_FILE_EXTENSION) ? READER_CHUNK_LOG_SIZE : 10;
52 uint32_t const logPageCount = (ext == DATA_FILE_EXTENSION) ? READER_CHUNK_LOG_COUNT : 4;
53
54 if (searchScope.empty())
55 {
56 if (file[0] == '/')
57 searchScope = "f";
58 else
59 {
60 ASSERT(ext != ".kml" && ext != ".kmb" && ext != ".kmz", ("BookmarkManager is responsible for that"));
61
62 if (ext == DATA_FILE_EXTENSION)
63 if (file.starts_with(WORLD_COASTS_FILE_NAME) || file.starts_with(WORLD_FILE_NAME))
64 searchScope = "wsr";
65 else
66 searchScope = "w";
67 else if (file == SETTINGS_FILE_NAME)
68 searchScope = "s";
69 else
70 searchScope = "rw";
71 }
72 }
73
74#ifdef DEBUG
75 DbgLogger logger(file);
76#endif
77
78 for (char const s : searchScope)
79 {
80#ifdef DEBUG
81 logger.SetSource(s);
82#endif
83
84 switch (s)
85 {
86 case 'w':
87 {
88 auto const path = base::JoinPath(m_writableDir, file);
89 if (IsFileExistsByFullPath(path))
90 return std::make_unique<FileReader>(path, logPageSize, logPageCount);
91 break;
92 }
93
94 case 's':
95 {
96 auto const path = base::JoinPath(m_settingsDir, file);
97 if (IsFileExistsByFullPath(path))
98 return std::make_unique<FileReader>(path, logPageSize, logPageCount);
99 break;
100 }
101
102 case 'f':

Callers

nothing calls this directly

Calls 8

GetFileExtensionFunction · 0.85
AsciiToLowerFunction · 0.85
ASSERTFunction · 0.85
JoinPathFunction · 0.85
SetSourceMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected