Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion FileSystem.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22013.1
VisualStudioVersion = 14.0.22108.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1477614-E825-4204-A684-385004B63AEB}"
EndProject
Expand All @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.FileSystems.Interfaces", "src\Microsoft.AspNet.FileSystems.Interfaces\Microsoft.AspNet.FileSystems.Interfaces.kproj", "{DD94B7E8-3A59-4F84-98A0-8139BE259A87}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -46,12 +48,23 @@ Global
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9}.Release|x86.ActiveCfg = Release|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Debug|x86.ActiveCfg = Debug|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Release|Any CPU.Build.0 = Release|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DD94B7E8-3A59-4F84-98A0-8139BE259A87}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A830B046-595A-4992-B9E1-3C28C6440707} = {A1477614-E825-4204-A684-385004B63AEB}
{66FE5FDF-BBF9-4573-A7B7-53551731C0F9} = {E399495E-82B8-4C06-8779-C1D02BEF4495}
{DD94B7E8-3A59-4F84-98A0-8139BE259A87} = {A1477614-E825-4204-A684-385004B63AEB}
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions src/Microsoft.AspNet.FileSystems.Interfaces/IDirectoryContents.cs
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System namespaces go first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


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; }
}
}
32 changes: 32 additions & 0 deletions src/Microsoft.AspNet.FileSystems.Interfaces/IExpirationTrigger.cs
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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Up @@ -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; }

Expand All @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make it symmetric to CreateReadStream so that it returns a writeable stream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an IsReadOnly property?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎱

Copy link
Contributor

Choose a reason for hiding this comment

The 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();
}
}
}
28 changes: 28 additions & 0 deletions src/Microsoft.AspNet.FileSystems.Interfaces/IFileSystem.cs
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>
12 changes: 12 additions & 0 deletions src/Microsoft.AspNet.FileSystems.Interfaces/project.json
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": { }
}
}
Loading