Module: AppInfo::Helper::FileTypeDetection
- Included in:
- AppInfo
- Defined in:
- lib/app_info/helper/file_type_detection.rb
Instance Method Summary collapse
-
#file_type(file) ⇒ Object
Detect file type by reading file header.
Instance Method Details
#file_type(file) ⇒ Object
Detect file type by reading file header
TODO: This can be better solution, if anyone knows, tell me please.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/app_info/helper/file_type_detection.rb', line 8 def file_type(file) header_hex = ::File.read(file, 100) case header_hex when ZIP_RETGEX detect_zip_file(file) when PE_REGEX AppInfo::Format::PE when PLIST_REGEX, BPLIST_REGEX AppInfo::Format::MOBILEPROVISION else AppInfo::Format::UNKNOWN end end |