This repository was archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 464
Zip #745
Open
FurkanS1821
wants to merge
6
commits into
indev
Choose a base branch
from
Zip
base: indev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Zip #745
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
760a97c
Zip support
FurkanS1821 322b525
Fixed requests
FurkanS1821 c40c71b
Even more changes
FurkanS1821 a3b5ae7
Idk what I changed either
FurkanS1821 80b3f67
Changed according to moon's requests
FurkanS1821 3678cdf
try/finally doesn't handle exceptions you dumbass
FurkanS1821 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using System.IO; | ||
|
|
||
| namespace LeagueSandbox.GameServer.Content | ||
| { | ||
| public class FileEntry | ||
| { | ||
| public string Name { get; } | ||
| public string FullPath { get; } | ||
|
|
||
| private byte[] _data; | ||
|
|
||
| public FileEntry(string name, string fullPath, Stream stream) | ||
| { | ||
| Name = name; | ||
| FullPath = fullPath; | ||
| using (stream) | ||
| { | ||
| _data = new byte[stream.Length]; | ||
| stream.Read(_data, 0, (int)stream.Length); | ||
| } | ||
| } | ||
|
|
||
| public MemoryStream ReadFile() | ||
| { | ||
| return new MemoryStream(_data); | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return FullPath; | ||
| } | ||
|
|
||
| public override int GetHashCode() | ||
| { | ||
| return FullPath.GetHashCode(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still storing full content of the file into memory.
However this time you did define a class that describes an interface for a
FileEntry.You should extract this interface so that you can have multiple implementations for
FileEntry(example .zip or file system).And yes this would mean that your
ContentManagerwould have to implementIDisposableto get rid of open .zip handles which should be trivial to implement(store them in list).So what you should implement is
FilesystemFileEntrywhich should be wraper forIFilerEntryaround this class:https://docs.microsoft.com/en-us/dotnet/api/system.io.fileinfo?view=netframework-4.7.2
For
ZipFileEntryyou can wrap this class(ZipArchiveEntry):https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-compress-and-extract-files
Both of those provide you a way to:
OpenorOpenReadwhich returns a stream