using System.Collections.Generic;
using MVR.FileManagementSecure; // FileManagerSecure (VaM's sandboxed file API)
public class LooksLister : MVRScript
{
// Returns the .vap (appearance preset) files in a folder, or an empty list.
private List<string> GetLooks(string path)
{
var looks = new List<string>();
// Tidy up slashes etc. so the path is in VaM's expected format.
string normalized = SuperController.singleton.NormalizePath(path);
// Don't use System.IO (Directory.Exists): VaM blocks it for plugins.
// FileManagerSecure is the allowed equivalent. It returns:
// true -> folder exists and is inside VaM's allowed area
// false -> folder doesn't exist
// It throws only if the folder exists but is OUTSIDE the allowed area, hence the try/catch below.
try
{
if (!FileManagerSecure.DirectoryExists(normalized))
return looks; // nothing there, give back the empty list
// Returns full paths, or null if the path isn't allowed.
string[] files = SuperController.singleton.GetFilesAtPath(normalized, "*.vap");
if (files != null)
looks.AddRange(files);
}
catch (System.Exception e) // path outside Saved/Custom
{
SuperController.LogError("Can't read '" + path + "': " + e.Message);
}
return looks;
}
// Typical call. Looks live under Custom/Atom/Person/Appearance.
// Use "Saved/..." or "Custom/..." paths; anything else is blocked.
private void Start()
{
List<string> looks = GetLooks("Custom/Atom/Person/Appearance");
SuperController.LogMessage("Found " + looks.Count + " looks");
}
}