humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_random_file_content
get_random_file_content($folder,$ext,$include_subfolders,$timeout=60); - данная функция используется для получения содержимого случайного файла в заданной папкеФункция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Demonstrates getting content of random files from a directory $xhe_host = "localhost:7010"; // Connect functional objects if not already connected if (!isset($path)){ $path = "../../../Templates/init.php"; require($path); } // info echo "\n<span >file_os->" . basename (__FILE__) . "</span>\n"; // Example 1: Get content of random txt or php file from test folder echo "\n\n1. Get content of random txt or php file from test folder: "; $folderPath = "test"; $fileExtensions = "txt;php"; $searchSubfolders = false; $timeout = 60; $filePath = SYSTEM::$file_os->get_random_file_content($folderPath, $fileExtensions, $searchSubfolders, $timeout); if ($filePath != "") { echo "Random file path: " . $filePath . "\n"; } else { echo "No files of specified types in the folder\n"; } // Example 2: Get content of random txt file from test folder and its subfolders echo "\n2. Get content of random txt file from test folder and its subfolders: "; $folderPath = "test"; $fileExtensions = "txt"; $searchSubfolders = true; $timeout = 60; $filePath = SYSTEM::$file_os->get_random_file_content($folderPath, $fileExtensions, $searchSubfolders, $timeout); if ($filePath != "") { echo "Random file path: " . $filePath . "\n"; } else { echo "No files of specified types in the folder and its subfolders\n"; } // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>file_os.xxxxxxxxx</font><hr>") # 1 echo("1. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder: <br>") file_path = file_os.get_random_file_content("test","txt;php",false, 60) if file_path != "": echo(file_path,"<br>") else: echo("нет файлов таких типов в каталоге<br>") # 2 echo("2. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder и его подкаталогах: <br>") file_path = file_os.get_random_file_content("test","txt;php",true,60) if file_path != "": echo(file_path,"<br>") else: echo("нет файлов таких типов в каталоге и его подкаталогах") # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>file_os.get_random_file_content</font><hr>"); // 1 шаг echo("1. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder : "); echo (file_os.get_random_file_content("test","txt;php",false, 60)+"<br>"); // 2 шаг echo("2. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder и его подкаталогах : "); echo (file_os.get_random_file_content("test","txt;php",true,60)); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>file_os.get_random_file_content</font><hr>"); // 1 шаг echo("1. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder: <br>"); file_path = file_os.get_random_file_content("test","txt;php",false, 60); if(file_path != "") echo(file_path+"<br>"); else echo("нет файлов таких типов в каталоге<br>"); // 2 шаг echo("2. Получить содержимое случайного файла типа txt или php, из каталога: TestFolder и его подкаталогах: <br>"); file_path = file_os.get_random_file_content("test","txt;php",true,60); if(file_path != "") echo(file_path+"<br>"); else echo("нет файлов таких типов в каталоге и его подкаталогах"); // конец echo("\n"); // Quit app.quit();
=============================================
File_os Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.