-
Notifications
You must be signed in to change notification settings - Fork 80
Refactoring IFileSystem #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.AspNet.FileSystems | ||
| { | ||
| /// <summary> | ||
| /// Represents a directory's content in the file system. | ||
| /// </summary> | ||
| #if ASPNET50 || ASPNETCORE50 | ||
| [Framework.Runtime.AssemblyNeutral] | ||
| #endif | ||
| public interface IDirectoryContents : IEnumerable<IFileInfo> | ||
| { | ||
| /// <summary> | ||
| /// True if a directory was located at the given path. | ||
| /// </summary> | ||
| bool Exists { get; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Microsoft.Framework.Expiration.Interfaces | ||
| { | ||
| #if ASPNET50 || ASPNETCORE50 | ||
| [Framework.Runtime.AssemblyNeutral] | ||
| #endif | ||
| public interface IExpirationTrigger | ||
| { | ||
| /// <summary> | ||
| /// Checked each time the key is accessed in the cache. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not super sure what this comment means. |
||
| /// </summary> | ||
| bool IsExpired { get; } | ||
|
|
||
| /// <summary> | ||
| /// Indicates if this trigger will pro-actively trigger callbacks. Callbacks are still guaranteed to fire, eventually. | ||
| /// </summary> | ||
| bool ActiveExpirationCallbacks { get; } | ||
|
|
||
| /// <summary> | ||
| /// Registers for a callback that will be invoked when the entries should be expired. | ||
| /// IsExpired MUST be set before the callback is invoked. | ||
| /// </summary> | ||
| /// <param name="callback"></param> | ||
| /// <param name="state"></param> | ||
| /// <returns></returns> | ||
| IDisposable RegisterExpirationCallback(Action<object> callback, object state); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,26 +3,35 @@ | |
|
|
||
| using System; | ||
| using System.IO; | ||
| using Microsoft.Framework.Expiration.Interfaces; | ||
|
|
||
| namespace Microsoft.AspNet.FileSystems | ||
| { | ||
| /// <summary> | ||
| /// Represents a file in the given file system. | ||
| /// </summary> | ||
| #if ASPNET50 || ASPNETCORE50 | ||
| [Framework.Runtime.AssemblyNeutral] | ||
| #endif | ||
| public interface IFileInfo | ||
| { | ||
| /// <summary> | ||
| /// The length of the file in bytes, or -1 for a directory info | ||
| /// True if resource exists in the underlying storage system. | ||
| /// </summary> | ||
| bool Exists { get; } | ||
|
|
||
| /// <summary> | ||
| /// The length of the file in bytes, or -1 for a directory or non-existing files. | ||
| /// </summary> | ||
| long Length { get; } | ||
|
|
||
| /// <summary> | ||
| /// The path to the file, including the file name. Return null if the file is not directly accessible. | ||
| /// The path to the file, including the file name. Return null if the file is not directly accessible. | ||
| /// </summary> | ||
| string PhysicalPath { get; } | ||
|
|
||
| /// <summary> | ||
| /// The name of the file | ||
| /// The name of the file or directory, not including any path. | ||
| /// </summary> | ||
| string Name { get; } | ||
|
|
||
|
|
@@ -41,5 +50,26 @@ public interface IFileInfo | |
| /// </summary> | ||
| /// <returns>The file stream</returns> | ||
| Stream CreateReadStream(); | ||
|
|
||
| /// <summary> | ||
| /// True if the file is readonly. | ||
| /// </summary> | ||
| bool IsReadOnly { get; } | ||
|
|
||
| /// <summary> | ||
| /// Store new contents for resource. Folders will be created if needed. | ||
| /// </summary> | ||
| void WriteContent(byte[] content); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to make it symmetric to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need an IsReadOnly property?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎱
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a IsReadOnly property to IFileInfo. |
||
|
|
||
| /// <summary> | ||
| /// Deletes the file. | ||
| /// </summary> | ||
| void Delete(); | ||
|
|
||
| /// <summary> | ||
| /// Gets a trigger to monitor the file changes. | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| IExpirationTrigger CreateFileChangeTrigger(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.AspNet.FileSystems | ||
| { | ||
| /// <summary> | ||
| /// A file system abstraction. | ||
| /// </summary> | ||
| #if ASPNET50 || ASPNETCORE50 | ||
| [Framework.Runtime.AssemblyNeutral] | ||
| #endif | ||
| public interface IFileSystem | ||
| { | ||
| /// <summary> | ||
| /// Locate a file at the given path. | ||
| /// </summary> | ||
| /// <param name="subpath">Relative path that identifies the file.</param> | ||
| /// <returns>The file information. Caller must check Exists property.</returns> | ||
| IFileInfo GetFileInfo(string subpath); | ||
|
|
||
| /// <summary> | ||
| /// Enumerate a directory at the given path, if any. | ||
| /// </summary> | ||
| /// <param name="subpath">Relative path that identifies the directory.</param> | ||
| /// <returns>Returns the contents of the directory.</returns> | ||
| IDirectoryContents GetDirectoryContents(string subpath); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup> | ||
| <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion> | ||
| <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
| </PropertyGroup> | ||
|
|
||
| <Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
| <PropertyGroup Label="Globals"> | ||
| <ProjectGuid>dd94b7e8-3a59-4f84-98a0-8139be259a87</ProjectGuid> | ||
| <OutputType>Library</OutputType> | ||
| <RootNamespace>Microsoft.AspNet.FileSystems.Interfaces</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="$(OutputType) == 'Console'"> | ||
| <DebuggerFlavor>ConsoleDebugger</DebuggerFlavor> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="$(OutputType) == 'Web'"> | ||
| <DebuggerFlavor>WebDebugger</DebuggerFlavor> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <SchemaVersion>2.0</SchemaVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "version": "1.0.0-*", | ||
| "description": "ASP.NET 5 File System interfaces.", | ||
| "dependencies": { | ||
| "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*" | ||
| }, | ||
| "frameworks": { | ||
| "net45": { }, | ||
| "aspnet50": { }, | ||
| "aspnetcore50": { } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System namespaces go first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done