// This is a script for Directory Opus. // See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information. // Opus Events ------------------------------------------------------ function OnInit(initData) { //uid added via script wizard (do not change after publishing this script) var uid = "5E04DF9B-E33B-4093-B0EB-594432CF7645"; //thread url added via script wizard (required for updating) var url = "http://resource.dopus.com/viewtopic.php?f=35&t=26541"; initData.name = "Steam *.acf app name column"; initData.desc = "Shows to which Steam app/game does each appmanifest_*.acf belong to."; initData.copyright = "by jsys in 2016"; initData.version = "0.9.0"; initData.default_enable = true; initData.min_version = "11.5.2"; // Column var col = initData.AddColumn(); col.name = "Steam app name"; col.label = "Steam app name"; col.method = "onListItem"; col.justify = "left"; col.multicol = false; } function onListItem(scriptColData) { if (stringEndsWith(scriptColData.item.name, ".acf")) { var game_name = readAcfGameName(scriptColData.item); game_name = stringAfter(game_name, '"'); // remove first " quote character game_name = stringUntil(game_name, '"'); // remove second " quote character scriptColData.value = game_name; } } // Custom functions ------------------------------------------------- function readAcfGameName(path_file) { var iterator = new Enumerator(readTextFile(path_file).split("\n")); for (; !iterator.atEnd(); iterator.moveNext()) { if (stringStartsWith(iterator.item(), ' "name" ')) { return stringAfter(iterator.item(), " "); } } } function readTextFile(path_file) // modified code from: http://www.winscripter.com/WSH/FileIO/74.aspx { var for_reading = 1, for_writing = 2, for_appending = 8; // define array to store lines. rline = new Array(); // Create the object fs = new ActiveXObject("Scripting.FileSystemObject"); f = fs.GetFile(path_file); // Open the file file = f.OpenAsTextStream(for_reading, 0); // Start and continue to read until we hit the end of the file. var count = 0; while(!file.AtEndOfStream) { rline[count] = file.ReadLine(); count++; } // Close the stream file.Close(); // Place the contents of the array into a variable. var content = ""; for(i = 0; i < rline.length; i++) { content += rline[i] + "\n"; } return content } function stringStartsWith(str, prefix) { return str.indexOf(prefix) == 0; } function stringEndsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } function stringAfter(str, delimiter) { var start = str.indexOf(delimiter); if (start !== -1) { return str.slice(start + delimiter.length, str.length); } return str; } function stringUntil(str, delimiter) { var end = str.indexOf(delimiter); if (end !== -1) { return str.slice(0, end); } return str; } // ------------------------------------------------------------------ /////////////////////////////////////////////////////////////////////////////// function OnAboutScript(data){ //v0.1 var cmd = DOpus.Create.Command(); if (!cmd.Commandlist('s').exists("ScriptWizard")){ if (DOpus.Dlg.Request("The 'ScriptWizard' add-in has not been found.\n\n"+ "Install 'ScriptWizard' from [resource.dopus.com].\nThe add-in enables this dialog and also offers "+ "easy updating of scripts and many more.","Yes, take me there!|Cancel", "No About.. ", data.window)) cmd.RunCommand('http://resource.dopus.com/viewtopic.php?f=35&t=23179');} else cmd.RunCommand('ScriptWizard ABOUT WIN='+data.window+' FILE="'+Script.File+'"'); } //MD5 = "81096f8a80c8955ba863cf94517a74ea"; DATE = "2016.05.12 - 20:10:02"