mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
feat: Added eIcdFileMode for IO platform agnosticism
This commit is contained in:
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
### Added
|
### Added
|
||||||
- Added ToCollection extension method for copying an enumerable to a new collection
|
- Added ToCollection extension method for copying an enumerable to a new collection
|
||||||
- TableBuilder supports multi-line content
|
- TableBuilder supports multi-line content
|
||||||
|
- Added eIcdFileMode for IO platform agnosticism
|
||||||
|
|
||||||
## [11.0.0] - 2020-03-20
|
## [11.0.0] - 2020-03-20
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -126,6 +126,7 @@
|
|||||||
<Compile Include="GuidUtils.cs" />
|
<Compile Include="GuidUtils.cs" />
|
||||||
<Compile Include="IcdUriBuilder.cs" />
|
<Compile Include="IcdUriBuilder.cs" />
|
||||||
<Compile Include="IO\Compression\IcdZipEntry.cs" />
|
<Compile Include="IO\Compression\IcdZipEntry.cs" />
|
||||||
|
<Compile Include="IO\eIcdFileMode.cs" />
|
||||||
<Compile Include="IO\IcdBinaryReader.cs" />
|
<Compile Include="IO\IcdBinaryReader.cs" />
|
||||||
<Compile Include="IO\eSeekOrigin.cs" />
|
<Compile Include="IO\eSeekOrigin.cs" />
|
||||||
<Compile Include="IO\IcdStreamWriter.cs" />
|
<Compile Include="IO\IcdStreamWriter.cs" />
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ namespace ICD.Common.Utils.IO
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IcdFileStream Open(string path, FileMode mode)
|
public static IcdFileStream Open(string path, eIcdFileMode mode)
|
||||||
{
|
{
|
||||||
return new IcdFileStream(File.Open(path, mode));
|
return new IcdFileStream(File.Open(path, mode.ToFileMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
|
|||||||
46
ICD.Common.Utils/IO/eIcdFileMode.cs
Normal file
46
ICD.Common.Utils/IO/eIcdFileMode.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
#if SIMPLSHARP
|
||||||
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
|
#else
|
||||||
|
using System.IO;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace ICD.Common.Utils.IO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies how the operating system should open a file.
|
||||||
|
/// </summary>
|
||||||
|
public enum eIcdFileMode
|
||||||
|
{
|
||||||
|
CreateNew = 1,
|
||||||
|
Create = 2,
|
||||||
|
Open = 3,
|
||||||
|
OpenOrCreate = 4,
|
||||||
|
Truncate = 5,
|
||||||
|
Append = 6,
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class IcdFileModeExtensions
|
||||||
|
{
|
||||||
|
public static FileMode ToFileMode(this eIcdFileMode extends)
|
||||||
|
{
|
||||||
|
switch (extends)
|
||||||
|
{
|
||||||
|
case eIcdFileMode.CreateNew:
|
||||||
|
return FileMode.CreateNew;
|
||||||
|
case eIcdFileMode.Create:
|
||||||
|
return FileMode.Create;
|
||||||
|
case eIcdFileMode.Open:
|
||||||
|
return FileMode.Open;
|
||||||
|
case eIcdFileMode.OpenOrCreate:
|
||||||
|
return FileMode.OpenOrCreate;
|
||||||
|
case eIcdFileMode.Truncate:
|
||||||
|
return FileMode.Truncate;
|
||||||
|
case eIcdFileMode.Append:
|
||||||
|
return FileMode.Append;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException("extends");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user