refactor getMediaFileTree

This commit is contained in:
uncor3
2025-08-24 01:35:08 +00:00
parent 181a3365a2
commit f46627ab81
2 changed files with 7 additions and 25 deletions
@@ -1,29 +1,24 @@
#include "./get-media.h"
#include "../../iDescriptor.h"
#include <QDebug>
#include <iostream>
#include <libimobiledevice/afc.h>
#include <libimobiledevice/lockdown.h>
#include <string.h>
MediaFileTree getMediaFileTree(afc_client_t afcClient,
lockdownd_service_descriptor_t lockdownService,
const std::string &path = "/")
MediaFileTree get_file_tree(afc_client_t afcClient, idevice_t device,
const std::string &path)
{
MediaFileTree result;
result.currentPath = path;
if (afcClient == nullptr) {
qDebug() << "AFC client is not initialized in getMediaFileTree";
}
if (lockdownService == nullptr) {
qDebug() << "Lockdown service is not initialized in getMediaFileTree";
qDebug() << "AFC client is not initialized in get_file_tree";
}
char **dirs = NULL;
if (afc_read_directory(afcClient, path.c_str(), &dirs) != AFC_E_SUCCESS) {
if (safe_afc_read_directory(afcClient, device, path.c_str(), &dirs) !=
AFC_E_SUCCESS) {
// afc_client_free(afcClient);
// lockdownd_service_descriptor_free(lockdownService);
result.success = false;
@@ -57,6 +52,7 @@ MediaFileTree getMediaFileTree(afc_client_t afcClient,
}
result.entries.push_back({entryName, isDir});
}
free(dirs);
// TODO : Freed when device is disconnected
// afc_client_free(afc);
// lockdownd_service_descriptor_free(service);
-14
View File
@@ -1,14 +0,0 @@
#pragma once
#include <string>
#include <vector>
struct MediaEntry {
std::string name;
bool isDir;
};
struct MediaFileTree {
std::vector<MediaEntry> entries;
bool success;
std::string currentPath;
};