Skip to content

Commit

Permalink
Merge pull request #70 from FrendsPlatform/issue-69
Browse files Browse the repository at this point in the history
Files.Read fixed issue-69
  • Loading branch information
ttossavainen authored Oct 15, 2024
2 parents 6610978 + 812e01a commit 4bc80e4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Frends.Files.Read/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.1.0] - 2024-10-14
### Fixed
- Fixed documentation for Path parameter.
### Added
- Added Windows1252 encoding to the FileEncoding enum.
- Added different sizes to the Task result.

## [1.0.0] - 2023-02-28
### Added
- Initial implementation
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void TearDown()
}

[Test]
public async Task FileMoveTestWithCredentials()
public async Task FileReadTestWithCredentials()
{
var result = await Files.Read(_input, _options);

Expand All @@ -70,7 +70,7 @@ public async Task FileMoveTestWithCredentials()
}

[Test]
public void FileMoveTestWithUsernameWithoutDomain()
public void FileReadTestWithUsernameWithoutDomain()
{
var options = new Options
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is test file
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace Frends.Files.Read.Definitions;
public enum FileEncoding
{
UTF8,
ANSI,
Default,
ASCII,
Unicode,
Windows1252,
Other
}
2 changes: 1 addition & 1 deletion Frends.Files.Read/Frends.Files.Read/Definitions/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Frends.Files.Read.Definitions;
public class Input
{
/// <summary>
/// Full path of the target file to be written
/// Full path of the target file to be read.
/// </summary>
/// <example>c:\temp\foo.txt</example>
[DisplayFormat(DataFormatString = "Text")]
Expand Down
14 changes: 14 additions & 0 deletions Frends.Files.Read/Frends.Files.Read/Definitions/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public class Result
/// <example>32</example>
public double SizeInMegaBytes { get; private set; }

/// <summary>
/// Size of the written file in kilo bytes.
/// </summary>
/// <example>32</example>
public double SizeInKiloBytes { get; private set; }

/// <summary>
/// Size of the written file in bytes.
/// </summary>
/// <example>32</example>
public double SizeInBytes { get; private set; }

/// <summary>
/// DateTime when file was created.
/// </summary>
Expand All @@ -42,6 +54,8 @@ internal Result(FileInfo info, string content)
Content = content;
Path = info.FullName;
SizeInMegaBytes = Math.Round(info.Length / 1024d / 1024d, 3);
SizeInKiloBytes = Math.Round(info.Length / 1024d, 3);
SizeInBytes = info.Length;
CreationTime = info.CreationTime;
LastWriteTime = info.LastWriteTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<Authors>Frends</Authors>
<Copyright>Frends</Copyright>
<Company>Frends</Company>
Expand Down
8 changes: 6 additions & 2 deletions Frends.Files.Read/Frends.Files.Read/Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Frends.Files.Read;
public class Files
{
/// <summary>
/// Read file.
/// Reads a file from directory.
/// [Documentation](https://tasks.frends.com/tasks/frends-tasks/Frends.Files.Read)
/// </summary>
/// <param name="input">Input parameters</param>
Expand Down Expand Up @@ -75,10 +75,14 @@ private static Encoding GetEncoding(FileEncoding optionsFileEncoding, bool optio
return Encoding.GetEncoding(optionsEncodingInString);
case FileEncoding.ASCII:
return Encoding.ASCII;
case FileEncoding.ANSI:
case FileEncoding.Default:
return Encoding.Default;
case FileEncoding.UTF8:
return optionsEnableBom ? new UTF8Encoding(true) : new UTF8Encoding(false);
case FileEncoding.Windows1252:
EncodingProvider provider = CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(provider);
return Encoding.GetEncoding(1252);
case FileEncoding.Unicode:
return Encoding.Unicode;
default:
Expand Down

0 comments on commit 4bc80e4

Please sign in to comment.