Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed loading of native functions if pfp is contained in ZIP file #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

synalysis
Copy link

After trying to distribute PFP in a ZIP file I noticed that the native functions (BigEndian...) don't work anymore.

This pull request enables loading of the native files within a ZIP file.

@d0c-s4vage
Copy link
Owner

Hrmm, perhaps this would work? https://docs.python.org/2/library/zipimport.html I haven't used this myself, but from the docs it seems that if you add a .zip of pfp to sys.path you should be able to import it just fine.

@synalysis
Copy link
Author

Loading PFP as a whole from a ZIP works fine however iterating a folder inside the ZIP with methods working on directories doesn't work. It's only about loading the native functions.

@d0c-s4vage
Copy link
Owner

Sigh, I don't know why this never got merged. Are you still working on Synalysis @synalysis ?

@synalysis
Copy link
Author

Sigh, I don't know why this never got merged. Are you still working on Synalysis @synalysis ?

Yes, every pfp improvement is appreciated!

@d0c-s4vage
Copy link
Owner

This is quite an old PR, which is totally my fault. @synalysis here are my thoughts:

  • The known issues list needs to be triaged into actual tickets (I'll help with that)
  • Resolve merge conflicts
  • If all tests pass after changing the above items, LGTM!

Copy link
Owner

@d0c-s4vage d0c-s4vage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address the few comments, then if the tests pass, you're good!

@@ -0,0 +1,876 @@

###### AndroidManifestTemplate.bt ######
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make a new issue to follow up on these older known issues. I'd still like to document them and make sure we eventually clear them out. I.e. remove the known_issues.md and make a github issue with its contents.

pythonfiles = []

mydir = os.path.dirname(__file__)
if '.zip' in mydir:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be if mydir.endswith('.zip')?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's different than .endswith() because the zip file can be one among many directories in the path and is not necessarily the last one.

@@ -1212,6 +1229,22 @@ def _handle_metadata(self, node, scope, ctxt, stream):
#char blah[60] <packer=Zip, packtype=DataType>;
#int checksum <watch=field1,field2,field3, update=Crc32>;

def _handle_format_metadata(self, node, scope, ctxt, stream):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants