Technical Documentation: TeamAmaze/AmazeFileManager
βΉοΈ Provenance: Multi-Tier Ingestion Β· CodeWiki Reference
Overview (`README.md`)
[Amaze File Manager](https://teamamaze.xyz)
Simple and attractive Material Design file manager for Android
Overview
- Open Source, light and smooth
- Based on Material Design guidelines
- Basic features like cut, copy, delete, compress, extract etc. easily accessible
- Work on multiple tabs at same time
- Multiple themes with cool icons
- Navigation drawer for quick navigation
- App Manager to open, backup, or directly uninstall any app
- Quickly access history, access bookmarks or search for any file
- Root explorer for advanced users
- AES Encryption and Decryption of files for security (Jellybean v4.3+)
- Cloud services support (Jellybean v4.3+ / requires additional plug-in)
- Inbuilt Database Reader, Zip/Rar Reader, Apk Reader, Text Reader
- No ads or In-app purchases
- lots more...
Downloads
Contribute
You can contribute via one of the following ways:
- Help us with the translations of either Amaze File Manager or Amaze Utilities
- Contribute directly to the code, help us in fixing the bugs / implement new features.
If we feel your contribution is a significant help to us, we'll award you a bounty with any of your preferred mode of payment.
Support
Or buy the Cloud Plugin supports Google Driveβ’, Dropbox, OneDrive and Box accounts.
Try our app - Amaze File Utilities (Fdroid)
- List videos / images / music documents in your device in a interactive UI where you're able to group / sort and quickly jump to any headers.
- Open videos / images / music / documents (pdf / docx / epub) with inbuilt player.
- Share / delete / cast on your tv
- Analyse internal storage for junk files, duplicate files, large videos / old downloads / screenshots or recordings.
- Analyse and group images between memes, low light / blurry / selfies / group pics.
- Transfer files directly between two mobile devices on same wifi network using high speed peer to peer network
- Gesture support in image / video player, play in background, picture in picture mode, download subtitles within the player.
Warning
Basic r/w operations might not work on external memory on Kitkat devices. Don't use cut/paste from or to external SD Card. You might lose your files.
Under the license we are not responsible for damages.
See our Privacy Policy
Vendors/Developers
The device vendors/ROM developers are free to include Amaze apk pre-installed in system. There is no fee required; but you must comply with the license (for more information read the GNU GPL v3 or newer).
We strongly recommend using apk signed by us (either Play Store version or from AFH link above) so that users would be able to update directly from Play Store after distribution. Furthermore, a change in digital signature will break plug-ins.
License:
Copyright (C) 2014-2018 Arpit Khurana <[email protected]>
Copyright (C) 2014-2024 Vishal Nehra <[email protected]>
Copyright (C) 2017-2024 Emmanuel Messulam
Copyright (C) 2018-2024 Raymond Lai <airwave209gt at gmail.com>
Copyright (C) 2019-2024 Vishnu Sanal T <t.v.s10123 at gmail.com>
This file is part of Amaze File Manager.
Amaze File Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.Overview (`file_operations/src/main/rust/README.md`)
Rust File Operations Module
This directory contains the Rust implementation of file operations for the Amaze File Manager, which
was migrated from C/C++ to Rust for more modern, maintainable more safe code, with Rust's inherent
type-safety and memory-safety features.
Please refer to RUST_MIGRATION.md for detailed information
about the migration process, key changes, and advantages of using Rust.
Module Structure
The code is organized into separate modules for better maintainability and extensibility:
`lib.rs` - Main Library File
- Purpose: Organizes and re-exports functionality from various modules
- Content: Module declarations and re-exports for easy access
- Note: This is the entry point for the Rust library
`rootoperations.rs` - Root Operations
- Purpose: Contains root-specific file operations (migrated from C++)
- Functions:
Java_com_amaze_filemanager_fileoperations_filesystem_root_NativeOperations_isDirectory- JNI function for directory checkingcheck_is_directory- Helper function to check if a path is a directorycheck_path_exists- Helper function to check if a path existscheck_is_file- Helper function to check if a path is a fileget_file_size- Helper function to get file size
Usage
From Kotlin/Java
The JNI functions are automatically exported and can be called from Kotlin:
// In NativeOperations.kt
@JvmStatic
external fun isDirectory(path: String?): Boolean
// Usage
val isDir = NativeOperations.isDirectory("/some/path")From Rust (Internal)
Functions can be called directly within the Rust codebase:
use crate::rootoperations::check_is_directory;
let is_dir = check_is_directory("/some/path")?;Through Re-exports
Functions can be accessed through the main library:
use crate::check_is_directory;
let is_dir = check_is_directory("/some/path")?;Adding New Functionality
1. Create a New Module
Create a new .rs file (e.g., network_ops.rs):
// network_ops.rs
pub fn download_file(url: &str, destination: &str) -> Result<(), Box<dyn std::error::Error>> {
// Implementation
Ok(())
}2. Add Module Declaration
In lib.rs, add the module declaration:
pub mod network_ops;3. Re-export Functions (Optional)
In lib.rs, add re-exports for easy access:
pub use network_ops::{
download_file,
upload_file,
};4. Add JNI Functions (If Needed)
If you need to call the function from Kotlin:
// In network_ops.rs
#[no_mangle]
pub extern "system" fn Java_com_amaze_filemanager_fileoperations_filesystem_root_NativeOperations_downloadFile(
env: JNIEnv,
_class: JClass,
url: JString,
destination: JString,
) -> jboolean {
// Convert JString to Rust String
let url_str: String = env.get_string(url).unwrap().into();
let dest_str: String = env.get_string(destination).unwrap().into();
// Call the actual function
match download_file(&url_str, &dest_str) {
Ok(_) => 1, // true
Err(_) => 0, // false
}
}Then add the corresponding method in NativeOperations.kt:
@JvmStatic
external fun downloadFile(url: String?, destination: String?): BooleanTesting
Each module includes its own tests. Run tests with:
cd file_operations
cargo testTo test a specific module:
cargo test rootoperations::testsBest Practices
- Separation of Concerns: Keep related functions in the same module
- Error Handling: Use
Result<T, E>for functions that can fail - Documentation: Add doc comments to all public functions
- Testing: Include unit tests for all functions
- JNI Safety: Always handle JNI string conversion errors
- Logging: Use the
logcrate for debugging information
Example: Complete Function Implementation
/* Detailed source-code truncated for AI context efficiency. */This structure makes the codebase highly maintainable and easy to extend with new functionality while keeping everything organized and well-tested.
File Operations Doc RUST MIGRATION (`file_operations/doc/RUST_MIGRATION.md`)
C++ to Rust Migration Guide
This document outlines the migration from C++ to Rust in the file_operations module using Mozilla's Rust Android Gradle plugin.
Overview
The migration replaces the C++ implementation in src/main/c/rootoperations.c with a Rust implementation while maintaining the same JNI interface for seamless integration with the existing Kotlin code.
What Was Migrated
Original C++ Code
- File:
src/main/c/rootoperations.c - Function:
Java_com_amaze_filemanager_fileoperations_filesystem_root_NativeOperations_isDirectory - Purpose: Checks if a given path is a directory using the
stat()system call - Build System: CMake
New Rust Code
- File:
src/lib.rs - Function: Same JNI function signature
- Purpose: Identical functionality using Rust's
std::fs::metadata() - Build System: Cargo with Mozilla's Rust Android Gradle plugin
Prerequisites
- Rust Installation: Install Rust from https://rustup.rs/
- Android NDK: Install via Android Studio β Tools β SDK Manager β SDK Tools β NDK
- Environment Variables: Set
ANDROID_HOMEorANDROID_NDK_ROOT - Rust-compatible IDE: Before Android Studio gets first-class Rust support, consider using Visual Studio Code with Rust extensions for coding.
Setup Instructions
1. Automated Setup (Recommended)
The project includes an automated setup script that detects your system configuration and generates the correct configuration files:
cd file_operations
./setup_rust_android.shThis script will:
- Auto-detect your operating system (macOS, Linux, Windows)
- Find your Android SDK path (from
ANDROID_HOME,ANDROID_SDK_ROOT, or common locations) - Detect the latest NDK version installed
- Extract API level from your
build.gradle - Install necessary Rust targets for Android
- Generate
.cargo/config.tomlwith correct linker paths
2. Manual Setup (If Needed)
If the automated setup doesn't work, you can manually configure:
Install Android Rust targets:
bashrustup target add aarch64-linux-android rustup target add armv7-linux-androideabi rustup target add i686-linux-android rustup target add x86_64-linux-androidCreate
.cargo/config.tomlbased on your system:- Copy
.cargo/config.toml.templateto.cargo/config.toml - Replace placeholders with your actual paths:
{{NDK_PATH}}: Path to your NDK toolchain binaries{{API_LEVEL}}: Your minimum API level (e.g., 21){{EXE_SUFFIX}}:.exefor Windows, empty for Unix systems
- Copy
3. System Requirements
Android SDK/NDK:
- Android SDK installed (via Android Studio or command-line tools)
- NDK installed (via SDK Manager)
- Set
ANDROID_HOMEenvironment variable
Supported Platforms:
- macOS (
darwin-x86_64) - Linux (
linux-x86_64) - Windows (
windows-x86_64)
4. Build Configuration
The build.gradle file now includes:
- Mozilla's Rust Android Gradle plugin
- Cargo configuration for cross-compilation
- Automatic building of Rust code during Android build
File Structure
file_operations/
βββ src/
β βββ main/
β βββ rust/
β βββ lib.rs # Main library file (module organizer)
β βββ rootoperations.rs # Root operations functions
βββ .cargo/
β βββ config.toml # Auto-generated Cargo configuration for Android
β βββ config.toml.template # Template for generating config.toml
βββ Cargo.toml # Rust project configuration
βββ setup_rust_android.sh # Automated setup script
βββ build.gradle # Updated with Rust plugin
βββ RUST_MIGRATION.md # This fileKey Changes
1. Build System
- Before: CMake with
externalNativeBuild - After: Cargo with Mozilla's Rust Android Gradle plugin
2. Dependencies
- Added:
jni,libc,android_logger,logcrates - Removed: CMake build configuration
3. Function Implementation
- Before: C function using
stat()system call - After: Rust function using
std::fs::metadata()
4. Error Handling
- Before: errno-based error handling
- After: Rust's
Resulttype with proper error handling
5. Modular Structure
- Before: Single C file with all functions
- After: Organized module structure:
lib.rs: Main library file that organizes and re-exports modulesrootoperations.rs: Root-specific operations (migrated from C)
Testing
The Rust implementation includes unit tests:
cd file_operations
cargo testBuilding
The Rust code is automatically built when you build the Android project:
./gradlew :file_operations:buildAdvantages of the Migration
- Memory Safety: Rust prevents memory leaks and buffer overflows
- Better Error Handling: Rust's type system catches errors at compile time
- Cross-Platform: Easier to port to other platforms
- Modern Tooling: Cargo package manager and ecosystem
- Performance: Comparable performance to C++ with better safety
Troubleshooting
Configuration Issues
First, try re-running the automated setup script:
cd file_operations
./setup_rust_android.shThis will re-detect your system configuration and regenerate .cargo/config.toml.
NDK Path Issues
If the automated setup fails to find your NDK, ensure your Android SDK is properly configured:
export ANDROID_HOME=/path/to/android/sdk
# The script will automatically find the NDK in $ANDROID_HOME/ndk/[version]Linker Not Found
If you see linker errors, verify your NDK installation:
- Check that NDK is installed via Android Studio β SDK Manager β SDK Tools β NDK
- The setup script will automatically use the latest NDK version found
- If needed, manually verify the generated
.cargo/config.tomlpaths exist
Build Errors
Clean and rebuild:
cd file_operations
cargo clean
cd ..
./gradlew clean
./gradlew :file_operations:buildCross-Platform Issues
The setup script supports:
- macOS: Automatically detects
darwin-x86_64platform - Linux: Automatically detects
linux-x86_64platform - Windows: Automatically detects
windows-x86_64platform and adds.exesuffix
If you encounter platform-specific issues, check the generated linker paths in .cargo/config.toml.
Extending the Codebase
The modular structure makes it easy to add new functionality:
Adding a New Module
- Create a new
.rsfile insrc/main/rust/(e.g.,network_ops.rs) - Add the module declaration in
lib.rs:rustpub mod network_ops; - Re-export functions in
lib.rsfor easy access:rustpub use network_ops::{ download_file, upload_file, };
Adding JNI Functions
To add new JNI functions that can be called from Kotlin:
Add the function in the appropriate module:
rust#[no_mangle] pub extern "system" fn Java_com_amaze_filemanager_fileoperations_filesystem_root_NativeOperations_newFunction( env: JNIEnv, _class: JClass, param: JString, ) -> jboolean { // Implementation }Add the corresponding method in
NativeOperations.kt:kotlin@JvmStatic external fun newFunction(param: String?): Boolean
Example: Adding Compression Operations
// In src/main/rust/compression_ops.rs
pub mod compression_ops {
use jni::objects::{JClass, JString};
use jni::JNIEnv;
use jni::sys::jboolean;
#[no_mangle]
pub extern "system" fn Java_com_amaze_filemanager_fileoperations_filesystem_root_NativeOperations_compressFile(
env: JNIEnv,
_class: JClass,
source: JString,
destination: JString,
) -> jboolean {
// Implementation
}
}Future Enhancements
- Add More Functions: Migrate additional C++ functions to Rust
- Async Operations: Use Rust's async/await for non-blocking operations
- Better Logging: Enhanced logging with structured logs
- Performance Monitoring: Add metrics collection
- Cross-Platform Support: Extend to other platforms (iOS, Windows, etc.)
- Error Types: Create custom error types for better error handling
- Benchmarking: Add performance benchmarks for critical operations
Resources
Support
For questions or issues with the migration, please refer to:
--- METRICS ---
- Files Extracted: 3
- Estimated Token Budget: ~4947 tokens
- Canonical Reference: https://codewiki.google/github.com/TeamAmaze/AmazeFileManager