MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / open

Method open

app/src/API/Handlers/MDF4PlayerHandler.cpp:123–148  ·  view source on GitHub ↗

* @brief Open MDF4 file */

Source from the content-addressed store, hash-verified

121 * @brief Open MDF4 file
122 */
123API::CommandResponse API::Handlers::MDF4PlayerHandler::open(const QString& id,
124 const QJsonObject& params)
125{
126 if (!params.contains(QStringLiteral("filePath"))) {
127 return CommandResponse::makeError(
128 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: filePath"));
129 }
130
131 const QString file_path = params.value(QStringLiteral("filePath")).toString();
132 if (file_path.isEmpty()) {
133 return CommandResponse::makeError(
134 id, ErrorCode::InvalidParam, QStringLiteral("filePath cannot be empty"));
135 }
136
137 if (!API::isPathAllowed(file_path)) {
138 return CommandResponse::makeError(
139 id, ErrorCode::InvalidParam, QStringLiteral("filePath is not allowed"));
140 }
141
142 MDF4::Player::instance().openFile(file_path);
143
144 QJsonObject result;
145 result[QStringLiteral("filePath")] = file_path;
146 result[QStringLiteral("isOpen")] = MDF4::Player::instance().isOpen();
147 return CommandResponse::makeSuccess(id, result);
148}
149
150/**
151 * @brief Close MDF4 file

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
openFileMethod · 0.45
isOpenMethod · 0.45

Tested by

no test coverage detected