Skip to content

Commit

Permalink
feat: add App.FileBytes(path string) ([]byte, error) helper
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
moul committed Jun 1, 2020
1 parent 4e40c1a commit 2b82d78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/ipa/ipa.go
Expand Up @@ -99,6 +99,11 @@ func (a App) File(name string) *zip.File {
return nil
}

func (a App) FileBytes(name string) ([]byte, error) {
target := path.Join(a.dir(), name)
return a.p.FileBytes(target)
}

func (a App) Plist() (*Plist, error) {
b, err := a.p.FileBytes(path.Join(a.dir(), "Info.plist"))
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/ipa/ipa_test.go
Expand Up @@ -62,4 +62,12 @@ func TestOpen_gomobileipfsdemo(t *testing.T) {
UISupportedInterfaceOrientations: []string{"UIInterfaceOrientationPortrait", "UIInterfaceOrientationLandscapeLeft"},
}
require.Equal(t, plist, expected)

noExists, err := app.FileBytes("blahblah")
require.Nil(t, noExists)
require.Error(t, err)

exists, err := app.FileBytes("Frameworks/libswiftFoundation.dylib")
require.NoError(t, err)
require.Equal(t, len(exists), 8479536)
}

0 comments on commit 2b82d78

Please sign in to comment.