Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e4284b4

Browse files
Merge pull request #545 from github-for-unity/enhancements/download-functionality
Download Functionality
2 parents 926e19d + 7ea50e5 commit e4284b4

File tree

8 files changed

+511
-0
lines changed

8 files changed

+511
-0
lines changed

GitHub.Unity.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
</TypePattern>
336336
&lt;/Patterns&gt;</s:String>
337337
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
338+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD</s:String>
338339
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSH/@EntryIndexedValue">SSH</s:String>
339340
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
340341
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
<Compile Include="Tasks\BaseOutputProcessor.cs" />
140140
<Compile Include="Tasks\ConcurrentExclusiveInterleave.cs" />
141141
<Compile Include="Tasks\ConfigOutputProcessor.cs" />
142+
<Compile Include="Tasks\DownloadTask.cs" />
142143
<Compile Include="Tasks\ITaskManager.cs" />
143144
<Compile Include="Tasks\ProcessTask.cs" />
144145
<Compile Include="Tasks\TaskBase.cs" />

src/GitHub.Api/IO/FileSystem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public bool FileExists(string filename)
3434
return File.Exists(filename);
3535
}
3636

37+
public long FileLength(string path)
38+
{
39+
var fileInfo = new FileInfo(path);
40+
return fileInfo.Length;
41+
}
42+
3743
public IEnumerable<string> GetDirectories(string path)
3844
{
3945
return Directory.GetDirectories(path);
@@ -167,6 +173,11 @@ public void WriteAllText(string path, string contents, Encoding encoding)
167173
File.WriteAllText(path, contents, encoding);
168174
}
169175

176+
public byte[] ReadAllBytes(string path)
177+
{
178+
return File.ReadAllBytes(path);
179+
}
180+
170181
public string ReadAllText(string path)
171182
{
172183
return File.ReadAllText(path);
@@ -201,5 +212,10 @@ public Stream OpenRead(string path)
201212
{
202213
return File.OpenRead(path);
203214
}
215+
216+
public Stream OpenWrite(string path, FileMode mode)
217+
{
218+
return new FileStream(path, mode);
219+
}
204220
}
205221
}

src/GitHub.Api/IO/IFileSystem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace GitHub.Unity
77
public interface IFileSystem
88
{
99
bool FileExists(string path);
10+
long FileLength(string path);
1011
string Combine(string path1, string path2);
1112
string Combine(string path1, string path2, string path3);
1213
string GetFullPath(string path);
@@ -37,9 +38,11 @@ public interface IFileSystem
3738
string ReadAllText(string path);
3839
string ReadAllText(string path, Encoding encoding);
3940
Stream OpenRead(string path);
41+
Stream OpenWrite(string path, FileMode mode);
4042
string[] ReadAllLines(string path);
4143
char DirectorySeparatorChar { get; }
4244
bool ExistingPathIsDirectory(string path);
4345
void SetCurrentDirectory(string currentDirectory);
46+
byte[] ReadAllBytes(string path);
4447
}
4548
}

src/GitHub.Api/IO/NiceIO.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ public NPath WriteAllText(string contents, Encoding encoding)
907907
return this;
908908
}
909909

910+
public byte[] ReadAllBytes()
911+
{
912+
ThrowIfRelative();
913+
return FileSystem.ReadAllBytes(ToString());
914+
}
915+
910916
public string ReadAllText()
911917
{
912918
ThrowIfRelative();

0 commit comments

Comments
 (0)