Here's a basic script which implements the column. It will show:
[ul][li]"Writable" if it is able to open a file for writing.[/li]
[li]"Read-Only" if it can't open it for writing but can open it for reading.[/li]
[li]"Inaccessible" otherwise. (And nothing at all for folders.)[/li][/ul]
(It doesn't check for the rare case that something can be written but not read. That will just be reported as "Writable" the same as a normal read/write file.)
Important: You may want to wait until Opus 12.0.5 beta is out before using this, assuming you have UAC enabled. In current Opus versions, the column can/will trigger annoying UAC prompts if it cannot access things. I just made a code-change for 12.0.5 which allows scripts to request that UAC elevation does not happen, and the script uses that, but versions before 12.0.5 will ignore the request.
Also important: The script opens files for writing and then closes them. In my testing so far, this has not modified any of the files, but since the script is brand new and has only been tested a limited amount on my own machine, I advise using it first on some test files you don't care about, just in case. I don't think there is any risk, but it's better safe than sorry.
Download and drop into Preferences / Toolbars / Scripts:
Locked_Column.js.txt (1.54 KB)
You'll then have a Scripts > Locked column which can be added to the file display.
Code for reference (same as the .txt file):
[code]// Locked Column
// (c) 2016 Leo Davidson
// This is a script for Directory Opus.
// See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
var strWritable = "Writable";
var strReadOnly = "Read-Only";
var strInaccessible = "Inaccessible";
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "Locked Column";
initData.desc = "A column which shows which files can be modified.";
initData.copyright = "(c) 2016 Leo Davidson";
initData.version = "1.0";
initData.default_enable = true;
// initData.min_version = "12.0.5"; // Will work better with Opus 12.0.5 once it is released. Required to prevent UAC prompts.
var col = initData.AddColumn();
col.name = "Locked";
col.method = "OnLocked";
col.label = "Locked";
col.justify = "left";
col.autogroup = true;
col.match.push_back(strWritable); // when searching, these are the options.
col.match.push_back(strReadOnly);
col.match.push_back(strInaccessible);
}
// Implement the Locked column
function OnLocked(scriptColData)
{
if (scriptColData.item.is_dir)
{
return;
}
var file = scriptColData.item.Open("we","ElevateNoAsk");
var openError = file.error;
file.Close();
if (openError == 0)
{
scriptColData.value = strWritable;
return;
}
file = scriptColData.item.Open("","ElevateNoAsk");
openError = file.error;
file.Close();
if (openError == 0)
{
scriptColData.value = strReadOnly;
return;
}
scriptColData.value = strInaccessible;
}[/code]