Last active
November 13, 2023 05:58
-
-
Save fellowgeek/3628f2b3a74dce8d0ea265e8ed492bfb to your computer and use it in GitHub Desktop.
PHP server for retouch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define the base URL | |
define('__BASE_URL__', 'http://192.168.0.100/retroarch/'); | |
// Initialize a counter and create an object to hold the data | |
$count = 0; | |
$data = new stdClass(); | |
$data->files = []; | |
// Scan ROMs directory for files | |
$scannedFiles = glob('ROMs/*/*'); | |
foreach ($scannedFiles as $scannedFile) { | |
// Increment the counter | |
$count++; | |
// Get information about the file | |
$pathinfo_dir = pathinfo($scannedFile, PATHINFO_DIRNAME); | |
$pathinfo_name = pathinfo($scannedFile, PATHINFO_BASENAME); | |
$pathinfo_ext = pathinfo($scannedFile, PATHINFO_EXTENSION); | |
// Create an object for each file and populate it with relevant information | |
$filesObject = new stdClass(); | |
$filesObject->download_url = __BASE_URL__ . $scannedFile; | |
$filesObject->remote_path = '/' . $pathinfo_dir; | |
$data->files[] = $filesObject; | |
} | |
// Scan BIOS directory for files | |
$scannedFiles = glob('BIOS/*'); | |
foreach ($scannedFiles as $scannedFile) { | |
// Get information about the file | |
$pathinfo_dir = pathinfo($scannedFile, PATHINFO_DIRNAME); | |
$pathinfo_name = pathinfo($scannedFile, PATHINFO_BASENAME); | |
$pathinfo_ext = pathinfo($scannedFile, PATHINFO_EXTENSION); | |
// Create an object for each file in the BIOS directory and populate it with relevant information | |
$filesObject = new stdClass(); | |
$filesObject->download_url = __BASE_URL__ . $scannedFile; | |
$filesObject->remote_path = '/' . 'RetroArch/system/'; | |
$data->files[] = $filesObject; | |
} | |
// Set the response header to indicate JSON content type | |
header('Content-Type: application/json; charset=utf-8'); | |
// Print the JSON-encoded data with pretty formatting | |
print(json_encode($data, JSON_PRETTY_PRINT)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment