using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ScrewTurn.Wiki.PluginFramework { /// /// Contains information about a directory. /// /// This class is only used for provider-host communication. public class StDirectoryInfo { private string fullPath; private IFilesStorageProviderV30 provider; /// /// Initializes a new instance of the class. /// /// The full path of the directory, for example /dir/sub/ or /. /// The provider that handles the directory. public StDirectoryInfo(string fullPath, IFilesStorageProviderV30 provider) { this.fullPath = fullPath; this.provider = provider; } /// /// Gets the full path of the directory, for example /dir/sub/ or /. /// public string FullPath { get { return fullPath; } } /// /// Gets the provider that handles the directory. /// public IFilesStorageProviderV30 Provider { get { return provider; } } /// /// Gets the directory of a file. /// /// The full file path, such as '/file.txt' or '/directory/sub/file.txt'. /// The directory, such as '/' or '/directory/sub/'. public static string GetDirectory(string filePath) { if(!filePath.StartsWith("/")) filePath = "/" + filePath; int lastIndex = filePath.LastIndexOf("/"); if(lastIndex == 0) return "/"; else return filePath.Substring(0, lastIndex + 1); } } }