MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / CmdListRemoteAppFiles

Function CmdListRemoteAppFiles

src/common/cli.cpp:279–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279std::string CmdListRemoteAppFiles(const std::string& provider, const std::string& accountId, const std::string& appId) {
280 std::string tokenPath = GetTokenPath(provider);
281 if (tokenPath.empty()) {
282 return JsonError("Cannot determine config directory");
283 }
284
285 auto prov = CreateCloudProvider(provider);
286 if (!prov) {
287 return JsonError("Unknown provider: " + provider);
288 }
289
290 if (!prov->Init(tokenPath)) {
291 return JsonError("Failed to initialize provider");
292 }
293
294 if (!prov->IsAuthenticated()) {
295 prov->Shutdown();
296 return JsonError("Not authenticated");
297 }
298
299 std::string prefix = accountId + "/" + appId + "/";
300 std::vector<ICloudProvider::FileInfo> files;
301 bool complete = false;
302 if (!prov->ListChecked(prefix, files, &complete)) {
303 prov->Shutdown();
304 return JsonObject({
305 {"success", JsonBool(false)},
306 {"complete", JsonBool(false)},
307 {"error", JsonString("Failed to list remote app files")},
308 {"files", "[]"}
309 });
310 }
311 prov->Shutdown();
312
313 std::ostringstream out;
314 out << "[";
315 bool first = true;
316 for (const auto& f : files) {
317 if (!first) out << ",";
318 out << JsonObject({
319 {"path", JsonString(f.path)},
320 {"size", JsonInt(static_cast<int64_t>(f.size))},
321 {"modified_time", JsonInt(static_cast<int64_t>(f.modifiedTime))}
322 });
323 first = false;
324 }
325 out << "]";
326
327 return JsonObject({
328 {"success", JsonBool(true)},
329 {"complete", JsonBool(complete)},
330 {"files", out.str()}
331 });
332}
333
334std::string CmdDeleteRemoteApp(const std::string& provider, const std::string& accountId, const std::string& appId) {
335 std::string tokenPath = GetTokenPath(provider);

Callers 1

RunCliFunction · 0.85

Calls 11

GetTokenPathFunction · 0.85
JsonErrorFunction · 0.85
CreateCloudProviderFunction · 0.85
JsonObjectFunction · 0.85
JsonBoolFunction · 0.85
JsonStringFunction · 0.85
JsonIntFunction · 0.85
InitMethod · 0.45
IsAuthenticatedMethod · 0.45
ShutdownMethod · 0.45
ListCheckedMethod · 0.45

Tested by

no test coverage detected