void ThrowIfContainerNotFound() { if (!_file.Directory.Exists) { throw StreamErrors.ContainerNotFound(this); } }
void ThrowIfItemNotFound() { if (!_file.Exists) { throw StreamErrors.ItemNotFound(this); } }
public IEnumerable<string> ListAllNestedItems() { try { return _root.GetFiles().Select(f => f.Name).ToArray(); } catch (DirectoryNotFoundException e) { throw StreamErrors.ContainerNotFound(this, e); } }
public IEnumerable<StreamItemDetail> ListAllNestedItemsWithDetail() { try { return _root.GetFiles("*", SearchOption.AllDirectories).Select(f => new StreamItemDetail() { LastModifiedUtc = f.LastWriteTimeUtc, Length = f.Length, Name = f.Name }).ToArray(); } catch (DirectoryNotFoundException e) { throw StreamErrors.ContainerNotFound(this, e); } }
public IEnumerable <string> ListItems() { try { return(_directory.ListBlobs() .Select(item => _directory.Uri.MakeRelativeUri(item.Uri).ToString()) .ToArray()); } catch (StorageClientException e) { switch (e.ErrorCode) { case StorageErrorCode.ContainerNotFound: throw StreamErrors.ContainerNotFound(this, e); default: throw; } } }
/// <summary> /// Removes the item, ensuring that the specified condition is met. /// </summary> public void Delete() { try { _blob.Delete(); } catch (StorageClientException ex) { switch (ex.ErrorCode) { case StorageErrorCode.ContainerNotFound: throw StreamErrors.ContainerNotFound(this, ex); case StorageErrorCode.BlobNotFound: case StorageErrorCode.ConditionFailed: return; default: throw; } } }