Plugin File Open Here

# Fallback to native open return native_open(filepath) # plugin.py from hostapi import FileOpenHandler class CustomHandler(FileOpenHandler): def can_handle(self, path): return path.endswith('.encrypted')

bool is_safe_path(const char* requested, const char* allowed_root) char real_req[PATH_MAX], real_root[PATH_MAX]; if (!realpath(requested, real_req)) return false; if (!realpath(allowed_root, real_root)) return false; return strncmp(real_req, real_root, strlen(real_root)) == 0; plugin file open

// Called after host opens file void (*on_after_file_open)(const char* path, void* context, int host_result); # Fallback to native open return native_open(filepath) #

// Called instead of host opening (if plugin handles fully) int (*on_open_file)(const char* path, void* context, char** output_data, size_t* output_size); const char* allowed_root) char real_req[PATH_MAX]

Define standard return codes:

// Cleanup void (*on_close)(void* context); FileOpenPluginAPI; "id": "com.example.custom-opener", "version": "1.0.0", "hooks": "file-open": "extensions": [".xyz", ".custom"], "priority": 10, "async": true, "handler": "handlers/file_open.js"