Tactiliest/Tactility/Source/MountPoints.cpp
Ken Van Hoeylandt 53b711584f
Merge develop into main (#337)
- Implement `UiScale` in `hal::Configuration`: small screens with no touch can now opt for a more optimized experience (e.g. Cardputer, Waveshare 1.47, Waveshare 1.3", etc.)
- Fix for Cardputer UART configuration and added I2C configuration
- Fix for software keyboard bug in Gui
- Removed deprecated fields from `hal::Configuration`
- Updated the simulator devices to use the new HAL config
- add `bool tt::hal::hasDevice(Device::Type)`
- Cleanup of `AppList` app code
- Improve `Gpio` app for small screen devices
- Added various ESP32 GCC wrappers to wrap LVGL functions (with manipulations for small screen devices)
- Moved `Launcher` assets to `assets/` subfolder
- Optimized `Toolbar` for small screen devices
- Stop showing `system/` partition in `FileBrowser` because it's read-only and not very useful. Created `config::SHOW_SYSTEM_PARTITION` to override this behaviour.
- Hide apps when their required hardware isn't available (I2C, UART, PowerDevice)
- Fix for `CYD-2432S032C` DPI setting
2025-09-15 22:46:12 +02:00

60 lines
1.6 KiB
C++

#include "Tactility/MountPoints.h"
#include "Tactility/TactilityConfig.h"
#include "Tactility/hal/Device.h"
#include "Tactility/hal/sdcard/SdCardDevice.h"
#include <Tactility/file/File.h>
#include <cstring>
#include <vector>
#include <dirent.h>
namespace tt::file {
std::vector<dirent> getMountPoints() {
std::vector<dirent> dir_entries;
dir_entries.clear();
// Data partition
auto data_dirent = dirent{
.d_ino = 1,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(data_dirent.d_name, DATA_PARTITION_NAME);
dir_entries.push_back(data_dirent);
// SD card partitions
auto sdcards = tt::hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
for (auto& sdcard : sdcards) {
auto state = sdcard->getState();
if (state == hal::sdcard::SdCardDevice::State::Mounted) {
auto mount_name = sdcard->getMountPath().substr(1);
auto dir_entry = dirent {
.d_ino = 2,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
assert(mount_name.length() < sizeof(dirent::d_name));
strcpy(dir_entry.d_name, mount_name.c_str());
dir_entries.push_back(dir_entry);
}
}
if (config::SHOW_SYSTEM_PARTITION) {
// System partition
auto system_dirent = dirent{
.d_ino = 0,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(system_dirent.d_name, SYSTEM_PARTITION_NAME);
dir_entries.push_back(system_dirent);
}
return dir_entries;
}
}