# Janu VFS (Virtual File System)

A plug-and-play Python library that treats Google Drive like a local Linux hard drive. Built as the core storage engine for JanuOS, this library provides an ultra-fast, robust, and automated way to manage cloud files seamlessly.

## ✨ Features
* **Auto-Authentication:** Automatically opens a secure browser login and handles `token.json` generation if credentials are missing.
* **Smart Path Resolver:** Translates standard Linux paths (like `/Desktop/MyFolder/file.txt`) into Google Drive IDs, instantly creating any missing parent folders.
* **Redundancy Shield:** Built-in exponential backoff automatically retries uploads if there are network drops or Google Rate Limits (403 errors).
* **Duplicate Prevention:** Intelligently updates existing files instead of creating confusing duplicates.

## 🚀 Installation

```bash
pip install janu_vfs


🛠️ Setup

    Go to your Google Cloud Console.

    Enable the Google Drive API.

    Create an OAuth client ID (Desktop App) and download the JSON file.

    Rename the downloaded file to credentials.json and place it in the same directory as your Python script.

💻 Usage

Here is a complete test script demonstrating all the core features:
Python

import os
from janu_vfs import JanuDrive

# 1. Connect to the Drive! (Auto-authenticates and loads the Smart Cache)
drive = JanuDrive(master_id="YOUR_FOLDER_ID_HERE")

# 2. Create Folders and Files instantly
drive.create_folder("/JanuOS_Tests/My_First_Folder")
drive.create_file("/JanuOS_Tests/My_First_Folder/empty_config.json")

# 3. Upload Raw Text Directly (No local file needed)
drive.upload_text("/JanuOS_Tests/My_First_Folder/direct_notes.txt", "Shanimma and Julie built this entire OS framework!")

# 4. Upload a Real Physical File
with open("dummy_local_file.txt", "w") as f:
    f.write("This is a real local file being pushed to the cloud!")
drive.upload(local_file_path="dummy_local_file.txt", cloud_path="/JanuOS_Tests/uploaded_dummy.txt")

# 5. List Directory Contents
contents = drive.list_dir("/JanuOS_Tests/My_First_Folder")
print("Contents:")
for item in contents:
    print(f"  -> {item['name']} (Type: {item['type']})")

# 6. Retrieve (Download) a File
drive.retrieve(cloud_path="/JanuOS_Tests/uploaded_dummy.txt", local_save_directory="./Downloads_Test")

# 7. Rename and Delete
drive.rename(cloud_path="/JanuOS_Tests/uploaded_dummy.txt", new_name="renamed_dummy.txt")
drive.delete(cloud_path="/JanuOS_Tests/My_First_Folder/empty_config.json")

# 8. Clean the Smart Cache
drive.clean_cache()

🖥️ Expected Output

When you run the script, the janu_vfs engine will handle all the complex API tunneling and print this clean log:
Plaintext

[Janu VFS] Successfully connected to Master Drive!

--- TEST 1: Creating a Folder ---
[Janu VFS] Folder ensured: /JanuOS_Tests/My_First_Folder

--- TEST 2: Creating an Empty File ---
[Janu VFS] Uploaded text to /JanuOS_Tests/My_First_Folder/empty_config.json

--- TEST 3: Uploading Raw Text Directly ---
[Janu VFS] Uploaded text to /JanuOS_Tests/My_First_Folder/direct_notes.txt

--- TEST 4: Uploading a Real File ---
[Janu VFS] Uploaded new file: /JanuOS_Tests/uploaded_dummy.txt

--- TEST 5: Listing Directory Contents ---
Contents of /JanuOS_Tests/My_First_Folder:
  -> empty_config.json (Type: file)
  -> direct_notes.txt (Type: file)

--- TEST 6: Retrieving (Downloading) a File ---
[Janu VFS] Downloaded to: ./Downloads_Test/uploaded_dummy.txt

--- TEST 7: Renaming a File ---
[Janu VFS] Renamed to renamed_dummy.txt

--- TEST 8: Deleting a File ---
[Janu VFS] Deleted /JanuOS_Tests/My_First_Folder/empty_config.json
[Janu VFS] Smart cache wiped clean.

--- TEST 9: Cleaning the Smart Cache ---
[Janu VFS] Smart cache wiped clean.

✅ All 9 tests complete, Janu! The Janu VFS Framework is bulletproof!
