Adds an interface to list files in the static directories

This commit is contained in:
Cyberboss
2017-09-21 11:57:33 -04:00
parent fc29d1d680
commit e780aea11e
2 changed files with 31 additions and 0 deletions
+21
View File
@@ -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;
}
}
}
}
+10
View File
@@ -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>