mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
IStorageProvider FileExists() and FolderExists()
--HG-- branch : 1.x extra : rebase_source : 89792dec51c9419263c469998810cb95d6a2c050
This commit is contained in:
@@ -57,6 +57,16 @@ namespace Orchard.Tests.Storage {
|
||||
private string _folderPath;
|
||||
private IStorageProvider _storageProvider;
|
||||
|
||||
[Test]
|
||||
public void ExistsShouldBeTrueForExtistingFile() {
|
||||
Assert.That(_storageProvider.FileExists("testfile.txt"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExistsShouldBeFalseForNonExtistingFile() {
|
||||
Assert.That(_storageProvider.FileExists("notexisting"), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void GetFileThatDoesNotExistShouldThrow() {
|
||||
@@ -99,6 +109,16 @@ namespace Orchard.Tests.Storage {
|
||||
Assert.That(file2.GetPath(), Is.EqualTo("Subfolder1" + Path.DirectorySeparatorChar + "one.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExistsShouldBeTrueForExtistingFolder() {
|
||||
Assert.That(_storageProvider.FolderExists("Subfolder1"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExistsShouldBeFalseForNonExtistingFolder() {
|
||||
Assert.That(_storageProvider.FolderExists("notexisting"), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ListFoldersReturnsItemsWithShortPathAndEnvironmentSlashes() {
|
||||
var folders = _storageProvider.ListFolders(@"Subfolder1");
|
||||
|
@@ -4,6 +4,13 @@ using System.IO;
|
||||
|
||||
namespace Orchard.FileSystems.Media {
|
||||
public interface IStorageProvider : IDependency {
|
||||
/// <summary>
|
||||
/// Checks if the given file exists within the storage provider.
|
||||
/// </summary>
|
||||
/// <param name="path">The relative path within the storage provider.</param>
|
||||
/// <returns>True if the file exists; False otherwise.</returns>
|
||||
bool FileExists(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the public URL for a given file within the storage provider.
|
||||
/// </summary>
|
||||
@@ -26,6 +33,13 @@ namespace Orchard.FileSystems.Media {
|
||||
/// <returns>The list of files in the folder.</returns>
|
||||
IEnumerable<IStorageFile> ListFiles(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given folder exists within the storage provider.
|
||||
/// </summary>
|
||||
/// <param name="path">The relative path within the storage provider.</param>
|
||||
/// <returns>True if the folder exists; False otherwise.</returns>
|
||||
bool FolderExists(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the folders within a storage provider's path.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user