This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
tg-fuse is a FUSE-based virtual filesystem that enables sending files to Telegram contacts using standard Unix file operations. Users can cp files to virtual directories representing Telegram contacts (e.g., /mnt/tg/@username).
This project uses CMake with FetchContent for dependency management. Only system-level dependencies (FUSE libraries) need manual installation.
A Makefile is provided for convenience with common build targets.
Using the Makefile (recommended):
make build-debug # Build debug version in build/debug
make build-release # Build release version in build/release
make clean-all # Clean all build directories
make format # Format all source files with clang-formatUsing CMake directly:
mkdir build && cd build
cmake ..
make -j$(nproc) # Linux
make -j$(sysctl -n hw.ncpu) # macOScd build/release
sudo make install# Configure API credentials (one-time, get from https://my.telegram.org/apps)
tg-fuse config set --api-id=YOUR_API_ID --api-hash=YOUR_API_HASH
# Authenticate
tg-fuse login
# Mount filesystem
tg-fuse mount /mnt/tg # Linux
tg-fuse mount /Volumes/tg # macOS- Linux: libfuse3-dev, cmake, C++20 compiler
- macOS: macFUSE, cmake, C++20 compiler (Xcode command line tools)
- TDLib - Official Telegram client library
- nlohmann/json - JSON parsing
- spdlog - Logging framework
- CLI11 - Command line argument parsing
The codebase uses conditional compilation for FUSE headers:
#ifdef __APPLE__
#include <osxfuse/fuse.h>
#else
#include <fuse3/fuse.h>
#endif- Linux:
/mnt/tg(default) - macOS:
/Volumes/tg(default)
The project builds two executables:
tg-fuse- CLI companion app with subcommands (mount, login, etc.)tg-fused- FUSE daemon that runs the filesystem
Flow: tg-fuse mount /path → exec() into tg-fused → daemonise → FUSE loop
/mount_point/
├── users/
│ └── <username>/
│ └── .info # User information (read-only)
├── groups/
│ └── <groupname>/
│ └── .info # Group information
├── channels/
│ └── <channelname>/
│ └── .info # Channel information
├── @alice -> users/alice # Symlinks for quick access
└── ...
src/ctl/- CLI companion appsrc/fused/- FUSE daemonsrc/fuse/- FUSE library (operations, platform abstraction, VFS)src/tg/- Telegram wrapper libraryinclude/fuse/- FUSE library headersinclude/tg/- Telegram library headers
Cross-platform FUSE support is abstracted behind C++ interfaces in include/fuse/platform.hpp:
FuseOperations- Abstract interface for filesystem operationsPlatformAdapter- Bridges platform-specific FUSE callbacks to the abstract interface
Uses C++20 features with TDLib's asynchronous API and C++ coroutines for handling Telegram operations.
Since all dependencies are fetched automatically via CMake, the development process is:
- Clone repository
- Install only system FUSE libraries
- Run CMake (fetches all third-party dependencies)
- Build and develop
# From debug build
cd build/debug && ctest
# From release build
cd build/release && ctestIMPORTANT: Always run clang-format on modified files before committing.
# Format all source files (recommended)
make format
# Or format manually
clang-format -i src/main.cppThe project uses a .clang-format configuration based on Google style with 120 column limit and 4-space indentation.