Comments (2)
This horribleness is what I am currently doing (from Python) to determine the filters and formats:
def _get_exports(filename, arch='native'):
if not os.path.exists(filename):
return []
if filename.endswith('.a') or filename.endswith('.lib'):
# Crappy, sorry.
import subprocess
# syms = os.system('nm -g {}'.filename)
# on macOS at least:
# -PgUj is:
# P: posix format
# g: global (exported) only
# U: not undefined
# j is name only
if sys.platform == 'darwin':
flags = '-PgUj'
else:
flags = '-P'
out, _ = subprocess.Popen(['nm', flags, filename], shell=False,
stdout=subprocess.PIPE).communicate()
results = out.decode('utf-8').splitlines()
exports = [r.split(' ')[0] for r in results if (' T ') in r]
return exports
def get_libarchive_filters():
# This is horrible!
exports = _get_exports(os.path.join(sys.prefix, 'lib', 'libarchive.a'))
filters = {export.replace('_archive_write_add_filter_', '')
for export in exports if '_archive_write_add_filter_' in export}
for unwanted in ('by_name', 'program'):
if unwanted in filters:
filters.remove(unwanted)
return filters
def get_libarchive_formats():
# This is too!
exports = _get_exports(os.path.join(sys.prefix, 'lib', 'libarchive.a'))
formats = {export.replace('_archive_write_set_format_', '')
for export in exports if '_archive_write_set_format_' in export}
for unwanted in ('by_name', 'filter_by_ext', 'filter_by_ext_def', 'option'):
if unwanted in formats:
formats.remove(unwanted)
return formats
from python-libarchive-c.
This works better!
def get_libarchive_filters():
from libarchive.ffi import WRITE_FILTERS
return WRITE_FILTERS
def get_libarchive_formats():
from libarchive.ffi import WRITE_FORMATS
return WRITE_FORMATS
from python-libarchive-c.
Related Issues (20)
- Extract to specific folder HOT 2
- Minor test issues under pypy
- Attempting to use ArchiveEntry outside of for loop doesn't work
- read_next_header2() takes long time for closing archive in solid 7z archive when last file is big HOT 1
- Type checking
- Obtaining the position (byte offset) of an entry within the archive HOT 1
- `AttributeError` when using a libarchive version which doesn't support passphrases
- Cannot set uid/gid when adding file from memory
- hold strong reference of callback HOT 1
- Suggestion: Test file HOT 1
- Autodetection of libarchive version installed by Brew
- Tests with unicode path entires are failing HOT 2
- Ability to decrypt zip and 7z files HOT 3
- Extract empty files? HOT 2
- SECURE_NODOTDOT not having effect? HOT 1
- Writing 7zip file HOT 1
- Modifying the path of an entry before adding it to an archive HOT 1
- Detect valid archives HOT 3
- Inconsistent behavior for encrypted rar/zip/7z HOT 1
- Installing python-libarchive using pip via wheel HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-libarchive-c.