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

Method open

app/src/API/Handlers/CSVPlayerHandler.cpp:166–191  ·  view source on GitHub ↗

* @brief Open CSV file */

Source from the content-addressed store, hash-verified

164 * @brief Open CSV file
165 */
166API::CommandResponse API::Handlers::CSVPlayerHandler::open(const QString& id,
167 const QJsonObject& params)
168{
169 if (!params.contains(QStringLiteral("filePath"))) {
170 return CommandResponse::makeError(
171 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: filePath"));
172 }
173
174 const QString file_path = params.value(QStringLiteral("filePath")).toString();
175 if (file_path.isEmpty()) {
176 return CommandResponse::makeError(
177 id, ErrorCode::InvalidParam, QStringLiteral("filePath cannot be empty"));
178 }
179
180 if (!API::isPathAllowed(file_path)) {
181 return CommandResponse::makeError(
182 id, ErrorCode::InvalidParam, QStringLiteral("filePath is not allowed"));
183 }
184
185 CSV::Player::instance().openFile(file_path);
186
187 QJsonObject result;
188 result[QStringLiteral("filePath")] = file_path;
189 result[QStringLiteral("isOpen")] = CSV::Player::instance().isOpen();
190 return CommandResponse::makeSuccess(id, result);
191}
192
193/**
194 * @brief Close CSV file

Callers 15

fileOpenMethod · 0.45
loadTemplateManifestFunction · 0.45
loadTemplateBodyByIdFunction · 0.45
loadManifestFunction · 0.45
getMethod · 0.45
dryRunMethod · 0.45
exportToFileMethod · 0.45
loadMethod · 0.45
readMethod · 0.45
searchFileFunction · 0.45
writeBytesFunction · 0.45
loadMethod · 0.45

Calls 5

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

Tested by

no test coverage detected