Skip to content

Commit

Permalink
(chocolateyGH-121) IFileSystem.read_file_bytes
Browse files Browse the repository at this point in the history
Allow IFileSystem to read a file and return the file bytes as an array.
  • Loading branch information
ferventcoder committed May 3, 2015
1 parent f60ce80 commit 2da7306
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ public string read_file(string filePath)
return File.ReadAllText(filePath, get_file_encoding(filePath));
}

public byte[] read_file_bytes(string filePath)
{
return File.ReadAllBytes(filePath);
}

public FileStream open_file_readonly(string filePath)
{
return File.OpenRead(filePath);
Expand Down
8 changes: 8 additions & 0 deletions src/chocolatey/infrastructure/filesystem/IFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ public interface IFileSystem
/// <returns>A string of the file contents</returns>
string read_file(string filePath);

/// <summary>
/// Returns the contents of a file as bytes.
/// </summary>
/// <param name="filePath">The filepath.</param>
/// <returns>A byte array of the file contents</returns>
byte[] read_file_bytes(string filePath);

/// <summary>
/// Opens a file
/// </summary>
Expand Down Expand Up @@ -330,5 +337,6 @@ public interface IFileSystem
/// <param name="path">The path.</param>
/// <param name="attributes">The attributes.</param>
void ensure_file_attribute_set(string path, FileAttributes attributes);

}
}

0 comments on commit 2da7306

Please sign in to comment.