mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Adds an interface to list files in the static directories
This commit is contained in:
@@ -119,5 +119,26 @@ namespace TGServerService
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
|
||||
public IList<string> ListStaticDirectory(string subDir, out string error)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo dirToEnum = new DirectoryInfo(Path.Combine(StaticDirs, subDir ?? ""));
|
||||
var result = new List<string>();
|
||||
foreach (var I in dirToEnum.GetFiles())
|
||||
result.Add(I.Name);
|
||||
foreach (var I in dirToEnum.GetDirectories())
|
||||
result.Add("@" + I.Name);
|
||||
error = null;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = e.ToString();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,16 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
string ServerDirectory();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the file contents of the specified server directory
|
||||
/// Subdirectories will be prefixed with '@'
|
||||
/// </summary>
|
||||
/// <param name="subpath">Subdirectory to enumerate, enumerates the root directory if null</param>
|
||||
/// <param name="error">null on success, error message on failure</param>
|
||||
/// <returns>A list of files in the enumerated static directory on success, null on failure</returns>
|
||||
[OperationContract]
|
||||
IList<string> ListStaticDirectory(string subpath, out string error);
|
||||
|
||||
/// <summary>
|
||||
/// For when you really just need to see the raw data of the config
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user