mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 18:32:10 +02:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3f13bdca9 | |||
| 55444b9c4e | |||
| 2f14d7742e | |||
| 0534882f4e | |||
| ce2f2f4416 | |||
| 5259aeb039 | |||
| e51999edd1 | |||
| 2f96c847b9 | |||
| 32d6436027 | |||
| 7358326a13 | |||
| 434a879538 | |||
| 745a8dda65 | |||
| c40086615f | |||
| fe3d38e542 | |||
| f19a3b5549 | |||
| eb308e1861 | |||
| 9a4e7874d6 | |||
| d78e528527 | |||
| 81f0e4d583 | |||
| 1d9f462071 | |||
| 047dca3849 | |||
| 1f7c6ab70c | |||
| 1c49ae5324 | |||
| 2e82f8294f | |||
| b2ead8735b | |||
| 5e9166847d | |||
| 28c01599d5 | |||
| ce47a82fb5 | |||
| f1b047c32b | |||
| bc6ed4f4a2 | |||
| b1ac31f590 | |||
| 326d83f25b | |||
| 7218164088 | |||
| 6f970c36e3 | |||
| eea4150dbd | |||
| afa736c37d | |||
| 643e632368 | |||
| ffe354ab07 | |||
| f77090070c | |||
| fd5d2c84e8 | |||
| ef6af84ea1 | |||
| f64bf73279 |
@@ -187,7 +187,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG64
|
||||
update: true
|
||||
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
install: git mingw-w64-clang-x86_64-7zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -222,13 +222,16 @@ jobs:
|
||||
run: ctest
|
||||
|
||||
- name: create zip archive
|
||||
run: zip fastfetch-$(./fastfetch --version-raw)-Win64.zip *.dll fastfetch.exe flashfetch.exe
|
||||
run: 7z a -tzip -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win64.zip *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: create 7z archive
|
||||
run: 7z a -t7z -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win64.7z *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: fastfetch-win64
|
||||
path: ./fastfetch-*-Win64.zip
|
||||
path: ./fastfetch-*-Win64.*
|
||||
|
||||
win32:
|
||||
name: Win32
|
||||
@@ -248,7 +251,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG32
|
||||
update: true
|
||||
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
|
||||
install: git mingw-w64-clang-i686-7zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -280,13 +283,16 @@ jobs:
|
||||
run: ctest
|
||||
|
||||
- name: create zip archive
|
||||
run: zip fastfetch-$(./fastfetch --version-raw)-Win32.zip *.dll fastfetch.exe flashfetch.exe
|
||||
run: 7z a -tzip -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win32.zip *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: create 7z archive
|
||||
run: 7z a -t7z -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win32.7z *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: fastfetch-win32
|
||||
path: ./fastfetch-*-Win32.zip
|
||||
path: ./fastfetch-*-Win32.*
|
||||
|
||||
release:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'fastfetch-cli/fastfetch'
|
||||
|
||||
@@ -1,3 +1,43 @@
|
||||
# 2.0.5
|
||||
|
||||
Bugfixes:
|
||||
* Fix segfault when using libxrandr (#544, Display, Linux)
|
||||
* Don't print 0px (#544, Cursor)
|
||||
|
||||
Features:
|
||||
* Add option `--disk-use-available` (#543)
|
||||
* Add option `--disk-show-readonly`
|
||||
|
||||
# 2.0.4
|
||||
|
||||
Bugfixes:
|
||||
* Fix building on 32-bit FreeBSD (Memory, BSD)
|
||||
* Fix `--file-raw` doesn't work (Logo)
|
||||
|
||||
Features:
|
||||
* Trait `-` as an alias for `/dev/stdin`. Available for `--file`, `--file-raw` and `--raw` (Logo)
|
||||
|
||||
# 2.0.3
|
||||
|
||||
Bugfixes:
|
||||
* Fix typo in config parsing for --color-title (#534)
|
||||
* Fix percent formatting for `--*-format` (#535)
|
||||
* Fix loading presets for homebrew (macOS)
|
||||
|
||||
Features:
|
||||
* Add option `--percent-ndigits`
|
||||
* Add command flag `--config` as an alias of `--load-config`
|
||||
* Windows packages now include presets (Windows)
|
||||
|
||||
# 2.0.2
|
||||
|
||||
Bugfixes:
|
||||
* Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows)
|
||||
* Fix presets not detected by file name (#529)
|
||||
|
||||
Logo:
|
||||
* Add Tuxedo OS
|
||||
|
||||
# 2.0.1
|
||||
|
||||
First stable release of Fastfetch V2
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.0.1
|
||||
VERSION 2.0.5
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -825,6 +825,7 @@ elseif(WIN32)
|
||||
)
|
||||
elseif(BSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
PRIVATE "usbhid"
|
||||
)
|
||||
elseif(ANDROID)
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
# Fastfetch
|
||||
|
||||
[](https://github.com/fastfetch-cli/fastfetch/actions/workflows/ci.yml)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://repology.org/project/fastfetch/versions)
|
||||
[](https://repology.org/project/fastfetch/versions)
|
||||
|
||||
Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written mainly in C, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported.
|
||||
|
||||
@@ -101,9 +110,9 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa
|
||||
|
||||
##### Builtin logos
|
||||
|
||||
<!-- `Content of src/logo/builtin.c`.split('\n').map(x => x.trim()).filter(x => x.startsWith('// ')).map(x => x.slice(3)).sort((a,b)=>a.toUpperCase().localeCompare(b.toUpperCase())).join(', ') -->
|
||||
<!-- `Content of src/logo/builtin.c`.split('\n').map(x => x.trim()).filter(x => x.startsWith('// ')).map(x => x.slice(3)).filter(x => x != 'LAST').sort((a, b)=>a.toUpperCase().localeCompare(b.toUpperCase())).join(', ') -->
|
||||
```
|
||||
AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin
|
||||
AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, TuxedoOS, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin
|
||||
```
|
||||
|
||||
Run `fastfetch --print-logos` to print them
|
||||
|
||||
+20
-1
@@ -343,6 +343,8 @@
|
||||
"sizeNdigits": {
|
||||
"type": "integer",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting sizes",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 2
|
||||
},
|
||||
"sizeMaxPrefix": {
|
||||
@@ -388,9 +390,16 @@
|
||||
"type": "number",
|
||||
"title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"maximum": 255,
|
||||
"default": 1
|
||||
},
|
||||
"percentNdigits": {
|
||||
"type": "number",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting percentage numbers",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 0
|
||||
},
|
||||
"noBuffer": {
|
||||
"type": "boolean",
|
||||
"title": "Whether to disable the stdout application buffer",
|
||||
@@ -875,11 +884,21 @@
|
||||
"title": "Set if subvolumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"showReadOnly": {
|
||||
"type": "boolean",
|
||||
"title": "Set if read only volumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"showUnknown": {
|
||||
"type": "boolean",
|
||||
"title": "Set if unknown (unable to detect sizes) volumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"useAvailable": {
|
||||
"type": "boolean",
|
||||
"title": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes",
|
||||
"default": false
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
|
||||
}
|
||||
}
|
||||
ffStrbufAppendF(buffer, "%u%%", (unsigned) (percent + 0.5));
|
||||
ffStrbufAppendF(buffer, "%.*f%%", instance.config.percentNdigits, percent);
|
||||
|
||||
if (colored && !instance.config.pipe)
|
||||
{
|
||||
|
||||
@@ -74,6 +74,7 @@ static void defaultConfig(void)
|
||||
instance.config.barWidth = 10;
|
||||
instance.config.barBorder = true;
|
||||
instance.config.percentType = 1;
|
||||
instance.config.percentNdigits = 0;
|
||||
|
||||
ffInitBatteryOptions(&instance.config.battery);
|
||||
ffInitBiosOptions(&instance.config.bios);
|
||||
|
||||
@@ -325,7 +325,9 @@ const char* ffParseDisplayJsonConfig(void)
|
||||
config->temperatureUnit = (FFTemperatureUnit) value;
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "percentType"))
|
||||
config->percentType = (uint32_t) yyjson_get_uint(val);
|
||||
config->percentType = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "percentNdigits"))
|
||||
config->percentNdigits = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "bar"))
|
||||
{
|
||||
if (yyjson_is_obj(val))
|
||||
|
||||
@@ -19,6 +19,7 @@ Informative options:
|
||||
|
||||
General options:
|
||||
--load-config <file>: Load a config file or preset (+)
|
||||
--config <file>: Alias of --load-config (+)
|
||||
--multithreading <?value>: Use multiple threads to detect values
|
||||
--stat <?value>: Show time usage (in ms) for individual modules
|
||||
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
|
||||
@@ -70,6 +71,7 @@ Display options:
|
||||
--hide-cursor <?value>: Whether to hide the cursor during the run
|
||||
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
|
||||
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1
|
||||
--percent-ndigits <value>: Set the number of digits to keep after the decimal point when formatting percentage numbers. Default is 0
|
||||
--bar-char-elapsed <str>: Set the character to use in elapsed part. Default is '■'
|
||||
--bar-char-total <str>: Set the character to use in total part. Default is '-'
|
||||
--bar-width <?num>: Set the width of the bar, in number of characters. Default is 10
|
||||
@@ -127,7 +129,9 @@ Module specific options:
|
||||
--disk-show-external <?value>: Set if external volume should be printed. Default is true
|
||||
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
|
||||
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
|
||||
--disk-show-readonly <?value>: Set if read only volumes should be printed. Default is false
|
||||
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
|
||||
--disk-use-available <?value>: Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes. Default is false
|
||||
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
|
||||
--display-compact-type: <?string>: Set if all displays should be printed in one line. Default is none
|
||||
--display-detect-name: <?value>: Set if display name should be detected and printed (if supported). Default is false
|
||||
|
||||
@@ -7,7 +7,7 @@ static int compareDisks(const void* disk1, const void* disk2)
|
||||
return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint);
|
||||
}
|
||||
|
||||
const char* ffDetectDisks(FFlist* disks)
|
||||
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
const char* error = ffDetectDisksImpl(disks);
|
||||
|
||||
@@ -22,7 +22,13 @@ const char* ffDetectDisks(FFlist* disks)
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
|
||||
{
|
||||
if(disk->bytesTotal == 0)
|
||||
disk->type |= FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
else
|
||||
{
|
||||
disk->bytesUsed = disk->bytesTotal - (
|
||||
options->calcType == FF_DISK_CALC_TYPE_FREE ? disk->bytesFree : disk->bytesAvailable
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -10,9 +10,11 @@ typedef struct FFDisk
|
||||
FFstrbuf mountpoint;
|
||||
FFstrbuf filesystem;
|
||||
FFstrbuf name;
|
||||
FFDiskType type;
|
||||
FFDiskVolumeType type;
|
||||
|
||||
uint64_t bytesUsed;
|
||||
uint64_t bytesFree;
|
||||
uint64_t bytesAvailable;
|
||||
uint64_t bytesTotal;
|
||||
|
||||
uint32_t filesUsed;
|
||||
@@ -23,6 +25,6 @@ typedef struct FFDisk
|
||||
* Returns a List of FFDisk, sorted alphabetically by mountpoint.
|
||||
* If error is not set, disks contains at least one disk.
|
||||
*/
|
||||
const char* ffDetectDisks(FFlist* result /* list of FFDisk */);
|
||||
const char* ffDetectDisks(FFDiskOptions* options, FFlist* result /* list of FFDisk */);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
{
|
||||
// FreeBSD doesn't support these flags
|
||||
if(fs->f_flags & MNT_DONTBROWSE)
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else if(fs->f_flags & MNT_REMOVABLE)
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
|
||||
ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String);
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
if(ffStrbufEqualS(&disk->filesystem, "zfs"))
|
||||
{
|
||||
disk->type = !ffStrStartsWith(fs->f_mntfromname, "zroot/") || ffStrStartsWith(fs->f_mntfromname, "zroot/ROOT/")
|
||||
? FF_DISK_TYPE_REGULAR_BIT
|
||||
: FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
|
||||
: FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
}
|
||||
else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/"))
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else if(!(fs->f_flags & MNT_LOCAL))
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
|
||||
ffStrbufInit(&disk->name);
|
||||
}
|
||||
@@ -45,7 +45,9 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
#endif
|
||||
|
||||
disk->bytesTotal = fs->f_blocks * fs->f_bsize;
|
||||
disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bfree * fs->f_bsize);
|
||||
disk->bytesFree = (uint64_t)fs->f_bfree * fs->f_bsize;
|
||||
disk->bytesAvailable = (uint64_t)fs->f_bavail * fs->f_bsize;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs->f_files;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree);
|
||||
@@ -53,6 +55,9 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
ffStrbufInitS(&disk->mountpoint, fs->f_mntonname);
|
||||
ffStrbufInitS(&disk->filesystem, fs->f_fstypename);
|
||||
detectFsInfo(fs, disk);
|
||||
|
||||
if(fs->f_flags & MNT_RDONLY)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -155,11 +155,11 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
|
||||
static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDisk, FF_MAYBE_UNUSED const char* options)
|
||||
{
|
||||
if(ffStrbufEqualS(¤tDisk->mountpoint, "/") || ffStrbufEqualS(¤tDisk->mountpoint, "/storage/emulated"))
|
||||
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/mnt/media_rw/"))
|
||||
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -191,13 +191,13 @@ static bool isSubvolume(const FFlist* devices)
|
||||
static void detectType(const FFlist* devices, FFDisk* currentDisk, const char* options)
|
||||
{
|
||||
if(isSubvolume(devices))
|
||||
currentDisk->type = FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
else if(strstr(options, "nosuid") != NULL || strstr(options, "nodev") != NULL)
|
||||
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/boot") || ffStrbufStartsWithS(¤tDisk->mountpoint, "/efi"))
|
||||
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else
|
||||
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -209,10 +209,15 @@ static void detectStats(FFDisk* disk)
|
||||
memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
|
||||
|
||||
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
|
||||
disk->bytesUsed = disk->bytesTotal - (fs.f_bfree * fs.f_frsize);
|
||||
disk->bytesFree = fs.f_bfree * fs.f_frsize;
|
||||
disk->bytesAvailable = fs.f_bavail * fs.f_frsize;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs.f_files;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
|
||||
|
||||
if(fs.f_flag & ST_RDONLY)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks)
|
||||
|
||||
@@ -25,20 +25,25 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
ffStrbufInitWS(&disk->mountpoint, mountpoint);
|
||||
|
||||
uint64_t bytesFree;
|
||||
if(!GetDiskFreeSpaceExW(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
|
||||
if(!GetDiskFreeSpaceExW(
|
||||
mountpoint,
|
||||
(PULARGE_INTEGER)&disk->bytesAvailable,
|
||||
(PULARGE_INTEGER)&disk->bytesTotal,
|
||||
(PULARGE_INTEGER)&disk->bytesFree
|
||||
))
|
||||
{
|
||||
disk->bytesTotal = 0;
|
||||
bytesFree = 0;
|
||||
disk->bytesFree = 0;
|
||||
disk->bytesAvailable = 0;
|
||||
}
|
||||
disk->bytesUsed = disk->bytesTotal - bytesFree;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else if(driveType == DRIVE_FIXED)
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
|
||||
ffStrbufInit(&disk->filesystem);
|
||||
ffStrbufInit(&disk->name);
|
||||
@@ -47,11 +52,12 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
|
||||
UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||
|
||||
DWORD diskFlags;
|
||||
BOOL result = GetVolumeInformationW(mountpoint,
|
||||
diskName, sizeof(diskName) / sizeof(*diskName), //Volume name
|
||||
NULL, //Serial number
|
||||
NULL, //Max component length
|
||||
NULL, //File system flags
|
||||
&diskFlags, //File system flags
|
||||
diskFileSystem, sizeof(diskFileSystem) / sizeof(*diskFileSystem)
|
||||
);
|
||||
SetErrorMode(errorMode);
|
||||
@@ -60,6 +66,8 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
{
|
||||
ffStrbufSetWS(&disk->filesystem, diskFileSystem);
|
||||
ffStrbufSetWS(&disk->name, diskName);
|
||||
if(diskFlags & FILE_READ_ONLY_VOLUME)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
//Unsupported
|
||||
|
||||
@@ -116,6 +116,7 @@ typedef struct XrandrData
|
||||
{
|
||||
FF_LIBRARY_SYMBOL(XInternAtom)
|
||||
FF_LIBRARY_SYMBOL(XGetAtomName);
|
||||
FF_LIBRARY_SYMBOL(XFree);
|
||||
FF_LIBRARY_SYMBOL(XRRGetScreenInfo)
|
||||
FF_LIBRARY_SYMBOL(XRRConfigCurrentConfiguration)
|
||||
FF_LIBRARY_SYMBOL(XRRConfigCurrentRate)
|
||||
@@ -207,9 +208,11 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
Atom atomEdid = data->ffXInternAtom(data->display, "EDID", true);
|
||||
if (atomEdid != None)
|
||||
{
|
||||
unsigned long nitems = 0;
|
||||
int actual_format = 0;
|
||||
unsigned long nitems = 0, bytes_after = 0;
|
||||
Atom actual_type = None;
|
||||
uint8_t* edidData = NULL;
|
||||
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, 0, 0, AnyPropertyType, NULL, NULL, &nitems, NULL, &edidData) == Success)
|
||||
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, false, false, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &edidData) == Success)
|
||||
{
|
||||
if (nitems >= 128)
|
||||
{
|
||||
@@ -217,6 +220,8 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
ffEdidGetName(edidData, name);
|
||||
}
|
||||
}
|
||||
if (edidData)
|
||||
data->ffXFree(edidData);
|
||||
}
|
||||
bool res = xrandrHandleCrtc(data, outputInfo->crtc, name, primary);
|
||||
|
||||
@@ -228,8 +233,9 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
{
|
||||
bool foundOutput = false;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(data->ffXGetAtomName(data->display, monitorInfo->name));
|
||||
char* xname = data->ffXGetAtomName(data->display, monitorInfo->name);
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(xname);
|
||||
data->ffXFree(xname);
|
||||
for(int i = 0; i < monitorInfo->noutput; i++)
|
||||
{
|
||||
if(xrandrHandleOutput(data, monitorInfo->outputs[i], &name, monitorInfo->primary))
|
||||
@@ -341,6 +347,7 @@ void ffdsConnectXrandr(FFDisplayServerResult* result)
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XInternAtom,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XGetAtomName,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XFree,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenInfo,)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentRate,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentConfiguration,);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
{
|
||||
uint64_t length = sizeof(ram->bytesTotal);
|
||||
size_t length = sizeof(ram->bytesTotal);
|
||||
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
|
||||
return "Failed to read hw.physmem";
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@ typedef struct FFOpenGLResult
|
||||
FFstrbuf slv;
|
||||
} FFOpenGLResult;
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result);
|
||||
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatOb
|
||||
return error;
|
||||
}
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
CGLPixelFormatObj pixelFormat;
|
||||
CGLPixelFormatAttribute attrs[] = {
|
||||
|
||||
@@ -314,11 +314,11 @@ static const char* osMesaPrint(FFOpenGLResult* result)
|
||||
|
||||
#endif //FF_HAVE_OSMESA
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
#if FF_HAVE_GL
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_GLX)
|
||||
if(options->library == FF_OPENGL_LIBRARY_GLX)
|
||||
{
|
||||
#ifdef FF_HAVE_GLX
|
||||
return glxPrint(result);
|
||||
@@ -327,7 +327,7 @@ const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_EGL)
|
||||
if(options->library == FF_OPENGL_LIBRARY_EGL)
|
||||
{
|
||||
#ifdef FF_HAVE_EGL
|
||||
return eglPrint(result);
|
||||
@@ -336,7 +336,7 @@ const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_OSMESA)
|
||||
if(options->library == FF_OPENGL_LIBRARY_OSMESA)
|
||||
{
|
||||
#ifdef FF_HAVE_OSMESA
|
||||
return osMesaPrint(result);
|
||||
|
||||
@@ -82,7 +82,7 @@ LRESULT CALLBACK wglHandleWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
||||
}
|
||||
}
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
MSG msg = {0};
|
||||
WNDCLASSW wc = {
|
||||
|
||||
@@ -48,7 +48,7 @@ static void getProcessInformation(pid_t pid, FFstrbuf* processName, FFstrbuf* ex
|
||||
if(length > 0)
|
||||
exe->length = (uint32_t)length;
|
||||
|
||||
#else
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
size_t size = exe->allocated;
|
||||
if(!sysctl(
|
||||
|
||||
+24
-8
@@ -58,11 +58,11 @@ static inline void printCommandHelp(const char* command)
|
||||
{
|
||||
if(command == NULL)
|
||||
puts(FASTFETCH_DATATEXT_HELP);
|
||||
else if(ffStrEqualsIgnCase(command, "c") || ffStrEqualsIgnCase(command, "color"))
|
||||
else if(ffStrEqualsIgnCase(command, "color"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_COLOR);
|
||||
else if(ffStrEqualsIgnCase(command, "format"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_FORMAT);
|
||||
else if(ffStrEqualsIgnCase(command, "load-config") || ffStrEqualsIgnCase(command, "loadconfig") || ffStrEqualsIgnCase(command, "config"))
|
||||
else if(ffStrEqualsIgnCase(command, "load-config") || ffStrEqualsIgnCase(command, "config"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_CONFIG);
|
||||
else if(ffStrEqualsIgnCase(command, "os-format"))
|
||||
{
|
||||
@@ -758,7 +758,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128);
|
||||
if (ffPathExpandEnv(value, &absolutePath))
|
||||
{
|
||||
bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
@@ -773,7 +773,20 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
ffStrbufAppendS(&absolutePath, "fastfetch/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
//Try exe path
|
||||
ffStrbufSet(&absolutePath, &instance.state.platform.exePath);
|
||||
ffStrbufSubstrBeforeLastC(&absolutePath, '/');
|
||||
ffStrbufAppendS(&absolutePath, "/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
@@ -932,7 +945,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
//General options//
|
||||
///////////////////
|
||||
|
||||
else if(ffStrEqualsIgnCase(key, "--load-config"))
|
||||
else if(ffStrEqualsIgnCase(key, "--load-config") || ffStrEqualsIgnCase(key, "--config"))
|
||||
optionParseConfigFile(data, key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--gen-config"))
|
||||
generateConfigFile(false, value);
|
||||
@@ -1002,7 +1015,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
optionCheckString(key, value, &instance.config.colorKeys);
|
||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "-title"))
|
||||
else if(ffStrEqualsIgnCase(subkey, "-title"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorTitle);
|
||||
ffOptionParseColor(value, &instance.config.colorTitle);
|
||||
@@ -1053,7 +1066,9 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
});
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-type"))
|
||||
instance.config.percentType = ffOptionParseUInt32(key, value);
|
||||
instance.config.percentType = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-ndigits"))
|
||||
instance.config.percentNdigits = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--no-buffer"))
|
||||
instance.config.noBuffer = ffOptionParseBoolean(value);
|
||||
else if(ffStrStartsWithIgnCase(key, "--bar"))
|
||||
@@ -1190,7 +1205,8 @@ static void parseArguments(FFdata* data, int argc, const char** argv)
|
||||
}
|
||||
|
||||
if(i == argc - 1 || (
|
||||
*argv[i + 1] == '-' &&
|
||||
argv[i + 1][0] == '-' &&
|
||||
argv[i + 1][1] != '\0' && // `-` is used as an alias for `/dev/stdin`
|
||||
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
||||
)) {
|
||||
parseOption(data, argv[i], NULL);
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ typedef struct FFconfig
|
||||
FFstrbuf barCharTotal;
|
||||
uint8_t barWidth;
|
||||
bool barBorder;
|
||||
uint32_t percentType;
|
||||
uint8_t percentType;
|
||||
uint8_t percentNdigits;
|
||||
bool pipe; //disables logo and all escape sequences
|
||||
bool multithreading;
|
||||
bool stat;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#############################+
|
||||
.%#######################%@@@+
|
||||
. :#@%-
|
||||
.#@%%%- =@@#.
|
||||
*@%@@= +@@+
|
||||
=@@%@+.#@%-
|
||||
-@@%@@@#:
|
||||
.#@%%@-
|
||||
:#@@%@@=
|
||||
=@@+=@@%@+
|
||||
.#@@= -@@%@#
|
||||
-%@#: :%@%@%:
|
||||
*@@+ .#%%%%-
|
||||
:%@%- .
|
||||
+@@@%#%%%%%%%%%%%%%%%%%%%%%%%.
|
||||
+######################*******
|
||||
@@ -3657,6 +3657,15 @@ static const FFlogo T[] = {
|
||||
FF_COLOR_FG_CYAN,
|
||||
},
|
||||
},
|
||||
// TuxedoOS
|
||||
{
|
||||
.names = {"Tuxedo OS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_TUXEDO_OS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
FF_COLOR_FG_RED,
|
||||
},
|
||||
},
|
||||
// Twister
|
||||
{
|
||||
.names = {"Twister"},
|
||||
|
||||
+7
-17
@@ -3,6 +3,7 @@
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/syslimits.h>
|
||||
@@ -184,12 +185,6 @@ static inline bool checkAllocationResult(void* data, size_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline uint32_t simpleCeil(double value)
|
||||
{
|
||||
uint32_t result = (uint32_t) value;
|
||||
return value == (double) result ? result : result + 1;
|
||||
}
|
||||
|
||||
static void writeCacheStrbuf(FFLogoRequestData* requestData, const FFstrbuf* value, const char* cacheFileName)
|
||||
{
|
||||
uint32_t cacheDirLength = requestData->cacheDir.length;
|
||||
@@ -463,8 +458,8 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
else if(requestData->logoPixelHeight == 0)
|
||||
requestData->logoPixelHeight = (uint32_t) ((double) imageData.image->rows / (double) imageData.image->columns * requestData->logoPixelWidth);
|
||||
|
||||
requestData->logoCharacterWidth = simpleCeil((double) requestData->logoPixelWidth / requestData->characterPixelWidth);
|
||||
requestData->logoCharacterHeight = simpleCeil((double) requestData->logoPixelHeight / requestData->characterPixelHeight);
|
||||
requestData->logoCharacterWidth = (uint32_t) ceil((double) requestData->logoPixelWidth / requestData->characterPixelWidth);
|
||||
requestData->logoCharacterHeight = (uint32_t) ceil((double) requestData->logoPixelHeight / requestData->characterPixelHeight);
|
||||
|
||||
if(requestData->logoPixelWidth == 0 || requestData->logoPixelHeight == 0 || requestData->logoCharacterWidth == 0 || requestData->logoCharacterHeight == 0)
|
||||
{
|
||||
@@ -608,8 +603,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData)
|
||||
instance.state.logoHeight = requestData->logoCharacterHeight + instance.config.logo.paddingTop;
|
||||
|
||||
//Go to upper left corner
|
||||
fputs("\033[9999999D", stdout);
|
||||
printf("\033[%uA", instance.state.logoHeight);
|
||||
printf("\033[9999999D\033[%uA", instance.state.logoHeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -674,8 +668,8 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
|
||||
return false;
|
||||
}
|
||||
|
||||
requestData.logoPixelWidth = simpleCeil((double) instance.config.logo.width * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = simpleCeil((double) instance.config.logo.height * requestData.characterPixelHeight);
|
||||
requestData.logoPixelWidth = (uint32_t) ceil((double) instance.config.logo.width * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = (uint32_t) ceil((double) instance.config.logo.height * requestData.characterPixelHeight);
|
||||
|
||||
ffStrbufInit(&requestData.cacheDir);
|
||||
ffStrbufAppend(&requestData.cacheDir, &instance.state.platform.cacheDir);
|
||||
@@ -692,11 +686,7 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
|
||||
}
|
||||
ffStrbufRecalculateLength(&requestData.cacheDir);
|
||||
ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/');
|
||||
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth);
|
||||
ffStrbufAppendC(&requestData.cacheDir, '*');
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight);
|
||||
ffStrbufAppendC(&requestData.cacheDir, '/');
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u*%u/", requestData.logoPixelWidth, requestData.logoPixelHeight);
|
||||
|
||||
if(!instance.config.logo.recache && printCached(&requestData))
|
||||
{
|
||||
|
||||
+4
-1
@@ -359,7 +359,10 @@ static bool logoPrintFileIfExists(bool doColorReplacement, bool raw)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
|
||||
if(!ffAppendFileBuffer(options->source.chars, &content))
|
||||
if(ffStrbufEqualS(&options->source, "-")
|
||||
? !ffAppendFDBuffer(FFUnixFD2NativeFD(STDIN_FILENO), &content)
|
||||
: !ffAppendFileBuffer(options->source.chars, &content)
|
||||
)
|
||||
{
|
||||
fprintf(stderr, "Logo: Failed to load file content from logo source: %s \n", options->source.chars);
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ logoType:
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_FILE;
|
||||
}
|
||||
else if(strcasecmp(key, "raw") == 0)
|
||||
else if(strcasecmp(subKey, "raw") == 0)
|
||||
{
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_FILE_RAW;
|
||||
|
||||
@@ -10,17 +10,16 @@
|
||||
|
||||
static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
{
|
||||
if(instance.config.battery.moduleArgs.outputFormat.length == 0)
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
bool showStatus =
|
||||
!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
result->status.length > 0 &&
|
||||
ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(result->capacity >= 0)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
@@ -62,11 +61,13 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&capacityStr, result->capacity, 51, 21, false);
|
||||
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->capacity},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature},
|
||||
});
|
||||
|
||||
@@ -43,10 +43,9 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
});
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
@@ -66,8 +65,10 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&valueStr, item->value, 10, 10, false);
|
||||
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_FLOAT, &item->value},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &percentage}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result.theme, stdout);
|
||||
|
||||
if(result.size.length > 0)
|
||||
if(result.size.length > 0 && !ffStrbufEqualS(&result.size, "0"))
|
||||
printf(" (%spx)", result.size.chars);
|
||||
|
||||
putchar('\n');
|
||||
|
||||
+86
-33
@@ -79,12 +79,22 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
if(disk->filesystem.length)
|
||||
ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars);
|
||||
|
||||
if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)
|
||||
ffStrbufAppendS(&str, "[External]");
|
||||
else if(disk->type & FF_DISK_TYPE_SUBVOLUME_BIT)
|
||||
ffStrbufAppendS(&str, "[Subvolume]");
|
||||
else if(disk->type & FF_DISK_TYPE_HIDDEN_BIT)
|
||||
ffStrbufAppendS(&str, "[Hidden]");
|
||||
ffStrbufAppendC(&str, '[');
|
||||
if(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT)
|
||||
ffStrbufAppendS(&str, "External, ");
|
||||
if(disk->type & FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT)
|
||||
ffStrbufAppendS(&str, "Subvolume, ");
|
||||
if(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT)
|
||||
ffStrbufAppendS(&str, "Hidden, ");
|
||||
if(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT)
|
||||
ffStrbufAppendS(&str, "Read-only, ");
|
||||
if (str.chars[str.length - 1] == '[')
|
||||
ffStrbufSubstrBefore(&str, str.length - 1);
|
||||
else
|
||||
{
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
str.chars[str.length - 1] = ']';
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
@@ -92,21 +102,27 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t filesPercentage = disk->filesTotal > 0 ? (uint8_t) (((double) disk->filesUsed / (double) disk->filesTotal) * 100.0) : 0;
|
||||
FF_STRBUF_AUTO_DESTROY bytesPercentageStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&bytesPercentageStr, bytesPercentage, 50, 80, false);
|
||||
FF_STRBUF_AUTO_DESTROY filesPercentageStr = ffStrbufCreate();
|
||||
double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0;
|
||||
ffAppendPercentNum(&filesPercentageStr, filesPercentage, 50, 80, false);
|
||||
|
||||
bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT);
|
||||
bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT);
|
||||
bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
|
||||
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isExternal},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isHidden},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -152,7 +168,7 @@ static void printAutodetected(FFDiskOptions* options, const FFlist* disks)
|
||||
{
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
|
||||
{
|
||||
if(!(disk->type & options->showTypes))
|
||||
if(disk->type & ~options->showTypes)
|
||||
continue;
|
||||
|
||||
printDisk(options, disk);
|
||||
@@ -162,7 +178,7 @@ static void printAutodetected(FFDiskOptions* options, const FFlist* disks)
|
||||
void ffPrintDisk(FFDiskOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY disks = ffListCreate(sizeof (FFDisk));
|
||||
const char* error = ffDetectDisks(&disks);
|
||||
const char* error = ffDetectDisks(options, &disks);
|
||||
|
||||
if(error)
|
||||
{
|
||||
@@ -190,7 +206,8 @@ void ffInitDiskOptions(FFDiskOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
ffStrbufInit(&options->folders);
|
||||
options->showTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
options->calcType = FF_DISK_CALC_TYPE_FREE;
|
||||
}
|
||||
|
||||
bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value)
|
||||
@@ -209,45 +226,63 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch
|
||||
if (ffStrEqualsIgnCase(subKey, "show-regular"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_TYPE_REGULAR_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_REGULAR_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "show-external"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "show-hidden"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "show-subvolumes"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "show-readonly"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "show-unknown"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "use-available"))
|
||||
{
|
||||
if (ffOptionParseBoolean(value))
|
||||
options->calcType = FF_DISK_CALC_TYPE_AVAILABLE;
|
||||
else
|
||||
options->calcType = FF_DISK_CALC_TYPE_FREE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -281,36 +316,54 @@ void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module)
|
||||
if (ffStrEqualsIgnCase(key, "showExternal"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showHidden"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showSubvolumes"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showReadOnly"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showUnknown"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
options->showTypes |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
else
|
||||
options->showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
options->showTypes &= ~FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "useAvailable"))
|
||||
{
|
||||
if (yyjson_get_bool(val))
|
||||
options->calcType = FF_DISK_CALC_TYPE_AVAILABLE;
|
||||
else
|
||||
options->calcType = FF_DISK_CALC_TYPE_FREE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,22 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum FFDiskType
|
||||
typedef enum FFDiskVolumeType
|
||||
{
|
||||
FF_DISK_TYPE_NONE = 0,
|
||||
FF_DISK_TYPE_REGULAR_BIT = 1 << 0,
|
||||
FF_DISK_TYPE_HIDDEN_BIT = 1 << 1,
|
||||
FF_DISK_TYPE_EXTERNAL_BIT = 1 << 2,
|
||||
FF_DISK_TYPE_SUBVOLUME_BIT = 1 << 3,
|
||||
FF_DISK_TYPE_UNKNOWN_BIT = 1 << 4,
|
||||
} FFDiskType;
|
||||
FF_DISK_VOLUME_TYPE_NONE = 0,
|
||||
FF_DISK_VOLUME_TYPE_REGULAR_BIT = 1 << 0,
|
||||
FF_DISK_VOLUME_TYPE_HIDDEN_BIT = 1 << 1,
|
||||
FF_DISK_VOLUME_TYPE_EXTERNAL_BIT = 1 << 2,
|
||||
FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT = 1 << 3,
|
||||
FF_DISK_VOLUME_TYPE_UNKNOWN_BIT = 1 << 4,
|
||||
FF_DISK_VOLUME_TYPE_READONLY_BIT = 1 << 5,
|
||||
} FFDiskVolumeType;
|
||||
|
||||
typedef enum FFDiskCalcType
|
||||
{
|
||||
FF_DISK_CALC_TYPE_FREE,
|
||||
FF_DISK_CALC_TYPE_AVAILABLE,
|
||||
} FFDiskCalcType;
|
||||
|
||||
typedef struct FFDiskOptions
|
||||
{
|
||||
@@ -20,5 +27,6 @@ typedef struct FFDiskOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFstrbuf folders;
|
||||
FFDiskType showTypes;
|
||||
FFDiskVolumeType showTypes;
|
||||
FFDiskCalcType calcType;
|
||||
} FFDiskOptions;
|
||||
|
||||
@@ -12,7 +12,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
|
||||
if(dsResult->displays.length == 0)
|
||||
{
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Couldn't detect display");
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect display");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,12 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
ffStrbufInit(&result.vendor);
|
||||
ffStrbufInit(&result.slv);
|
||||
|
||||
const char* error = ffDetectOpenGL(&result);
|
||||
const char* error = ffDetectOpenGL(options, &result);
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
|
||||
@@ -63,10 +63,12 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPrintFormat(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ void ffPlatformInit(FFPlatform* platform)
|
||||
ffStrbufInit(&platform->cacheDir);
|
||||
ffListInit(&platform->configDirs, sizeof(FFstrbuf));
|
||||
ffListInit(&platform->dataDirs, sizeof(FFstrbuf));
|
||||
ffStrbufInit(&platform->exePath);
|
||||
|
||||
ffStrbufInit(&platform->userName);
|
||||
ffStrbufInit(&platform->hostName);
|
||||
|
||||
@@ -11,6 +11,7 @@ typedef struct FFPlatform {
|
||||
FFstrbuf cacheDir; // Trailing slash included
|
||||
FFlist configDirs; // List of FFstrbuf, trailing slash included
|
||||
FFlist dataDirs; // List of FFstrbuf, trailing slash included
|
||||
FFstrbuf exePath; // The real path of current exe
|
||||
|
||||
FFstrbuf userName;
|
||||
FFstrbuf hostName;
|
||||
|
||||
@@ -5,8 +5,36 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <limits.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <libproc.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
static void getExePath(FFPlatform* platform)
|
||||
{
|
||||
FFstrbuf* const exePath = &platform->exePath;
|
||||
ffStrbufEnsureFree(exePath, PATH_MAX);
|
||||
#ifdef __linux__
|
||||
ssize_t exePathLen = readlink("/proc/self/exe", exePath->chars, exePath->allocated);
|
||||
#elif defined(__APPLE__)
|
||||
int exePathLen = proc_pidpath((int) getpid(), exePath->chars, exePath->allocated);
|
||||
#elif defined(__FreeBSD__)
|
||||
size_t exePathLen = exePath->allocated;
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int) getpid()}, 4,
|
||||
exePath->chars, &exePathLen,
|
||||
NULL, 0
|
||||
))
|
||||
exePathLen = 0;
|
||||
#endif
|
||||
if (exePathLen > 0)
|
||||
exePath->length = (uint32_t) exePathLen;
|
||||
}
|
||||
|
||||
static void platformPathAddEnv(FFlist* dirs, const char* env)
|
||||
{
|
||||
const char* envValue = getenv(env);
|
||||
@@ -82,7 +110,17 @@ static void getDataDirs(FFPlatform* platform)
|
||||
platformPathAddEnv(&platform->dataDirs, "XDG_DATA_HOME");
|
||||
ffPlatformPathAddHome(&platform->dataDirs, platform, ".local/share/");
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// Add ${currentExePath}/../share
|
||||
if (platform->exePath.length > 0)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath);
|
||||
ffStrbufSubstrBeforeLastC(&path, '/');
|
||||
ffStrbufSubstrBeforeLastC(&path, '/');
|
||||
ffStrbufAppendS(&path, "/share");
|
||||
ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
ffPlatformPathAddHome(&platform->dataDirs, platform, "Library/Application Support/");
|
||||
#endif
|
||||
|
||||
@@ -152,6 +190,7 @@ void ffPlatformInitImpl(FFPlatform* platform)
|
||||
if(uname(&uts) != 0)
|
||||
memset(&uts, 0, sizeof(uts));
|
||||
|
||||
getExePath(platform);
|
||||
getHomeDir(platform, pwd);
|
||||
getCacheDir(platform);
|
||||
getConfigDirs(platform);
|
||||
|
||||
@@ -6,6 +6,18 @@
|
||||
#include <Windows.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
static void getExePath(FFPlatform* platform)
|
||||
{
|
||||
wchar_t exePathW[MAX_PATH];
|
||||
DWORD exePathWLen = GetModuleFileNameW(NULL, exePathW, MAX_PATH);
|
||||
if (exePathWLen == 0 && exePathWLen >= MAX_PATH) return;
|
||||
|
||||
ffStrbufSetNWS(&platform->exePath, exePathWLen, exePathW);
|
||||
if (ffStrbufStartsWithS(&platform->exePath, "\\\\?\\"))
|
||||
ffStrbufSubstrAfter(&platform->exePath, 3);
|
||||
ffStrbufReplaceAllC(&platform->exePath, '\\', '/');
|
||||
}
|
||||
|
||||
static void getHomeDir(FFPlatform* platform)
|
||||
{
|
||||
PWSTR pPath;
|
||||
@@ -213,6 +225,7 @@ static void getSystemArchitecture(FFPlatform* platform)
|
||||
|
||||
void ffPlatformInitImpl(FFPlatform* platform)
|
||||
{
|
||||
getExePath(platform);
|
||||
getHomeDir(platform);
|
||||
getCacheDir(platform);
|
||||
getConfigDirs(platform);
|
||||
|
||||
+109
-103
@@ -14,6 +14,7 @@ extern "C" {
|
||||
#include <utility>
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
enum class FFWmiNamespace {
|
||||
CIMV2,
|
||||
@@ -36,115 +37,120 @@ struct FFWmiVariant: VARIANT {
|
||||
return this->hasValue();
|
||||
}
|
||||
|
||||
template <typename T> T get();
|
||||
template <typename T> T get()
|
||||
{
|
||||
// boolean
|
||||
if constexpr (std::is_same_v<T, bool>) {
|
||||
assert(this->vt == VT_BOOL);
|
||||
return this->boolVal != VARIANT_FALSE;
|
||||
}
|
||||
|
||||
// boolean
|
||||
template <> bool get<bool>() {
|
||||
assert(this->vt == VT_BOOL);
|
||||
return this->boolVal != VARIANT_FALSE;
|
||||
}
|
||||
// signed
|
||||
else if constexpr (std::is_same_v<T, int8_t>) {
|
||||
assert(this->vt == VT_I1);
|
||||
return this->cVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, int16_t>) {
|
||||
assert(vt == VT_I2);
|
||||
return this->iVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, int32_t>) {
|
||||
assert(this->vt == VT_I4 || vt == VT_INT);
|
||||
return this->intVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, int64_t>) {
|
||||
assert(this->vt == VT_I8);
|
||||
return this->llVal;
|
||||
}
|
||||
|
||||
// signed
|
||||
template <> int8_t get() {
|
||||
assert(this->vt == VT_I1);
|
||||
return this->cVal;
|
||||
}
|
||||
template <> int16_t get() {
|
||||
assert(vt == VT_I2);
|
||||
return this->iVal;
|
||||
}
|
||||
template <> int32_t get() {
|
||||
assert(this->vt == VT_I4 || vt == VT_INT);
|
||||
return this->intVal;
|
||||
}
|
||||
template <> int64_t get() {
|
||||
assert(this->vt == VT_I8);
|
||||
return this->llVal;
|
||||
}
|
||||
// unsigned
|
||||
else if constexpr (std::is_same_v<T, uint8_t>) {
|
||||
assert(this->vt == VT_UI1);
|
||||
return this->bVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, uint16_t>) {
|
||||
assert(this->vt == VT_UI2);
|
||||
return this->uiVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, uint32_t>) {
|
||||
assert(this->vt == VT_UI4 || vt == VT_UINT);
|
||||
return this->uintVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, uint64_t>) {
|
||||
assert(this->vt == VT_UI8);
|
||||
return this->ullVal;
|
||||
}
|
||||
|
||||
// unsigned
|
||||
template <> uint8_t get() {
|
||||
assert(this->vt == VT_UI1);
|
||||
return this->bVal;
|
||||
}
|
||||
template <> uint16_t get() {
|
||||
assert(this->vt == VT_UI2);
|
||||
return this->uiVal;
|
||||
}
|
||||
template <> uint32_t get() {
|
||||
assert(this->vt == VT_UI4 || vt == VT_UINT);
|
||||
return this->uintVal;
|
||||
}
|
||||
template <> uint64_t get() {
|
||||
assert(this->vt == VT_UI8);
|
||||
return this->ullVal;
|
||||
}
|
||||
// decimal
|
||||
else if constexpr (std::is_same_v<T, float>) {
|
||||
assert(this->vt == VT_R4);
|
||||
return this->fltVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, double>) {
|
||||
assert(this->vt == VT_R8);
|
||||
return this->dblVal;
|
||||
}
|
||||
|
||||
// decimal
|
||||
template <> float get() {
|
||||
assert(this->vt == VT_R4);
|
||||
return this->fltVal;
|
||||
}
|
||||
template <> double get() {
|
||||
assert(this->vt == VT_R8);
|
||||
return this->dblVal;
|
||||
}
|
||||
// string
|
||||
else if constexpr (std::is_same_v<T, std::string_view>) {
|
||||
assert(this->vt == VT_LPSTR);
|
||||
return this->pcVal;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::wstring_view>) {
|
||||
assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR);
|
||||
if (this->vt == VT_LPWSTR)
|
||||
return this->bstrVal;
|
||||
else
|
||||
return { this->bstrVal, SysStringLen(this->bstrVal) };
|
||||
}
|
||||
|
||||
// string
|
||||
template <> std::string_view get() {
|
||||
assert(this->vt == VT_LPSTR);
|
||||
return this->pcVal;
|
||||
}
|
||||
template <> std::wstring_view get() {
|
||||
assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR);
|
||||
if (this->vt == VT_LPWSTR)
|
||||
return this->bstrVal;
|
||||
else
|
||||
return { this->bstrVal, SysStringLen(this->bstrVal) };
|
||||
}
|
||||
// array signed
|
||||
else if constexpr (std::is_same_v<T, std::pair<const int8_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I1);
|
||||
return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const int16_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I2);
|
||||
return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const int32_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I4);
|
||||
return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const int64_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I8);
|
||||
return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
|
||||
// array signed
|
||||
template <> std::pair<const int8_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I1);
|
||||
return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const int16_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I2);
|
||||
return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const int32_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I4);
|
||||
return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const int64_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_I8);
|
||||
return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
|
||||
// array unsigned
|
||||
template <> std::pair<const uint8_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI1);
|
||||
return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const uint16_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI2);
|
||||
return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const uint32_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI4);
|
||||
return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
template <> std::pair<const uint64_t*, uint32_t> get() {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI8);
|
||||
return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims);
|
||||
// array unsigned
|
||||
else if constexpr (std::is_same_v<T, std::pair<const uint8_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI1);
|
||||
return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const uint16_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI2);
|
||||
return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const uint32_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI4);
|
||||
return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::pair<const uint64_t*, uint32_t>>) {
|
||||
assert(this->vt & VT_ARRAY);
|
||||
assert((this->vt & ~VT_ARRAY) == VT_UI8);
|
||||
return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims);
|
||||
}
|
||||
else {
|
||||
assert(false && "unsupported type");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user