├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── Images ├── App-Icon.svg └── ScreenShots │ ├── ScreenShot-AbyssDark.svg │ ├── ScreenShot-Dracula.svg │ ├── ScreenShot-Drawer.svg │ ├── ScreenShot-Home.svg │ ├── ScreenShot-QuietLight.svg │ └── ScreenShot-Terminal.svg ├── LICENSE.md ├── README.md ├── app ├── .gitignore ├── arch_arm32 │ ├── assets │ │ └── python.7z │ └── release │ │ └── output-metadata.json ├── arch_arm64-v8a │ └── assets │ │ └── python.7z ├── arch_x86 │ └── assets │ │ └── python.7z ├── arch_x86_64 │ └── assets │ │ └── python.7z ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── github │ │ └── psicodes │ │ └── ktxpy │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── .idea │ │ ├── .gitignore │ │ ├── misc.xml │ │ └── modules.xml │ ├── AndroidManifest.xml │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── JetBrainsMono-Regular.ttf │ │ ├── Roboto-Regular.ttf │ │ ├── RobotoMono-Regular.ttf │ │ ├── Samples │ │ │ ├── PatternPrinter.py │ │ │ ├── inputFromUser.py │ │ │ ├── loops.py │ │ │ ├── numberGuesser.py │ │ │ ├── printAWord.py │ │ │ ├── rockPaperScisscors.py │ │ │ └── ticTacToe.py │ │ └── textmate │ │ │ ├── QuietLight.tmTheme │ │ │ ├── abyss-color-theme.json │ │ │ ├── darcula.json │ │ │ └── python │ │ │ ├── language-configuration.json │ │ │ └── syntax │ │ │ └── python.tmLanguage.json │ ├── ic_launcher-playstore.png │ ├── java │ │ ├── com │ │ │ └── wildzeus │ │ │ │ └── pythonktx │ │ │ │ └── ui │ │ │ │ └── LayoutComponents │ │ │ │ └── DropDownMenu │ │ │ │ └── DropDownMenuItem.kt │ │ └── github │ │ │ └── psicodes │ │ │ └── ktxpy │ │ │ ├── Application.kt │ │ │ ├── activities │ │ │ ├── EditorActivity.kt │ │ │ ├── HomeActivity.kt │ │ │ └── TermActivity.kt │ │ │ ├── dataStore │ │ │ └── SettingsDataStore.kt │ │ │ ├── ui │ │ │ ├── layoutComponents │ │ │ │ ├── FullScreenMessage.kt │ │ │ │ ├── ListComponent.kt │ │ │ │ └── MenuItem.kt │ │ │ ├── screens │ │ │ │ ├── AboutScreen.kt │ │ │ │ ├── FilePickerScreen.kt │ │ │ │ ├── HomeScreen.kt │ │ │ │ ├── LibraryDownloaderScreen.kt │ │ │ │ └── SampleScreen.kt │ │ │ └── theme │ │ │ │ ├── Color.kt │ │ │ │ ├── EditorTheme.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ ├── utils │ │ │ ├── Commands.kt │ │ │ ├── CrashHandler.java │ │ │ ├── Keys.kt │ │ │ ├── PermissionManageExternal.kt │ │ │ └── PythonFileManager.kt │ │ │ └── viewModels │ │ │ └── HomeScreenViewModel.kt │ ├── jniLibs │ │ ├── arm64-v8a │ │ │ └── libpython3.so │ │ ├── armeabi-v7a │ │ │ └── libpython3.so │ │ ├── x86 │ │ │ └── libpython3.so │ │ └── x86_64 │ │ │ └── libpython3.so │ └── res │ │ ├── drawable-v24 │ │ ├── redo_icon.xml │ │ ├── scrollbar_track_icon.xml │ │ └── undo_icon.xml │ │ ├── drawable │ │ ├── about_icon.xml │ │ ├── add_file_icon.xml │ │ ├── app_icon.xml │ │ ├── app_icon_foreground.xml │ │ ├── back_icon.xml │ │ ├── code_run_icon.xml │ │ ├── coming_soon_icon.xml │ │ ├── create_file_icon.xml │ │ ├── current_files_icon.xml │ │ ├── file_icon.xml │ │ ├── file_open_icon.xml │ │ ├── folder_icon.xml │ │ ├── interactive_mode_icon.xml │ │ ├── library_icon.xml │ │ ├── menu_icon.xml │ │ ├── python_icon.xml │ │ ├── sample_icon.xml │ │ ├── scrollbar_thumb_icon.xml │ │ ├── terminal_icon.xml │ │ ├── text_save_icon.xml │ │ ├── theme_selector_icon.xml │ │ └── white_cursor_icon.xml │ │ ├── font │ │ ├── custom_sans.ttf │ │ ├── jetbrainsmono_medium.ttf │ │ └── roboto_condensed_bold.ttf │ │ ├── ic_launcher-web.png │ │ ├── layout │ │ └── activity_editor.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── playstore-icon.png │ │ ├── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── github │ └── psicodes │ └── ktxpy │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── libp7zip ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── CMakeLists.txt │ ├── cmd │ │ ├── command.cpp │ │ └── command.h │ ├── ndkhelper.h │ ├── p7zip.cpp │ ├── p7zip │ │ ├── C │ │ │ ├── 7zBuf.h │ │ │ ├── 7zBuf2.c │ │ │ ├── 7zCrc.c │ │ │ ├── 7zCrc.h │ │ │ ├── 7zCrcOpt.c │ │ │ ├── 7zStream.c │ │ │ ├── 7zTypes.h │ │ │ ├── 7zVersion.h │ │ │ ├── Aes.c │ │ │ ├── Aes.h │ │ │ ├── Alloc.c │ │ │ ├── Alloc.h │ │ │ ├── Bcj2.c │ │ │ ├── Bcj2.h │ │ │ ├── Bcj2Enc.c │ │ │ ├── Blake2.h │ │ │ ├── Blake2s.c │ │ │ ├── Bra.c │ │ │ ├── Bra.h │ │ │ ├── Bra86.c │ │ │ ├── BraIA64.c │ │ │ ├── BwtSort.c │ │ │ ├── BwtSort.h │ │ │ ├── Compiler.h │ │ │ ├── CpuArch.c │ │ │ ├── CpuArch.h │ │ │ ├── Delta.c │ │ │ ├── Delta.h │ │ │ ├── HuffEnc.c │ │ │ ├── HuffEnc.h │ │ │ ├── LzFind.c │ │ │ ├── LzFind.h │ │ │ ├── LzFindMt.c │ │ │ ├── LzFindMt.h │ │ │ ├── LzHash.h │ │ │ ├── Lzma2Dec.c │ │ │ ├── Lzma2Dec.h │ │ │ ├── Lzma2Enc.c │ │ │ ├── Lzma2Enc.h │ │ │ ├── Lzma86.h │ │ │ ├── Lzma86Dec.c │ │ │ ├── Lzma86Enc.c │ │ │ ├── LzmaDec.c │ │ │ ├── LzmaDec.h │ │ │ ├── LzmaEnc.c │ │ │ ├── LzmaEnc.h │ │ │ ├── MtCoder.c │ │ │ ├── MtCoder.h │ │ │ ├── Ppmd.h │ │ │ ├── Ppmd7.c │ │ │ ├── Ppmd7.h │ │ │ ├── Ppmd7Dec.c │ │ │ ├── Ppmd7Enc.c │ │ │ ├── Ppmd8.c │ │ │ ├── Ppmd8.h │ │ │ ├── Ppmd8Dec.c │ │ │ ├── Ppmd8Enc.c │ │ │ ├── Precomp.h │ │ │ ├── RotateDefs.h │ │ │ ├── Sha1.c │ │ │ ├── Sha1.h │ │ │ ├── Sha256.c │ │ │ ├── Sha256.h │ │ │ ├── Sort.c │ │ │ ├── Sort.h │ │ │ ├── Threads.c │ │ │ ├── Threads.h │ │ │ ├── Xz.c │ │ │ ├── Xz.h │ │ │ ├── XzCrc64.c │ │ │ ├── XzCrc64.h │ │ │ ├── XzCrc64Opt.c │ │ │ ├── XzDec.c │ │ │ ├── XzEnc.c │ │ │ ├── XzEnc.h │ │ │ └── XzIn.c │ │ └── CPP │ │ │ ├── 7zip │ │ │ ├── Archive │ │ │ │ ├── 7z │ │ │ │ │ ├── 7zCompressionMode.cpp │ │ │ │ │ ├── 7zCompressionMode.h │ │ │ │ │ ├── 7zDecode.cpp │ │ │ │ │ ├── 7zDecode.h │ │ │ │ │ ├── 7zEncode.cpp │ │ │ │ │ ├── 7zEncode.h │ │ │ │ │ ├── 7zExtract.cpp │ │ │ │ │ ├── 7zFolderInStream.cpp │ │ │ │ │ ├── 7zFolderInStream.h │ │ │ │ │ ├── 7zHandler.cpp │ │ │ │ │ ├── 7zHandler.h │ │ │ │ │ ├── 7zHandlerOut.cpp │ │ │ │ │ ├── 7zHeader.cpp │ │ │ │ │ ├── 7zHeader.h │ │ │ │ │ ├── 7zIn.cpp │ │ │ │ │ ├── 7zIn.h │ │ │ │ │ ├── 7zItem.h │ │ │ │ │ ├── 7zOut.cpp │ │ │ │ │ ├── 7zOut.h │ │ │ │ │ ├── 7zProperties.cpp │ │ │ │ │ ├── 7zProperties.h │ │ │ │ │ ├── 7zRegister.cpp │ │ │ │ │ ├── 7zSpecStream.cpp │ │ │ │ │ ├── 7zSpecStream.h │ │ │ │ │ ├── 7zUpdate.cpp │ │ │ │ │ └── 7zUpdate.h │ │ │ │ ├── ApmHandler.cpp │ │ │ │ ├── ArHandler.cpp │ │ │ │ ├── ArjHandler.cpp │ │ │ │ ├── Bz2Handler.cpp │ │ │ │ ├── Cab │ │ │ │ │ ├── CabBlockInStream.cpp │ │ │ │ │ ├── CabBlockInStream.h │ │ │ │ │ ├── CabHandler.cpp │ │ │ │ │ ├── CabHandler.h │ │ │ │ │ ├── CabHeader.cpp │ │ │ │ │ ├── CabHeader.h │ │ │ │ │ ├── CabIn.cpp │ │ │ │ │ ├── CabIn.h │ │ │ │ │ ├── CabItem.h │ │ │ │ │ └── CabRegister.cpp │ │ │ │ ├── Chm │ │ │ │ │ ├── ChmHandler.cpp │ │ │ │ │ ├── ChmHandler.h │ │ │ │ │ ├── ChmIn.cpp │ │ │ │ │ └── ChmIn.h │ │ │ │ ├── ComHandler.cpp │ │ │ │ ├── Common │ │ │ │ │ ├── CoderMixer2.cpp │ │ │ │ │ ├── CoderMixer2.h │ │ │ │ │ ├── DummyOutStream.cpp │ │ │ │ │ ├── DummyOutStream.h │ │ │ │ │ ├── FindSignature.cpp │ │ │ │ │ ├── FindSignature.h │ │ │ │ │ ├── HandlerOut.cpp │ │ │ │ │ ├── HandlerOut.h │ │ │ │ │ ├── InStreamWithCRC.cpp │ │ │ │ │ ├── InStreamWithCRC.h │ │ │ │ │ ├── ItemNameUtils.cpp │ │ │ │ │ ├── ItemNameUtils.h │ │ │ │ │ ├── MultiStream.cpp │ │ │ │ │ ├── MultiStream.h │ │ │ │ │ ├── OutStreamWithCRC.cpp │ │ │ │ │ ├── OutStreamWithCRC.h │ │ │ │ │ ├── OutStreamWithSha1.cpp │ │ │ │ │ ├── OutStreamWithSha1.h │ │ │ │ │ ├── ParseProperties.cpp │ │ │ │ │ └── ParseProperties.h │ │ │ │ ├── CpioHandler.cpp │ │ │ │ ├── CramfsHandler.cpp │ │ │ │ ├── DeflateProps.cpp │ │ │ │ ├── DeflateProps.h │ │ │ │ ├── DmgHandler.cpp │ │ │ │ ├── ElfHandler.cpp │ │ │ │ ├── ExtHandler.cpp │ │ │ │ ├── FatHandler.cpp │ │ │ │ ├── FlvHandler.cpp │ │ │ │ ├── GptHandler.cpp │ │ │ │ ├── GzHandler.cpp │ │ │ │ ├── HandlerCont.cpp │ │ │ │ ├── HandlerCont.h │ │ │ │ ├── HfsHandler.cpp │ │ │ │ ├── IArchive.h │ │ │ │ ├── IhexHandler.cpp │ │ │ │ ├── Iso │ │ │ │ │ ├── IsoHandler.cpp │ │ │ │ │ ├── IsoHandler.h │ │ │ │ │ ├── IsoHeader.cpp │ │ │ │ │ ├── IsoHeader.h │ │ │ │ │ ├── IsoIn.cpp │ │ │ │ │ ├── IsoIn.h │ │ │ │ │ ├── IsoItem.h │ │ │ │ │ └── IsoRegister.cpp │ │ │ │ ├── LzhHandler.cpp │ │ │ │ ├── LzmaHandler.cpp │ │ │ │ ├── MachoHandler.cpp │ │ │ │ ├── MbrHandler.cpp │ │ │ │ ├── MslzHandler.cpp │ │ │ │ ├── MubHandler.cpp │ │ │ │ ├── Nsis │ │ │ │ │ ├── NsisDecode.cpp │ │ │ │ │ ├── NsisDecode.h │ │ │ │ │ ├── NsisHandler.cpp │ │ │ │ │ ├── NsisHandler.h │ │ │ │ │ ├── NsisIn.cpp │ │ │ │ │ ├── NsisIn.h │ │ │ │ │ └── NsisRegister.cpp │ │ │ │ ├── NtfsHandler.cpp │ │ │ │ ├── PeHandler.cpp │ │ │ │ ├── PpmdHandler.cpp │ │ │ │ ├── QcowHandler.cpp │ │ │ │ ├── Rar │ │ │ │ │ ├── Rar5Handler.cpp │ │ │ │ │ ├── Rar5Handler.h │ │ │ │ │ ├── RarHandler.cpp │ │ │ │ │ ├── RarHandler.h │ │ │ │ │ ├── RarHeader.h │ │ │ │ │ ├── RarItem.h │ │ │ │ │ └── RarVol.h │ │ │ │ ├── RpmHandler.cpp │ │ │ │ ├── SplitHandler.cpp │ │ │ │ ├── SquashfsHandler.cpp │ │ │ │ ├── SwfHandler.cpp │ │ │ │ ├── Tar │ │ │ │ │ ├── TarHandler.cpp │ │ │ │ │ ├── TarHandler.h │ │ │ │ │ ├── TarHandlerOut.cpp │ │ │ │ │ ├── TarHeader.cpp │ │ │ │ │ ├── TarHeader.h │ │ │ │ │ ├── TarIn.cpp │ │ │ │ │ ├── TarIn.h │ │ │ │ │ ├── TarItem.h │ │ │ │ │ ├── TarOut.cpp │ │ │ │ │ ├── TarOut.h │ │ │ │ │ ├── TarRegister.cpp │ │ │ │ │ ├── TarUpdate.cpp │ │ │ │ │ └── TarUpdate.h │ │ │ │ ├── Udf │ │ │ │ │ ├── UdfHandler.cpp │ │ │ │ │ ├── UdfHandler.h │ │ │ │ │ ├── UdfIn.cpp │ │ │ │ │ └── UdfIn.h │ │ │ │ ├── UefiHandler.cpp │ │ │ │ ├── VdiHandler.cpp │ │ │ │ ├── VhdHandler.cpp │ │ │ │ ├── VmdkHandler.cpp │ │ │ │ ├── Wim │ │ │ │ │ ├── WimHandler.cpp │ │ │ │ │ ├── WimHandler.h │ │ │ │ │ ├── WimHandlerOut.cpp │ │ │ │ │ ├── WimIn.cpp │ │ │ │ │ ├── WimIn.h │ │ │ │ │ └── WimRegister.cpp │ │ │ │ ├── XarHandler.cpp │ │ │ │ ├── XzHandler.cpp │ │ │ │ ├── XzHandler.h │ │ │ │ ├── ZHandler.cpp │ │ │ │ └── Zip │ │ │ │ │ ├── ZipAddCommon.cpp │ │ │ │ │ ├── ZipAddCommon.h │ │ │ │ │ ├── ZipCompressionMode.h │ │ │ │ │ ├── ZipHandler.cpp │ │ │ │ │ ├── ZipHandler.h │ │ │ │ │ ├── ZipHandlerOut.cpp │ │ │ │ │ ├── ZipHeader.h │ │ │ │ │ ├── ZipIn.cpp │ │ │ │ │ ├── ZipIn.h │ │ │ │ │ ├── ZipItem.cpp │ │ │ │ │ ├── ZipItem.h │ │ │ │ │ ├── ZipOut.cpp │ │ │ │ │ ├── ZipOut.h │ │ │ │ │ ├── ZipRegister.cpp │ │ │ │ │ ├── ZipUpdate.cpp │ │ │ │ │ └── ZipUpdate.h │ │ │ ├── Common │ │ │ │ ├── CWrappers.cpp │ │ │ │ ├── CWrappers.h │ │ │ │ ├── CreateCoder.cpp │ │ │ │ ├── CreateCoder.h │ │ │ │ ├── FilePathAutoRename.cpp │ │ │ │ ├── FilePathAutoRename.h │ │ │ │ ├── FileStreams.cpp │ │ │ │ ├── FileStreams.h │ │ │ │ ├── FilterCoder.cpp │ │ │ │ ├── FilterCoder.h │ │ │ │ ├── InBuffer.cpp │ │ │ │ ├── InBuffer.h │ │ │ │ ├── InOutTempBuffer.cpp │ │ │ │ ├── InOutTempBuffer.h │ │ │ │ ├── LimitedStreams.cpp │ │ │ │ ├── LimitedStreams.h │ │ │ │ ├── MemBlocks.cpp │ │ │ │ ├── MemBlocks.h │ │ │ │ ├── MethodId.cpp │ │ │ │ ├── MethodId.h │ │ │ │ ├── MethodProps.cpp │ │ │ │ ├── MethodProps.h │ │ │ │ ├── OffsetStream.cpp │ │ │ │ ├── OffsetStream.h │ │ │ │ ├── OutBuffer.cpp │ │ │ │ ├── OutBuffer.h │ │ │ │ ├── OutMemStream.cpp │ │ │ │ ├── OutMemStream.h │ │ │ │ ├── ProgressMt.cpp │ │ │ │ ├── ProgressMt.h │ │ │ │ ├── ProgressUtils.cpp │ │ │ │ ├── ProgressUtils.h │ │ │ │ ├── PropId.cpp │ │ │ │ ├── RegisterArc.h │ │ │ │ ├── RegisterCodec.h │ │ │ │ ├── StreamBinder.cpp │ │ │ │ ├── StreamBinder.h │ │ │ │ ├── StreamObjects.cpp │ │ │ │ ├── StreamObjects.h │ │ │ │ ├── StreamUtils.cpp │ │ │ │ ├── StreamUtils.h │ │ │ │ ├── UniqBlocks.cpp │ │ │ │ ├── UniqBlocks.h │ │ │ │ ├── VirtThread.cpp │ │ │ │ └── VirtThread.h │ │ │ ├── Compress │ │ │ │ ├── BZip2Const.h │ │ │ │ ├── BZip2Crc.cpp │ │ │ │ ├── BZip2Crc.h │ │ │ │ ├── BZip2Decoder.cpp │ │ │ │ ├── BZip2Decoder.h │ │ │ │ ├── BZip2Encoder.cpp │ │ │ │ ├── BZip2Encoder.h │ │ │ │ ├── BZip2Register.cpp │ │ │ │ ├── Bcj2Coder.cpp │ │ │ │ ├── Bcj2Coder.h │ │ │ │ ├── Bcj2Register.cpp │ │ │ │ ├── BcjCoder.cpp │ │ │ │ ├── BcjCoder.h │ │ │ │ ├── BcjRegister.cpp │ │ │ │ ├── BitlDecoder.cpp │ │ │ │ ├── BitlDecoder.h │ │ │ │ ├── BitlEncoder.h │ │ │ │ ├── BitmDecoder.h │ │ │ │ ├── BitmEncoder.h │ │ │ │ ├── BranchMisc.cpp │ │ │ │ ├── BranchMisc.h │ │ │ │ ├── BranchRegister.cpp │ │ │ │ ├── ByteSwap.cpp │ │ │ │ ├── CodecExports.cpp │ │ │ │ ├── CopyCoder.cpp │ │ │ │ ├── CopyCoder.h │ │ │ │ ├── CopyRegister.cpp │ │ │ │ ├── Deflate64Register.cpp │ │ │ │ ├── DeflateConst.h │ │ │ │ ├── DeflateDecoder.cpp │ │ │ │ ├── DeflateDecoder.h │ │ │ │ ├── DeflateEncoder.cpp │ │ │ │ ├── DeflateEncoder.h │ │ │ │ ├── DeflateRegister.cpp │ │ │ │ ├── DeltaFilter.cpp │ │ │ │ ├── HuffmanDecoder.h │ │ │ │ ├── ImplodeDecoder.cpp │ │ │ │ ├── ImplodeDecoder.h │ │ │ │ ├── ImplodeHuffmanDecoder.cpp │ │ │ │ ├── ImplodeHuffmanDecoder.h │ │ │ │ ├── LzOutWindow.cpp │ │ │ │ ├── LzOutWindow.h │ │ │ │ ├── LzhDecoder.cpp │ │ │ │ ├── LzhDecoder.h │ │ │ │ ├── Lzma2Decoder.cpp │ │ │ │ ├── Lzma2Decoder.h │ │ │ │ ├── Lzma2Encoder.cpp │ │ │ │ ├── Lzma2Encoder.h │ │ │ │ ├── Lzma2Register.cpp │ │ │ │ ├── LzmaDecoder.cpp │ │ │ │ ├── LzmaDecoder.h │ │ │ │ ├── LzmaEncoder.cpp │ │ │ │ ├── LzmaEncoder.h │ │ │ │ ├── LzmaRegister.cpp │ │ │ │ ├── LzmsDecoder.cpp │ │ │ │ ├── LzmsDecoder.h │ │ │ │ ├── Lzx.h │ │ │ │ ├── LzxDecoder.cpp │ │ │ │ ├── LzxDecoder.h │ │ │ │ ├── Mtf8.h │ │ │ │ ├── PpmdDecoder.cpp │ │ │ │ ├── PpmdDecoder.h │ │ │ │ ├── PpmdEncoder.cpp │ │ │ │ ├── PpmdEncoder.h │ │ │ │ ├── PpmdRegister.cpp │ │ │ │ ├── PpmdZip.cpp │ │ │ │ ├── PpmdZip.h │ │ │ │ ├── QuantumDecoder.cpp │ │ │ │ ├── QuantumDecoder.h │ │ │ │ ├── Rar1Decoder.cpp │ │ │ │ ├── Rar1Decoder.h │ │ │ │ ├── Rar2Decoder.cpp │ │ │ │ ├── Rar2Decoder.h │ │ │ │ ├── Rar3Decoder.cpp │ │ │ │ ├── Rar3Decoder.h │ │ │ │ ├── Rar3Vm.cpp │ │ │ │ ├── Rar3Vm.h │ │ │ │ ├── Rar5Decoder.cpp │ │ │ │ ├── Rar5Decoder.h │ │ │ │ ├── RarCodecsRegister.cpp │ │ │ │ ├── ShrinkDecoder.cpp │ │ │ │ ├── ShrinkDecoder.h │ │ │ │ ├── XpressDecoder.cpp │ │ │ │ ├── XpressDecoder.h │ │ │ │ ├── ZDecoder.cpp │ │ │ │ ├── ZDecoder.h │ │ │ │ ├── ZlibDecoder.cpp │ │ │ │ ├── ZlibDecoder.h │ │ │ │ ├── ZlibEncoder.cpp │ │ │ │ └── ZlibEncoder.h │ │ │ ├── Crypto │ │ │ │ ├── 7zAes.cpp │ │ │ │ ├── 7zAes.h │ │ │ │ ├── 7zAesRegister.cpp │ │ │ │ ├── HmacSha1.cpp │ │ │ │ ├── HmacSha1.h │ │ │ │ ├── HmacSha256.cpp │ │ │ │ ├── HmacSha256.h │ │ │ │ ├── MyAes.cpp │ │ │ │ ├── MyAes.h │ │ │ │ ├── MyAesReg.cpp │ │ │ │ ├── Pbkdf2HmacSha1.cpp │ │ │ │ ├── Pbkdf2HmacSha1.h │ │ │ │ ├── RandGen.cpp │ │ │ │ ├── RandGen.h │ │ │ │ ├── Rar20Crypto.cpp │ │ │ │ ├── Rar20Crypto.h │ │ │ │ ├── Rar5Aes.cpp │ │ │ │ ├── Rar5Aes.h │ │ │ │ ├── RarAes.cpp │ │ │ │ ├── RarAes.h │ │ │ │ ├── Sha1Cls.h │ │ │ │ ├── WzAes.cpp │ │ │ │ ├── WzAes.h │ │ │ │ ├── ZipCrypto.cpp │ │ │ │ ├── ZipCrypto.h │ │ │ │ ├── ZipStrong.cpp │ │ │ │ └── ZipStrong.h │ │ │ ├── ICoder.h │ │ │ ├── IDecl.h │ │ │ ├── IPassword.h │ │ │ ├── IProgress.h │ │ │ ├── IStream.h │ │ │ ├── MyVersion.h │ │ │ ├── PropID.h │ │ │ └── UI │ │ │ │ ├── Common │ │ │ │ ├── ArchiveCommandLine.cpp │ │ │ │ ├── ArchiveCommandLine.h │ │ │ │ ├── ArchiveExtractCallback.cpp │ │ │ │ ├── ArchiveExtractCallback.h │ │ │ │ ├── ArchiveName.cpp │ │ │ │ ├── ArchiveName.h │ │ │ │ ├── ArchiveOpenCallback.cpp │ │ │ │ ├── ArchiveOpenCallback.h │ │ │ │ ├── Bench.cpp │ │ │ │ ├── Bench.h │ │ │ │ ├── DefaultName.cpp │ │ │ │ ├── DefaultName.h │ │ │ │ ├── DirItem.h │ │ │ │ ├── EnumDirItems.cpp │ │ │ │ ├── EnumDirItems.h │ │ │ │ ├── ExitCode.h │ │ │ │ ├── Extract.cpp │ │ │ │ ├── Extract.h │ │ │ │ ├── ExtractMode.h │ │ │ │ ├── ExtractingFilePath.cpp │ │ │ │ ├── ExtractingFilePath.h │ │ │ │ ├── HashCalc.cpp │ │ │ │ ├── HashCalc.h │ │ │ │ ├── IFileExtractCallback.h │ │ │ │ ├── LoadCodecs.cpp │ │ │ │ ├── LoadCodecs.h │ │ │ │ ├── OpenArchive.cpp │ │ │ │ ├── OpenArchive.h │ │ │ │ ├── PropIDUtils.cpp │ │ │ │ ├── PropIDUtils.h │ │ │ │ ├── Property.h │ │ │ │ ├── SetProperties.cpp │ │ │ │ ├── SetProperties.h │ │ │ │ ├── SortUtils.cpp │ │ │ │ ├── SortUtils.h │ │ │ │ ├── TempFiles.cpp │ │ │ │ ├── TempFiles.h │ │ │ │ ├── Update.cpp │ │ │ │ ├── Update.h │ │ │ │ ├── UpdateAction.cpp │ │ │ │ ├── UpdateAction.h │ │ │ │ ├── UpdateCallback.cpp │ │ │ │ ├── UpdateCallback.h │ │ │ │ ├── UpdatePair.cpp │ │ │ │ ├── UpdatePair.h │ │ │ │ ├── UpdateProduce.cpp │ │ │ │ └── UpdateProduce.h │ │ │ │ └── Console │ │ │ │ ├── BenchCon.cpp │ │ │ │ ├── BenchCon.h │ │ │ │ ├── ConsoleClose.cpp │ │ │ │ ├── ConsoleClose.h │ │ │ │ ├── ExtractCallbackConsole.cpp │ │ │ │ ├── ExtractCallbackConsole.h │ │ │ │ ├── HashCon.cpp │ │ │ │ ├── HashCon.h │ │ │ │ ├── List.cpp │ │ │ │ ├── List.h │ │ │ │ ├── Main.cpp │ │ │ │ ├── MainAr.cpp │ │ │ │ ├── OpenCallbackConsole.cpp │ │ │ │ ├── OpenCallbackConsole.h │ │ │ │ ├── PercentPrinter.cpp │ │ │ │ ├── PercentPrinter.h │ │ │ │ ├── UpdateCallbackConsole.cpp │ │ │ │ ├── UpdateCallbackConsole.h │ │ │ │ ├── UserInputUtils.cpp │ │ │ │ └── UserInputUtils.h │ │ │ ├── Common │ │ │ ├── AutoPtr.h │ │ │ ├── CRC.cpp │ │ │ ├── C_FileIO.cpp │ │ │ ├── C_FileIO.h │ │ │ ├── ComTry.h │ │ │ ├── CommandLineParser.cpp │ │ │ ├── CommandLineParser.h │ │ │ ├── Common.h │ │ │ ├── CrcReg.cpp │ │ │ ├── Defs.h │ │ │ ├── DynLimBuf.cpp │ │ │ ├── DynLimBuf.h │ │ │ ├── DynamicBuffer.h │ │ │ ├── IntToString.cpp │ │ │ ├── IntToString.h │ │ │ ├── Lang.cpp │ │ │ ├── Lang.h │ │ │ ├── ListFileUtils.cpp │ │ │ ├── ListFileUtils.h │ │ │ ├── MyBuffer.h │ │ │ ├── MyCom.h │ │ │ ├── MyException.h │ │ │ ├── MyGuidDef.h │ │ │ ├── MyInitGuid.h │ │ │ ├── MyLinux.h │ │ │ ├── MyMap.cpp │ │ │ ├── MyMap.h │ │ │ ├── MyString.cpp │ │ │ ├── MyString.h │ │ │ ├── MyTypes.h │ │ │ ├── MyUnknown.h │ │ │ ├── MyVector.cpp │ │ │ ├── MyVector.h │ │ │ ├── MyWindows.cpp │ │ │ ├── MyWindows.h │ │ │ ├── MyXml.cpp │ │ │ ├── MyXml.h │ │ │ ├── NewHandler.cpp │ │ │ ├── NewHandler.h │ │ │ ├── Random.h │ │ │ ├── Sha1Reg.cpp │ │ │ ├── Sha256Reg.cpp │ │ │ ├── StdInStream.cpp │ │ │ ├── StdInStream.h │ │ │ ├── StdOutStream.cpp │ │ │ ├── StdOutStream.h │ │ │ ├── StringConvert.cpp │ │ │ ├── StringConvert.h │ │ │ ├── StringToInt.cpp │ │ │ ├── StringToInt.h │ │ │ ├── TextConfig.cpp │ │ │ ├── TextConfig.h │ │ │ ├── UTFConvert.cpp │ │ │ ├── UTFConvert.h │ │ │ ├── Wildcard.cpp │ │ │ ├── Wildcard.h │ │ │ └── XzCrc64Reg.cpp │ │ │ ├── Windows │ │ │ ├── DLL.cpp │ │ │ ├── DLL.h │ │ │ ├── Defs.h │ │ │ ├── ErrorMsg.cpp │ │ │ ├── ErrorMsg.h │ │ │ ├── FileDir.cpp │ │ │ ├── FileDir.h │ │ │ ├── FileFind.cpp │ │ │ ├── FileFind.h │ │ │ ├── FileIO.cpp │ │ │ ├── FileIO.h │ │ │ ├── FileName.cpp │ │ │ ├── FileName.h │ │ │ ├── Menu.h │ │ │ ├── NtCheck.h │ │ │ ├── PropVariant.cpp │ │ │ ├── PropVariant.h │ │ │ ├── PropVariantConv.cpp │ │ │ ├── PropVariantConv.h │ │ │ ├── PropVariantUtils.cpp │ │ │ ├── PropVariantUtils.h │ │ │ ├── Synchronization.cpp │ │ │ ├── Synchronization.h │ │ │ ├── Synchronization2.h │ │ │ ├── System.cpp │ │ │ ├── System.h │ │ │ ├── Thread.h │ │ │ ├── TimeUtils.cpp │ │ │ └── TimeUtils.h │ │ │ ├── include_windows │ │ │ ├── basetyps.h │ │ │ ├── tchar.h │ │ │ └── windows.h │ │ │ └── myWindows │ │ │ ├── StdAfx.h │ │ │ ├── config.h │ │ │ ├── initguid.h │ │ │ ├── myAddExeFlag.cpp │ │ │ ├── myPrivate.h │ │ │ ├── mySplitCommandLine.cpp │ │ │ └── wine_date_and_time.cpp │ └── str2args │ │ ├── str2args.cpp │ │ └── str2args.h │ ├── java │ └── com │ │ └── hzy │ │ └── libp7zip │ │ ├── ExitCode.java │ │ └── P7ZipApi.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-vendored 2 | *.kt linguist-vendored=false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /.idea 4 | .DS_Store 5 | /build 6 | /captures 7 | .externalNativeBuild 8 | .cxx 9 | /app/build 10 | *.log 11 | local.properties 12 | -------------------------------------------------------------------------------- /Images/App-Icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/arch_arm32/assets/python.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/arch_arm32/assets/python.7z -------------------------------------------------------------------------------- /app/arch_arm64-v8a/assets/python.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/arch_arm64-v8a/assets/python.7z -------------------------------------------------------------------------------- /app/arch_x86/assets/python.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/arch_x86/assets/python.7z -------------------------------------------------------------------------------- /app/arch_x86_64/assets/python.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/arch_x86_64/assets/python.7z -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/github/psicodes/ktxpy/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.wildzeus.pythonktx", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app/src/main/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/README.md -------------------------------------------------------------------------------- /app/src/main/assets/JetBrainsMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/assets/JetBrainsMono-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/assets/Roboto-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/RobotoMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/assets/RobotoMono-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/Samples/PatternPrinter.py: -------------------------------------------------------------------------------- 1 | n=int(input("Number of Design : ")) 2 | for i in range(n): 3 | for m in range(i): 4 | print("*", end= " ") 5 | print("\n") -------------------------------------------------------------------------------- /app/src/main/assets/Samples/inputFromUser.py: -------------------------------------------------------------------------------- 1 | #To take Input from user we use input("") function 2 | #The value passed in input function will be shown as output before taking input 3 | #for example-> 4 | sample=input("Enter your name: ") 5 | print(f"Hello {sample}") -------------------------------------------------------------------------------- /app/src/main/assets/Samples/loops.py: -------------------------------------------------------------------------------- 1 | ''' 2 | while loop 3 | continues to execute command until provided condition is false 4 | ''' 5 | a=0 6 | while(a<100): 7 | print(a) 8 | a+=1 9 | ''' 10 | for loop 11 | used mainly for indexing arrays etc 12 | ''' 13 | Subject=["Science","Math","Hindi","English","SSt"] 14 | for s in Subject: 15 | print(s) -------------------------------------------------------------------------------- /app/src/main/assets/Samples/numberGuesser.py: -------------------------------------------------------------------------------- 1 | import random 2 | def numberGuesserGame(): 3 | r:int=random.randint(0, 15) 4 | gameState=True 5 | while(gameState): 6 | a:int=int(input("Guess The Number Between 0 to 15 : ")) 7 | if (r-a)<0: 8 | print("\ntry smaller number") 9 | elif(r-a)>0: 10 | print("\ntry bigger number") 11 | else: 12 | print("\nYou Won") 13 | gameState=False 14 | if __name__=="__main__": 15 | numberGuesserGame() 16 | -------------------------------------------------------------------------------- /app/src/main/assets/Samples/printAWord.py: -------------------------------------------------------------------------------- 1 | #Anything you will pass to print parameter will be provided as output 2 | print("Hello world") -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/wildzeus/pythonktx/ui/LayoutComponents/DropDownMenu/DropDownMenuItem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2022-2023 PsiCodes 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | package com.wildzeus.pythonktx.ui.LayoutComponents.DropDownMenu 18 | 19 | data class DropDownMenuItem( 20 | val Title:String, 21 | val Icon:Int, 22 | val Clickable:()->Unit 23 | ) 24 | -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/Application.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy 2 | 3 | import com.google.android.material.color.DynamicColors 4 | 5 | class Application : android.app.Application() { 6 | override fun onCreate() { 7 | super.onCreate() 8 | DynamicColors.applyToActivitiesIfAvailable(this) 9 | } 10 | } -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/ui/layoutComponents/MenuItem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2022-2023 PsiCodes 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | package github.psicodes.ktxpy.ui.layoutComponents 18 | 19 | data class MenuItem( 20 | val id:String, val title:String, val resID:Int, val clickable:()->Unit 21 | ) 22 | -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple80 = Color(0xFFD0BCFF) 6 | val PurpleGrey80 = Color(0xFFCCC2DC) 7 | val Pink80 = Color(0xFFEFB8C8) 8 | 9 | val Purple40 = Color(0xFF6650a4) 10 | val PurpleGrey40 = Color(0xFF625b71) 11 | val Pink40 = Color(0xFF7D5260) -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/ui/theme/EditorTheme.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy.ui.theme 2 | 3 | class EditorTheme { 4 | companion object { 5 | const val AbyssColor: String = "Abyss Color" 6 | const val DarculaTheme: String = "Dracula Theme" 7 | const val QuietLight: String = "Quiet Light" 8 | } 9 | } -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy.ui.theme 2 | 3 | import androidx.compose.material3.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/utils/Keys.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy.utils 2 | 3 | object Keys { 4 | const val KEY_FILE_PATH = "file_path" 5 | const val IS_SHELL_MODE_KEY = "is_shell_mode" 6 | } -------------------------------------------------------------------------------- /app/src/main/java/github/psicodes/ktxpy/utils/PermissionManageExternal.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy.utils 2 | 3 | import android.app.Activity 4 | import android.content.Intent 5 | import android.net.Uri 6 | import android.provider.Settings 7 | import androidx.annotation.RequiresApi 8 | 9 | @RequiresApi(30) 10 | object PermissionManageExternal { 11 | fun request(activity: Activity): Boolean { 12 | try { 13 | val uri = Uri.parse("package:" + github.psicodes.ktxpy.BuildConfig.APPLICATION_ID) 14 | val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri) 15 | activity.startActivity(intent) 16 | return true 17 | } catch (ignore: Exception) { 18 | } 19 | try { 20 | val intent = Intent() 21 | intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION 22 | activity.startActivity(intent) 23 | return true 24 | } catch (ignore: Exception) { 25 | } 26 | return false 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/main/jniLibs/arm64-v8a/libpython3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/jniLibs/arm64-v8a/libpython3.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libpython3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/jniLibs/armeabi-v7a/libpython3.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/x86/libpython3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/jniLibs/x86/libpython3.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/x86_64/libpython3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/jniLibs/x86_64/libpython3.so -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/scrollbar_track_icon.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/undo_icon.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/about_icon.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/add_file_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/app_icon.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/app_icon_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/back_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/code_run_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/coming_soon_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/create_file_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/current_files_icon.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/file_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/file_open_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/folder_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/interactive_mode_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/library_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/menu_icon.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sample_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/scrollbar_thumb_icon.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/terminal_icon.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_save_icon.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/theme_selector_icon.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/white_cursor_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/font/custom_sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/res/font/custom_sans.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/jetbrainsmono_medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/res/font/jetbrainsmono_medium.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_condensed_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/res/font/roboto_condensed_bold.ttf -------------------------------------------------------------------------------- /app/src/main/res/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/res/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/playstore-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/app/src/main/res/playstore-icon.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 8dp 4 | 4dp 5 | 16dp 6 | 7 | 16dp 8 | 16dp 9 | 16dp 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #000000 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Ktxpy 3 | Undo 4 | Redo 5 | Select Theme 6 | Save File 7 | Add File 8 | Access to \"External Storage\" is required to manage its files 9 | run code 10 | extra menu 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/test/java/github/psicodes/ktxpy/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package github.psicodes.ktxpy 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | compose_version = '1.1.1' 4 | } 5 | project.ext{ 6 | compileSdkVersion = 32 7 | targetSdkVersion = 33 8 | minSdkVersion = 26 9 | ndkVersion = '25.1.8937393' 10 | } 11 | }// Top-level build file where you can add configuration options common to all sub-projects/modules. 12 | plugins { 13 | id 'com.android.application' version '8.1.2' apply false 14 | id 'com.android.library' version '8.1.2' apply false 15 | id 'org.jetbrains.kotlin.android' version '1.9.10' apply false 16 | id 'com.google.dagger.hilt.android' version '2.44' apply false 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## For more details on how to configure your build environment visit 2 | # http://www.gradle.org/docs/current/userguide/build_environment.html 3 | # 4 | # Specifies the JVM arguments used for the daemon process. 5 | # The setting is particularly useful for tweaking memory settings. 6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 8 | # 9 | # When configured, Gradle will run in incubating parallel mode. 10 | # This option should only be used with decoupled projects. More details, visit 11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 | # org.gradle.parallel=true 13 | #Sun Oct 29 10:49:03 IST 2023 14 | android.defaults.buildfeatures.buildconfig=true 15 | android.nonFinalResIds=false 16 | android.nonTransitiveRClass=true 17 | android.useAndroidX=true 18 | kotlin.code.style=official 19 | org.gradle.jvmargs=-Xmx1024M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -Dfile.encoding\=UTF-8 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsiCodes/ktxpy/ac19f0a4599a991d032d92d9ef39c555d8cec9dc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 18 15:14:33 IST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /libp7zip/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml 3 | .externalNativeBuild 4 | .cxx 5 | -------------------------------------------------------------------------------- /libp7zip/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdk 34 5 | 6 | defaultConfig { 7 | minSdkVersion 26 8 | targetSdkVersion 34 9 | externalNativeBuild { 10 | cmake { 11 | arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-18' 12 | } 13 | } 14 | } 15 | buildTypes { 16 | debug { 17 | externalNativeBuild { 18 | cmake { 19 | // log switch 20 | cppFlags.add('-DNATIVE_LOG') 21 | } 22 | } 23 | } 24 | } 25 | externalNativeBuild { 26 | cmake { 27 | path 'src/main/cpp/CMakeLists.txt' 28 | } 29 | } 30 | ndkVersion '25.1.8937393' 31 | namespace 'com.hzy.libp7zip' 32 | lint { 33 | abortOnError false 34 | } 35 | } 36 | 37 | dependencies { 38 | implementation fileTree(dir: 'libs', include: ['*.jar']) 39 | } 40 | 41 | //publish { 42 | // userOrg = 'huzongyao' 43 | // groupId = 'com.hzy' 44 | // artifactId = 'libp7zip' 45 | // publishVersion = '1.7.1' 46 | // desc = 'An Android compress and extract library support popular compression format such as rar, zip, tar, lzma. based on p7zip.' 47 | // website = 'https://github.com/hzy3774/AndroidP7zip' 48 | //} -------------------------------------------------------------------------------- /libp7zip/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/huzongyao/software/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. You should either keep the default value or only pass a 3 | # value of 3.4.0 or lower. 4 | # by huzongyao 5 | 6 | cmake_minimum_required(VERSION 3.4.1) 7 | 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID_NDK -fexceptions -DNDEBUG -D_REENTRANT -DENV_UNIX") 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBREAK_HANDLER -DUNICODE -D_UNICODE -DUNIX_USE_WIN_FILE -fPIC") 10 | 11 | add_definitions("-w") 12 | add_definitions("-fvisibility=hidden") 13 | add_definitions("-Wno-error=c++11-narrowing") 14 | 15 | # Creates and names a library, sets it as either STATIC 16 | # or SHARED, and provides the relative paths to its source code. 17 | # You can define multiple libraries, and CMake builds it for you. 18 | # Gradle automatically packages shared libraries with your APK. 19 | file(GLOB_RECURSE NATIVE_SRCS *.c *.cpp) 20 | 21 | include_directories(./ p7zip/CPP 22 | p7zip/CPP/Common 23 | p7zip/CPP/myWindows 24 | p7zip/CPP/include_windows) 25 | 26 | add_library(p7zip SHARED ${NATIVE_SRCS}) 27 | 28 | # Specifies libraries CMake should link to your target library. You 29 | # can link multiple libraries, such as libraries you define in the 30 | # build script, prebuilt third-party libraries, or system libraries. 31 | target_link_libraries(p7zip log) 32 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/cmd/command.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "command.h" 4 | 5 | int executeCommand(const char *cmd) { 6 | int argc = 0; 7 | char temp[ARGC_MAX][ARGV_LEN_MAX]; 8 | char *argv[ARGC_MAX]; 9 | if (!str2args(cmd, temp, &argc)) { 10 | return 7; 11 | } 12 | for (int i = 0; i < argc; i++) { 13 | argv[i] = temp[i]; 14 | LOGD("arg[%d]:[%s]", i, argv[i]); 15 | } 16 | return main(argc, argv); 17 | } -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/cmd/command.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROIDP7ZIP_COMMAND_H 2 | #define ANDROIDP7ZIP_COMMAND_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | int MY_CDECL 11 | main( 12 | #ifndef _WIN32 13 | int numArgs, char *args[] 14 | #endif 15 | ); 16 | 17 | int executeCommand(const char *cmd); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/ndkhelper.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROIDUN7ZIP_NDKHELPER_H 2 | #define ANDROIDUN7ZIP_NDKHELPER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include <7zip/MyVersion.h> 11 | 12 | #ifdef NATIVE_LOG 13 | #define LOG_TAG "NATIVE.LOG" 14 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 15 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) 16 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) 17 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 18 | #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG,__VA_ARGS__) 19 | #else 20 | #define LOGD(...) do{}while(0) 21 | #define LOGI(...) do{}while(0) 22 | #define LOGW(...) do{}while(0) 23 | #define LOGE(...) do{}while(0) 24 | #define LOGF(...) do{}while(0) 25 | #endif 26 | 27 | #define JNI_FUNC(X) Java_com_hzy_libp7zip_P7ZipApi_##X 28 | 29 | /** 30 | * To Get lib p7zip version info 31 | * @param env 32 | * @param type 33 | * @return 34 | */ 35 | JNIEXPORT jstring JNICALL 36 | JNI_FUNC(get7zVersionInfo)(JNIEnv *env, jclass type); 37 | 38 | /** 39 | * To execute some command with p7zip 40 | * @param env 41 | * @param type 42 | * @param command_ 43 | * @return 44 | */ 45 | JNIEXPORT jint JNICALL 46 | JNI_FUNC(executeCommand)(JNIEnv *env, jclass type, jstring command_); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | JNIEXPORT jstring JNICALL 5 | JNI_FUNC(get7zVersionInfo)(JNIEnv *env, jclass type) { 6 | return env->NewStringUTF(MY_VERSION_COPYRIGHT_DATE); 7 | } 8 | 9 | JNIEXPORT jint JNICALL 10 | JNI_FUNC(executeCommand)(JNIEnv *env, jclass type, jstring command_) { 11 | const char *command = env->GetStringUTFChars(command_, nullptr); 12 | LOGI("CMD:[%s]", command); 13 | int ret = executeCommand(command); 14 | env->ReleaseStringUTFChars(command_, command); 15 | return ret; 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/7zBuf.h: -------------------------------------------------------------------------------- 1 | /* 7zBuf.h -- Byte Buffer 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_BUF_H 5 | #define __7Z_BUF_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | Byte *data; 14 | size_t size; 15 | } CBuf; 16 | 17 | void Buf_Init(CBuf *p); 18 | int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); 19 | void Buf_Free(CBuf *p, ISzAlloc *alloc); 20 | 21 | typedef struct 22 | { 23 | Byte *data; 24 | size_t size; 25 | size_t pos; 26 | } CDynBuf; 27 | 28 | void DynBuf_Construct(CDynBuf *p); 29 | void DynBuf_SeekToBeg(CDynBuf *p); 30 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc); 31 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc); 32 | 33 | EXTERN_C_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/7zBuf2.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf2.c -- Byte Buffer 2 | 2014-08-22 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include 7 | 8 | #include "7zBuf.h" 9 | 10 | void DynBuf_Construct(CDynBuf *p) 11 | { 12 | p->data = 0; 13 | p->size = 0; 14 | p->pos = 0; 15 | } 16 | 17 | void DynBuf_SeekToBeg(CDynBuf *p) 18 | { 19 | p->pos = 0; 20 | } 21 | 22 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc) 23 | { 24 | if (size > p->size - p->pos) 25 | { 26 | size_t newSize = p->pos + size; 27 | Byte *data; 28 | newSize += newSize / 4; 29 | data = (Byte *)alloc->Alloc(alloc, newSize); 30 | if (data == 0) 31 | return 0; 32 | p->size = newSize; 33 | memcpy(data, p->data, p->pos); 34 | alloc->Free(alloc, p->data); 35 | p->data = data; 36 | } 37 | if (size != 0) 38 | { 39 | memcpy(p->data + p->pos, buf, size); 40 | p->pos += size; 41 | } 42 | return 1; 43 | } 44 | 45 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc) 46 | { 47 | alloc->Free(alloc, p->data); 48 | p->data = 0; 49 | p->size = 0; 50 | p->pos = 0; 51 | } 52 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/7zCrc.h: -------------------------------------------------------------------------------- 1 | /* 7zCrc.h -- CRC32 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_CRC_H 5 | #define __7Z_CRC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | extern UInt32 g_CrcTable[]; 12 | 13 | /* Call CrcGenerateTable one time before other CRC functions */ 14 | void MY_FAST_CALL CrcGenerateTable(void); 15 | 16 | #define CRC_INIT_VAL 0xFFFFFFFF 17 | #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) 18 | #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 19 | 20 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); 21 | UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); 22 | 23 | EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/7zVersion.h: -------------------------------------------------------------------------------- 1 | #define MY_VER_MAJOR 16 2 | #define MY_VER_MINOR 02 3 | #define MY_VER_BUILD 0 4 | #define MY_VERSION_NUMBERS "16.02" 5 | #define MY_VERSION "16.02" 6 | #define MY_DATE "2016-05-21" 7 | #undef MY_COPYRIGHT 8 | #undef MY_VERSION_COPYRIGHT_DATE 9 | #define MY_AUTHOR_NAME "Igor Pavlov" 10 | #define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" 11 | #define MY_COPYRIGHT_CR "Copyright (c) 1999-2016 Igor Pavlov" 12 | 13 | #ifdef USE_COPYRIGHT_CR 14 | #define MY_COPYRIGHT MY_COPYRIGHT_CR 15 | #else 16 | #define MY_COPYRIGHT MY_COPYRIGHT_PD 17 | #endif 18 | 19 | #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " : " MY_COPYRIGHT " : " MY_DATE 20 | 21 | #define P7ZIP_VERSION "16.02" 22 | 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Aes.h: -------------------------------------------------------------------------------- 1 | /* Aes.h -- AES encryption / decryption 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __AES_H 5 | #define __AES_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define AES_BLOCK_SIZE 16 12 | 13 | /* Call AesGenTables one time before other AES functions */ 14 | void AesGenTables(void); 15 | 16 | /* UInt32 pointers must be 16-byte aligned */ 17 | 18 | /* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */ 19 | #define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4) 20 | 21 | /* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */ 22 | /* keySize = 16 or 24 or 32 (bytes) */ 23 | typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); 24 | void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); 25 | void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize); 26 | 27 | /* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */ 28 | void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ 29 | /* data - 16-byte aligned pointer to data */ 30 | /* numBlocks - the number of 16-byte blocks in data array */ 31 | typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); 32 | extern AES_CODE_FUNC g_AesCbc_Encode; 33 | extern AES_CODE_FUNC g_AesCbc_Decode; 34 | extern AES_CODE_FUNC g_AesCtr_Code; 35 | 36 | EXTERN_C_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Alloc.h: -------------------------------------------------------------------------------- 1 | /* Alloc.h -- Memory allocation functions 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __COMMON_ALLOC_H 5 | #define __COMMON_ALLOC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void *MyAlloc(size_t size); 12 | void MyFree(void *address); 13 | 14 | void SetLargePageSize(); 15 | 16 | void *MidAlloc(size_t size); 17 | void MidFree(void *address); 18 | void *BigAlloc(size_t size); 19 | void BigFree(void *address); 20 | 21 | extern ISzAlloc g_Alloc; 22 | extern ISzAlloc g_BigAlloc; 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Blake2.h: -------------------------------------------------------------------------------- 1 | /* Blake2.h -- BLAKE2 Hash 2 | 2015-06-30 : Igor Pavlov : Public domain 3 | 2015 : Samuel Neves : Public domain */ 4 | 5 | #ifndef __BLAKE2_H 6 | #define __BLAKE2_H 7 | 8 | #include "7zTypes.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | #define BLAKE2S_BLOCK_SIZE 64 13 | #define BLAKE2S_DIGEST_SIZE 32 14 | #define BLAKE2SP_PARALLEL_DEGREE 8 15 | 16 | typedef struct 17 | { 18 | UInt32 h[8]; 19 | UInt32 t[2]; 20 | UInt32 f[2]; 21 | Byte buf[BLAKE2S_BLOCK_SIZE]; 22 | UInt32 bufPos; 23 | UInt32 lastNode_f1; 24 | UInt32 dummy[2]; /* for sizeof(CBlake2s) alignment */ 25 | } CBlake2s; 26 | 27 | /* You need to xor CBlake2s::h[i] with input parameter block after Blake2s_Init0() */ 28 | /* 29 | void Blake2s_Init0(CBlake2s *p); 30 | void Blake2s_Update(CBlake2s *p, const Byte *data, size_t size); 31 | void Blake2s_Final(CBlake2s *p, Byte *digest); 32 | */ 33 | 34 | 35 | typedef struct 36 | { 37 | CBlake2s S[BLAKE2SP_PARALLEL_DEGREE]; 38 | unsigned bufPos; 39 | } CBlake2sp; 40 | 41 | 42 | void Blake2sp_Init(CBlake2sp *p); 43 | void Blake2sp_Update(CBlake2sp *p, const Byte *data, size_t size); 44 | void Blake2sp_Final(CBlake2sp *p, Byte *digest); 45 | 46 | EXTERN_C_END 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/BwtSort.h: -------------------------------------------------------------------------------- 1 | /* BwtSort.h -- BWT block sorting 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BWT_SORT_H 5 | #define __BWT_SORT_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M */ 12 | /* #define BLOCK_SORT_EXTERNAL_FLAGS */ 13 | 14 | #ifdef BLOCK_SORT_EXTERNAL_FLAGS 15 | #define BLOCK_SORT_EXTERNAL_SIZE(blockSize) ((((blockSize) + 31) >> 5)) 16 | #else 17 | #define BLOCK_SORT_EXTERNAL_SIZE(blockSize) 0 18 | #endif 19 | 20 | #define BLOCK_SORT_BUF_SIZE(blockSize) ((blockSize) * 2 + BLOCK_SORT_EXTERNAL_SIZE(blockSize) + (1 << 16)) 21 | 22 | UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Compiler.h: -------------------------------------------------------------------------------- 1 | /* Compiler.h 2 | 2015-08-02 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_COMPILER_H 5 | #define __7Z_COMPILER_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #ifdef UNDER_CE 10 | #define RPC_NO_WINDOWS_H 11 | /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ 12 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union 13 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int 14 | #endif 15 | 16 | #if _MSC_VER >= 1300 17 | #pragma warning(disable : 4996) // This function or variable may be unsafe 18 | #else 19 | #pragma warning(disable : 4511) // copy constructor could not be generated 20 | #pragma warning(disable : 4512) // assignment operator could not be generated 21 | #pragma warning(disable : 4514) // unreferenced inline function has been removed 22 | #pragma warning(disable : 4702) // unreachable code 23 | #pragma warning(disable : 4710) // not inlined 24 | #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information 25 | #endif 26 | 27 | #endif 28 | 29 | #define UNUSED_VAR(x) (void)x; 30 | /* #define UNUSED_VAR(x) x=x; */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Delta.h: -------------------------------------------------------------------------------- 1 | /* Delta.h -- Delta converter 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __DELTA_H 5 | #define __DELTA_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define DELTA_STATE_SIZE 256 12 | 13 | void Delta_Init(Byte *state); 14 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); 15 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); 16 | 17 | EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/HuffEnc.h: -------------------------------------------------------------------------------- 1 | /* HuffEnc.h -- Huffman encoding 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __HUFF_ENC_H 5 | #define __HUFF_ENC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* 12 | Conditions: 13 | num <= 1024 = 2 ^ NUM_BITS 14 | Sum(freqs) < 4M = 2 ^ (32 - NUM_BITS) 15 | maxLen <= 16 = kMaxLen 16 | Num_Items(p) >= HUFFMAN_TEMP_SIZE(num) 17 | */ 18 | 19 | void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen); 20 | 21 | EXTERN_C_END 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Lzma86Dec.c: -------------------------------------------------------------------------------- 1 | /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder 2 | 2016-05-16 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Lzma86.h" 7 | 8 | #include "Alloc.h" 9 | #include "Bra.h" 10 | #include "LzmaDec.h" 11 | 12 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) 13 | { 14 | unsigned i; 15 | if (srcLen < LZMA86_HEADER_SIZE) 16 | return SZ_ERROR_INPUT_EOF; 17 | *unpackSize = 0; 18 | for (i = 0; i < sizeof(UInt64); i++) 19 | *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i); 20 | return SZ_OK; 21 | } 22 | 23 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen) 24 | { 25 | SRes res; 26 | int useFilter; 27 | SizeT inSizePure; 28 | ELzmaStatus status; 29 | 30 | if (*srcLen < LZMA86_HEADER_SIZE) 31 | return SZ_ERROR_INPUT_EOF; 32 | 33 | useFilter = src[0]; 34 | 35 | if (useFilter > 1) 36 | { 37 | *destLen = 0; 38 | return SZ_ERROR_UNSUPPORTED; 39 | } 40 | 41 | inSizePure = *srcLen - LZMA86_HEADER_SIZE; 42 | res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure, 43 | src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc); 44 | *srcLen = inSizePure + LZMA86_HEADER_SIZE; 45 | if (res != SZ_OK) 46 | return res; 47 | if (useFilter == 1) 48 | { 49 | UInt32 x86State; 50 | x86_Convert_Init(x86State); 51 | x86_Convert(dest, *destLen, 0, &x86State, 0); 52 | } 53 | return SZ_OK; 54 | } 55 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_PRECOMP_H 5 | #define __7Z_PRECOMP_H 6 | 7 | #include "Compiler.h" 8 | /* #include "7zTypes.h" */ 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/RotateDefs.h: -------------------------------------------------------------------------------- 1 | /* RotateDefs.h -- Rotate functions 2 | 2015-03-25 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __ROTATE_DEFS_H 5 | #define __ROTATE_DEFS_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #include 10 | 11 | /* don't use _rotl with MINGW. It can insert slow call to function. */ 12 | 13 | /* #if (_MSC_VER >= 1200) */ 14 | #pragma intrinsic(_rotl) 15 | #pragma intrinsic(_rotr) 16 | /* #endif */ 17 | 18 | #define rotlFixed(x, n) _rotl((x), (n)) 19 | #define rotrFixed(x, n) _rotr((x), (n)) 20 | 21 | #else 22 | 23 | /* new compilers can translate these macros to fast commands. */ 24 | 25 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) 26 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Sha1.h: -------------------------------------------------------------------------------- 1 | /* Sha1.h -- SHA-1 Hash 2 | 2016-05-20 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_SHA1_H 5 | #define __7Z_SHA1_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define SHA1_NUM_BLOCK_WORDS 16 12 | #define SHA1_NUM_DIGEST_WORDS 5 13 | 14 | #define SHA1_BLOCK_SIZE (SHA1_NUM_BLOCK_WORDS * 4) 15 | #define SHA1_DIGEST_SIZE (SHA1_NUM_DIGEST_WORDS * 4) 16 | 17 | typedef struct 18 | { 19 | UInt32 state[SHA1_NUM_DIGEST_WORDS]; 20 | UInt64 count; 21 | UInt32 buffer[SHA1_NUM_BLOCK_WORDS]; 22 | } CSha1; 23 | 24 | void Sha1_Init(CSha1 *p); 25 | 26 | void Sha1_GetBlockDigest(CSha1 *p, const UInt32 *data, UInt32 *destDigest); 27 | void Sha1_Update(CSha1 *p, const Byte *data, size_t size); 28 | void Sha1_Final(CSha1 *p, Byte *digest); 29 | 30 | void Sha1_Update_Rar(CSha1 *p, Byte *data, size_t size /* , int rar350Mode */); 31 | 32 | void Sha1_32_PrepareBlock(const CSha1 *p, UInt32 *block, unsigned size); 33 | void Sha1_32_Update(CSha1 *p, const UInt32 *data, size_t size); 34 | void Sha1_32_Final(CSha1 *p, UInt32 *digest); 35 | 36 | EXTERN_C_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Sha256.h: -------------------------------------------------------------------------------- 1 | /* Sha256.h -- SHA-256 Hash 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __CRYPTO_SHA256_H 5 | #define __CRYPTO_SHA256_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define SHA256_DIGEST_SIZE 32 12 | 13 | typedef struct 14 | { 15 | UInt32 state[8]; 16 | UInt64 count; 17 | Byte buffer[64]; 18 | } CSha256; 19 | 20 | void Sha256_Init(CSha256 *p); 21 | void Sha256_Update(CSha256 *p, const Byte *data, size_t size); 22 | void Sha256_Final(CSha256 *p, Byte *digest); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/Sort.h: -------------------------------------------------------------------------------- 1 | /* Sort.h -- Sort functions 2 | 2014-04-05 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_SORT_H 5 | #define __7Z_SORT_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void HeapSort(UInt32 *p, size_t size); 12 | void HeapSort64(UInt64 *p, size_t size); 13 | 14 | /* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */ 15 | 16 | EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/XzCrc64.h: -------------------------------------------------------------------------------- 1 | /* XzCrc64.h -- CRC64 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_CRC64_H 5 | #define __XZ_CRC64_H 6 | 7 | #include 8 | 9 | #include "7zTypes.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | extern UInt64 g_Crc64Table[]; 14 | 15 | void MY_FAST_CALL Crc64GenerateTable(void); 16 | 17 | #define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF) 18 | #define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL) 19 | #define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 20 | 21 | UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size); 22 | UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/C/XzEnc.h: -------------------------------------------------------------------------------- 1 | /* XzEnc.h -- Xz Encode 2 | 2011-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_ENC_H 5 | #define __XZ_ENC_H 6 | 7 | #include "Lzma2Enc.h" 8 | 9 | #include "Xz.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | typedef struct 14 | { 15 | UInt32 id; 16 | UInt32 delta; 17 | UInt32 ip; 18 | int ipDefined; 19 | } CXzFilterProps; 20 | 21 | void XzFilterProps_Init(CXzFilterProps *p); 22 | 23 | typedef struct 24 | { 25 | const CLzma2EncProps *lzma2Props; 26 | const CXzFilterProps *filterProps; 27 | unsigned checkId; 28 | } CXzProps; 29 | 30 | void XzProps_Init(CXzProps *p); 31 | 32 | SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, 33 | const CXzProps *props, ICompressProgress *progress); 34 | 35 | SRes Xz_EncodeEmpty(ISeqOutStream *outStream); 36 | 37 | EXTERN_C_END 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.cpp: -------------------------------------------------------------------------------- 1 | // CompressionMethod.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp: -------------------------------------------------------------------------------- 1 | // 7zHeader.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "7zHeader.h" 6 | 7 | namespace NArchive { 8 | namespace N7z { 9 | 10 | Byte kSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; 11 | #ifdef _7Z_VOL 12 | Byte kFinishSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C + 1}; 13 | #endif 14 | 15 | // We can change signature. So file doesn't contain correct signature. 16 | // struct SignatureInitializer { SignatureInitializer() { kSignature[0]--; } }; 17 | // static SignatureInitializer g_SignatureInitializer; 18 | 19 | }} 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zProperties.h: -------------------------------------------------------------------------------- 1 | // 7zProperties.h 2 | 3 | #ifndef __7Z_PROPERTIES_H 4 | #define __7Z_PROPERTIES_H 5 | 6 | #include "../../PropID.h" 7 | 8 | namespace NArchive { 9 | namespace N7z { 10 | 11 | enum 12 | { 13 | kpidPackedSize0 = kpidUserDefined, 14 | kpidPackedSize1, 15 | kpidPackedSize2, 16 | kpidPackedSize3, 17 | kpidPackedSize4 18 | }; 19 | 20 | }} 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp: -------------------------------------------------------------------------------- 1 | // 7zRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "7zHandler.h" 8 | 9 | namespace NArchive { 10 | namespace N7z { 11 | 12 | static Byte k_Signature_Dec[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C}; 13 | 14 | REGISTER_ARC_IO_DECREMENT_SIG( 15 | "7z", "7z", NULL, 7, 16 | k_Signature_Dec, 17 | 0, 18 | NArcInfoFlags::kFindSignature, 19 | NULL); 20 | 21 | }} 22 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp: -------------------------------------------------------------------------------- 1 | // 7zSpecStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "7zSpecStream.h" 6 | 7 | STDMETHODIMP CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32 *processedSize) 8 | { 9 | UInt32 realProcessedSize; 10 | HRESULT result = _stream->Read(data, size, &realProcessedSize); 11 | _size += realProcessedSize; 12 | if (processedSize) 13 | *processedSize = realProcessedSize; 14 | return result; 15 | } 16 | 17 | STDMETHODIMP CSequentialInStreamSizeCount2::GetSubStreamSize(UInt64 subStream, UInt64 *value) 18 | { 19 | if (!_getSubStreamSize) 20 | return E_NOTIMPL; 21 | return _getSubStreamSize->GetSubStreamSize(subStream, value); 22 | } 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h: -------------------------------------------------------------------------------- 1 | // 7zSpecStream.h 2 | 3 | #ifndef __7Z_SPEC_STREAM_H 4 | #define __7Z_SPEC_STREAM_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../../ICoder.h" 9 | 10 | class CSequentialInStreamSizeCount2: 11 | public ISequentialInStream, 12 | public ICompressGetSubStreamSize, 13 | public CMyUnknownImp 14 | { 15 | CMyComPtr _stream; 16 | CMyComPtr _getSubStreamSize; 17 | UInt64 _size; 18 | public: 19 | void Init(ISequentialInStream *stream) 20 | { 21 | _size = 0; 22 | _getSubStreamSize.Release(); 23 | _stream = stream; 24 | _stream.QueryInterface(IID_ICompressGetSubStreamSize, &_getSubStreamSize); 25 | } 26 | UInt64 GetSize() const { return _size; } 27 | 28 | MY_UNKNOWN_IMP2(ISequentialInStream, ICompressGetSubStreamSize) 29 | 30 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 31 | 32 | STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value); 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h: -------------------------------------------------------------------------------- 1 | // CabBlockInStream.h 2 | 3 | #ifndef __CAB_BLOCK_IN_STREAM_H 4 | #define __CAB_BLOCK_IN_STREAM_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | #include "../../IStream.h" 8 | 9 | namespace NArchive { 10 | namespace NCab { 11 | 12 | class CCabBlockInStream: 13 | public ISequentialInStream, 14 | public CMyUnknownImp 15 | { 16 | Byte *_buf; 17 | UInt32 _size; 18 | UInt32 _pos; 19 | 20 | public: 21 | UInt32 ReservedSize; // < 256 22 | bool MsZip; 23 | 24 | MY_UNKNOWN_IMP 25 | 26 | CCabBlockInStream(): _buf(0), ReservedSize(0), MsZip(false) {} 27 | ~CCabBlockInStream(); 28 | 29 | bool Create(); 30 | 31 | void InitForNewBlock() { _size = 0; _pos = 0; } 32 | 33 | HRESULT PreRead(ISequentialInStream *stream, UInt32 &packSize, UInt32 &unpackSize); 34 | 35 | UInt32 GetPackSizeAvail() const { return _size - _pos; } 36 | const Byte *GetData() const { return _buf + _pos; } 37 | 38 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 39 | }; 40 | 41 | }} 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Cab/CabHandler.h: -------------------------------------------------------------------------------- 1 | // CabHandler.h 2 | 3 | #ifndef __CAB_HANDLER_H 4 | #define __CAB_HANDLER_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../IArchive.h" 9 | 10 | #include "CabIn.h" 11 | 12 | namespace NArchive { 13 | namespace NCab { 14 | 15 | class CHandler: 16 | public IInArchive, 17 | public CMyUnknownImp 18 | { 19 | public: 20 | MY_UNKNOWN_IMP1(IInArchive) 21 | 22 | INTERFACE_IInArchive(;) 23 | 24 | private: 25 | CMvDatabaseEx m_Database; 26 | UString _errorMessage; 27 | bool _isArc; 28 | bool _errorInHeaders; 29 | bool _unexpectedEnd; 30 | // int _mainVolIndex; 31 | UInt32 _phySize; 32 | UInt64 _offset; 33 | }; 34 | 35 | }} 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp: -------------------------------------------------------------------------------- 1 | // CabHeader.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "CabHeader.h" 6 | 7 | namespace NArchive { 8 | namespace NCab { 9 | namespace NHeader { 10 | 11 | const Byte kMarker[kMarkerSize] = {'M', 'S', 'C', 'F', 0, 0, 0, 0 }; 12 | 13 | // struct CSignatureInitializer { CSignatureInitializer() { kMarker[0]--; } } g_SignatureInitializer; 14 | 15 | }}} 16 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Cab/CabHeader.h: -------------------------------------------------------------------------------- 1 | // Archive/CabHeader.h 2 | 3 | #ifndef __ARCHIVE_CAB_HEADER_H 4 | #define __ARCHIVE_CAB_HEADER_H 5 | 6 | #include "../../../Common/MyTypes.h" 7 | 8 | namespace NArchive { 9 | namespace NCab { 10 | namespace NHeader { 11 | 12 | const unsigned kMarkerSize = 8; 13 | extern const Byte kMarker[kMarkerSize]; 14 | 15 | namespace NArcFlags 16 | { 17 | const unsigned kPrevCabinet = 1; 18 | const unsigned kNextCabinet = 2; 19 | const unsigned kReservePresent = 4; 20 | } 21 | 22 | namespace NMethod 23 | { 24 | const Byte kNone = 0; 25 | const Byte kMSZip = 1; 26 | const Byte kQuantum = 2; 27 | const Byte kLZX = 3; 28 | } 29 | 30 | const unsigned kFileNameIsUtf8_Mask = 0x80; 31 | 32 | namespace NFolderIndex 33 | { 34 | const unsigned kContinuedFromPrev = 0xFFFD; 35 | const unsigned kContinuedToNext = 0xFFFE; 36 | const unsigned kContinuedPrevAndNext = 0xFFFF; 37 | } 38 | 39 | }}} 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp: -------------------------------------------------------------------------------- 1 | // CabRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "CabHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NCab { 11 | 12 | REGISTER_ARC_I( 13 | "Cab", "cab", 0, 8, 14 | NHeader::kMarker, 15 | 0, 16 | NArcInfoFlags::kFindSignature, 17 | NULL) 18 | 19 | }} 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h: -------------------------------------------------------------------------------- 1 | // ChmHandler.h 2 | 3 | #ifndef __ARCHIVE_CHM_HANDLER_H 4 | #define __ARCHIVE_CHM_HANDLER_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../IArchive.h" 9 | 10 | #include "ChmIn.h" 11 | 12 | namespace NArchive { 13 | namespace NChm { 14 | 15 | class CHandler: 16 | public IInArchive, 17 | public CMyUnknownImp 18 | { 19 | public: 20 | MY_UNKNOWN_IMP1(IInArchive) 21 | 22 | INTERFACE_IInArchive(;) 23 | 24 | bool _help2; 25 | CHandler(bool help2): _help2(help2) {} 26 | 27 | private: 28 | CFilesDatabase m_Database; 29 | CMyComPtr m_Stream; 30 | UInt32 m_ErrorFlags; 31 | }; 32 | 33 | }} 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp: -------------------------------------------------------------------------------- 1 | // DummyOutStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "DummyOutStream.h" 6 | 7 | STDMETHODIMP CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) 8 | { 9 | UInt32 realProcessedSize = size; 10 | HRESULT res = S_OK; 11 | if (_stream) 12 | res = _stream->Write(data, size, &realProcessedSize); 13 | _size += realProcessedSize; 14 | if (processedSize) 15 | *processedSize = realProcessedSize; 16 | return res; 17 | } 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h: -------------------------------------------------------------------------------- 1 | // DummyOutStream.h 2 | 3 | #ifndef __DUMMY_OUT_STREAM_H 4 | #define __DUMMY_OUT_STREAM_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../../IStream.h" 9 | 10 | class CDummyOutStream: 11 | public ISequentialOutStream, 12 | public CMyUnknownImp 13 | { 14 | CMyComPtr _stream; 15 | UInt64 _size; 16 | public: 17 | void SetStream(ISequentialOutStream *outStream) { _stream = outStream; } 18 | void ReleaseStream() { _stream.Release(); } 19 | void Init() { _size = 0; } 20 | MY_UNKNOWN_IMP 21 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 22 | UInt64 GetSize() const { return _size; } 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/FindSignature.h: -------------------------------------------------------------------------------- 1 | // FindSignature.h 2 | 3 | #ifndef __FIND_SIGNATURE_H 4 | #define __FIND_SIGNATURE_H 5 | 6 | #include "../../IStream.h" 7 | 8 | HRESULT FindSignatureInStream(ISequentialInStream *stream, 9 | const Byte *signature, unsigned signatureSize, 10 | const UInt64 *limit, UInt64 &resPos); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp: -------------------------------------------------------------------------------- 1 | // InStreamWithCRC.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "InStreamWithCRC.h" 6 | 7 | STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 8 | { 9 | UInt32 realProcessed = 0; 10 | HRESULT result = S_OK; 11 | if (_stream) 12 | result = _stream->Read(data, size, &realProcessed); 13 | _size += realProcessed; 14 | if (size != 0 && realProcessed == 0) 15 | _wasFinished = true; 16 | _crc = CrcUpdate(_crc, data, realProcessed); 17 | if (processedSize) 18 | *processedSize = realProcessed; 19 | return result; 20 | } 21 | 22 | STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 23 | { 24 | UInt32 realProcessed = 0; 25 | HRESULT result = S_OK; 26 | if (_stream) 27 | result = _stream->Read(data, size, &realProcessed); 28 | _size += realProcessed; 29 | /* 30 | if (size != 0 && realProcessed == 0) 31 | _wasFinished = true; 32 | */ 33 | _crc = CrcUpdate(_crc, data, realProcessed); 34 | if (processedSize) 35 | *processedSize = realProcessed; 36 | return result; 37 | } 38 | 39 | STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 40 | { 41 | if (seekOrigin != STREAM_SEEK_SET || offset != 0) 42 | return E_FAIL; 43 | _size = 0; 44 | _crc = CRC_INIT_VAL; 45 | return _stream->Seek(offset, seekOrigin, newPosition); 46 | } 47 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h: -------------------------------------------------------------------------------- 1 | // Archive/Common/ItemNameUtils.h 2 | 3 | #ifndef __ARCHIVE_ITEM_NAME_UTILS_H 4 | #define __ARCHIVE_ITEM_NAME_UTILS_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | namespace NArchive { 9 | namespace NItemName { 10 | 11 | void ReplaceToOsPathSeparator(wchar_t *s); 12 | 13 | UString MakeLegalName(const UString &name); 14 | UString GetOSName(const UString &name); 15 | UString GetOSName2(const UString &name); 16 | void ConvertToOSName2(UString &name); 17 | bool HasTailSlash(const AString &name, UINT codePage); 18 | 19 | #ifdef _WIN32 20 | inline UString WinNameToOSName(const UString &name) { return name; } 21 | #else 22 | UString WinNameToOSName(const UString &name); 23 | #endif 24 | 25 | }} 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp: -------------------------------------------------------------------------------- 1 | // OutStreamWithCRC.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "OutStreamWithCRC.h" 6 | 7 | STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize) 8 | { 9 | HRESULT result = S_OK; 10 | if (_stream) 11 | result = _stream->Write(data, size, &size); 12 | if (_calculate) 13 | _crc = CrcUpdate(_crc, data, size); 14 | _size += size; 15 | if (processedSize != NULL) 16 | *processedSize = size; 17 | return result; 18 | } 19 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h: -------------------------------------------------------------------------------- 1 | // OutStreamWithCRC.h 2 | 3 | #ifndef __OUT_STREAM_WITH_CRC_H 4 | #define __OUT_STREAM_WITH_CRC_H 5 | 6 | #include "../../../../C/7zCrc.h" 7 | 8 | #include "../../../Common/MyCom.h" 9 | 10 | #include "../../IStream.h" 11 | 12 | class COutStreamWithCRC: 13 | public ISequentialOutStream, 14 | public CMyUnknownImp 15 | { 16 | CMyComPtr _stream; 17 | UInt64 _size; 18 | UInt32 _crc; 19 | bool _calculate; 20 | public: 21 | MY_UNKNOWN_IMP 22 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 23 | void SetStream(ISequentialOutStream *stream) { _stream = stream; } 24 | void ReleaseStream() { _stream.Release(); } 25 | void Init(bool calculate = true) 26 | { 27 | _size = 0; 28 | _calculate = calculate; 29 | _crc = CRC_INIT_VAL; 30 | } 31 | void EnableCalc(bool calculate) { _calculate = calculate; } 32 | void InitCRC() { _crc = CRC_INIT_VAL; } 33 | UInt64 GetSize() const { return _size; } 34 | UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); } 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp: -------------------------------------------------------------------------------- 1 | // OutStreamWithSha1.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "OutStreamWithSha1.h" 6 | 7 | STDMETHODIMP COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize) 8 | { 9 | HRESULT result = S_OK; 10 | if (_stream) 11 | result = _stream->Write(data, size, &size); 12 | if (_calculate) 13 | Sha1_Update(&_sha, (const Byte *)data, size); 14 | _size += size; 15 | if (processedSize) 16 | *processedSize = size; 17 | return result; 18 | } 19 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h: -------------------------------------------------------------------------------- 1 | // OutStreamWithSha1.h 2 | 3 | #ifndef __OUT_STREAM_WITH_SHA1_H 4 | #define __OUT_STREAM_WITH_SHA1_H 5 | 6 | #include "../../../../C/Sha1.h" 7 | 8 | #include "../../../Common/MyCom.h" 9 | 10 | #include "../../IStream.h" 11 | 12 | class COutStreamWithSha1: 13 | public ISequentialOutStream, 14 | public CMyUnknownImp 15 | { 16 | CMyComPtr _stream; 17 | UInt64 _size; 18 | CSha1 _sha; 19 | bool _calculate; 20 | public: 21 | MY_UNKNOWN_IMP 22 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 23 | void SetStream(ISequentialOutStream *stream) { _stream = stream; } 24 | void ReleaseStream() { _stream.Release(); } 25 | void Init(bool calculate = true) 26 | { 27 | _size = 0; 28 | _calculate = calculate; 29 | Sha1_Init(&_sha); 30 | } 31 | void InitSha1() { Sha1_Init(&_sha); } 32 | UInt64 GetSize() const { return _size; } 33 | void Final(Byte *digest) { Sha1_Final(&_sha, digest); } 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp: -------------------------------------------------------------------------------- 1 | // ParseProperties.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Common/ParseProperties.h: -------------------------------------------------------------------------------- 1 | // ParseProperties.h 2 | 3 | #ifndef __PARSE_PROPERTIES_H 4 | #define __PARSE_PROPERTIES_H 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/DeflateProps.cpp: -------------------------------------------------------------------------------- 1 | // DeflateProps.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/DeflateProps.h: -------------------------------------------------------------------------------- 1 | // DeflateProps.h 2 | 3 | #ifndef __DEFLATE_PROPS_H 4 | #define __DEFLATE_PROPS_H 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h: -------------------------------------------------------------------------------- 1 | // IsoHandler.h 2 | 3 | #ifndef __ISO_HANDLER_H 4 | #define __ISO_HANDLER_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../IArchive.h" 9 | 10 | #include "IsoIn.h" 11 | #include "IsoItem.h" 12 | 13 | namespace NArchive { 14 | namespace NIso { 15 | 16 | class CHandler: 17 | public IInArchive, 18 | public IInArchiveGetStream, 19 | public CMyUnknownImp 20 | { 21 | CMyComPtr _stream; 22 | CInArchive _archive; 23 | public: 24 | MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream) 25 | INTERFACE_IInArchive(;) 26 | STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); 27 | }; 28 | 29 | }} 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp: -------------------------------------------------------------------------------- 1 | // Archive/Iso/Header.h 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "IsoHeader.h" 6 | 7 | namespace NArchive { 8 | namespace NIso { 9 | 10 | const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0"; 11 | 12 | }} 13 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h: -------------------------------------------------------------------------------- 1 | // Archive/IsoHeader.h 2 | 3 | #ifndef __ARCHIVE_ISO_HEADER_H 4 | #define __ARCHIVE_ISO_HEADER_H 5 | 6 | #include "../../../Common/MyTypes.h" 7 | 8 | namespace NArchive { 9 | namespace NIso { 10 | 11 | namespace NVolDescType 12 | { 13 | const Byte kBootRecord = 0; 14 | const Byte kPrimaryVol = 1; 15 | const Byte kSupplementaryVol = 2; 16 | const Byte kVolParttition = 3; 17 | const Byte kTerminator = 255; 18 | } 19 | 20 | const Byte kVersion = 1; 21 | 22 | namespace NFileFlags 23 | { 24 | const Byte kDirectory = 1 << 1; 25 | const Byte kNonFinalExtent = 1 << 7; 26 | } 27 | 28 | extern const char *kElToritoSpec; 29 | 30 | const UInt32 kStartPos = 0x8000; 31 | 32 | namespace NBootEntryId 33 | { 34 | const Byte kValidationEntry = 1; 35 | const Byte kInitialEntryNotBootable = 0; 36 | const Byte kInitialEntryBootable = 0x88; 37 | 38 | const Byte kMoreHeaders = 0x90; 39 | const Byte kFinalHeader = 0x91; 40 | 41 | const Byte kExtensionIndicator = 0x44; 42 | } 43 | 44 | namespace NBootPlatformId 45 | { 46 | const Byte kX86 = 0; 47 | const Byte kPowerPC = 1; 48 | const Byte kMac = 2; 49 | } 50 | 51 | const Byte kBootMediaTypeMask = 0xF; 52 | 53 | namespace NBootMediaType 54 | { 55 | const Byte kNoEmulation = 0; 56 | const Byte k1d2Floppy = 1; 57 | const Byte k1d44Floppy = 2; 58 | const Byte k2d88Floppy = 3; 59 | const Byte kHardDisk = 4; 60 | } 61 | 62 | }} 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp: -------------------------------------------------------------------------------- 1 | // IsoRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "IsoHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NIso { 11 | 12 | static const Byte k_Signature[] = { 'C', 'D', '0', '0', '1' }; 13 | 14 | REGISTER_ARC_I( 15 | "Iso", "iso img", 0, 0xE7, 16 | k_Signature, 17 | NArchive::NIso::kStartPos + 1, 18 | 0, 19 | NULL) 20 | 21 | }} 22 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h: -------------------------------------------------------------------------------- 1 | // NSisHandler.h 2 | 3 | #ifndef __NSIS_HANDLER_H 4 | #define __NSIS_HANDLER_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../../Common/CreateCoder.h" 9 | 10 | #include "../IArchive.h" 11 | 12 | #include "NsisIn.h" 13 | 14 | namespace NArchive { 15 | namespace NNsis { 16 | 17 | class CHandler: 18 | public IInArchive, 19 | public CMyUnknownImp 20 | { 21 | CInArchive _archive; 22 | AString _methodString; 23 | 24 | bool GetUncompressedSize(unsigned index, UInt32 &size) const; 25 | bool GetCompressedSize(unsigned index, UInt32 &size) const; 26 | 27 | // AString GetMethod(NMethodType::EEnum method, bool useItemFilter, UInt32 dictionary) const; 28 | public: 29 | MY_UNKNOWN_IMP1(IInArchive) 30 | 31 | INTERFACE_IInArchive(;) 32 | }; 33 | 34 | }} 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp: -------------------------------------------------------------------------------- 1 | // NsisRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "NsisHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NNsis { 11 | 12 | REGISTER_ARC_I( 13 | "Nsis", "nsis", 0, 0x9, 14 | kSignature, 15 | 4, 16 | NArcInfoFlags::kFindSignature | 17 | NArcInfoFlags::kUseGlobalOffset, 18 | NULL) 19 | 20 | }} 21 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp: -------------------------------------------------------------------------------- 1 | // Archive/TarHeader.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "TarHeader.h" 6 | 7 | namespace NArchive { 8 | namespace NTar { 9 | namespace NFileHeader { 10 | 11 | const char *kLongLink = "././@LongLink"; 12 | const char *kLongLink2 = "@LongLink"; 13 | 14 | // The magic field is filled with this if uname and gname are valid. 15 | namespace NMagic 16 | { 17 | // const char *kUsTar = "ustar"; // 5 chars 18 | // const char *kGNUTar = "GNUtar "; // 7 chars and a null 19 | // const char *kEmpty = "\0\0\0\0\0\0\0\0"; 20 | const char kUsTar_00[8] = { 'u', 's', 't', 'a', 'r', 0, '0', '0' } ; 21 | } 22 | 23 | }}} 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Tar/TarIn.h: -------------------------------------------------------------------------------- 1 | // TarIn.h 2 | 3 | #ifndef __ARCHIVE_TAR_IN_H 4 | #define __ARCHIVE_TAR_IN_H 5 | 6 | #include "../../IStream.h" 7 | 8 | #include "TarItem.h" 9 | 10 | namespace NArchive { 11 | namespace NTar { 12 | 13 | enum EErrorType 14 | { 15 | k_ErrorType_OK, 16 | k_ErrorType_Corrupted, 17 | k_ErrorType_UnexpectedEnd, 18 | }; 19 | 20 | HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo, EErrorType &error); 21 | 22 | API_FUNC_IsArc IsArc_Tar(const Byte *p, size_t size); 23 | 24 | }} 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Tar/TarOut.h: -------------------------------------------------------------------------------- 1 | // Archive/TarOut.h 2 | 3 | #ifndef __ARCHIVE_TAR_OUT_H 4 | #define __ARCHIVE_TAR_OUT_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../../IStream.h" 9 | 10 | #include "TarItem.h" 11 | 12 | namespace NArchive { 13 | namespace NTar { 14 | 15 | class COutArchive 16 | { 17 | CMyComPtr m_Stream; 18 | 19 | HRESULT WriteBytes(const void *data, unsigned size); 20 | HRESULT WriteHeaderReal(const CItem &item); 21 | public: 22 | UInt64 Pos; 23 | 24 | void Create(ISequentialOutStream *outStream) 25 | { 26 | m_Stream = outStream; 27 | } 28 | 29 | HRESULT WriteHeader(const CItem &item); 30 | HRESULT FillDataResidual(UInt64 dataSize); 31 | HRESULT WriteFinishHeader(); 32 | }; 33 | 34 | }} 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp: -------------------------------------------------------------------------------- 1 | // TarRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "TarHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NTar { 11 | 12 | static const Byte k_Signature[] = { 'u', 's', 't', 'a', 'r' }; 13 | 14 | REGISTER_ARC_IO( 15 | "tar", "tar ova", 0, 0xEE, 16 | k_Signature, 17 | NFileHeader::kUstarMagic_Offset, 18 | NArcInfoFlags::kStartOpen | 19 | NArcInfoFlags::kSymLinks | 20 | NArcInfoFlags::kHardLinks, 21 | IsArc_Tar) 22 | 23 | }} 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h: -------------------------------------------------------------------------------- 1 | // TarUpdate.h 2 | 3 | #ifndef __TAR_UPDATE_H 4 | #define __TAR_UPDATE_H 5 | 6 | #include "../IArchive.h" 7 | 8 | #include "TarItem.h" 9 | 10 | namespace NArchive { 11 | namespace NTar { 12 | 13 | struct CUpdateItem 14 | { 15 | int IndexInArc; 16 | int IndexInClient; 17 | UInt64 Size; 18 | Int64 MTime; 19 | UInt32 Mode; 20 | bool NewData; 21 | bool NewProps; 22 | bool IsDir; 23 | AString Name; 24 | AString User; 25 | AString Group; 26 | 27 | CUpdateItem(): Size(0), IsDir(false) {} 28 | }; 29 | 30 | HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream, 31 | const CObjectVector &inputItems, 32 | const CObjectVector &updateItems, 33 | UINT codePage, 34 | IArchiveUpdateCallback *updateCallback); 35 | 36 | }} 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h: -------------------------------------------------------------------------------- 1 | // UdfHandler.h 2 | 3 | #ifndef __UDF_HANDLER_H 4 | #define __UDF_HANDLER_H 5 | 6 | #include "../../../Common/MyCom.h" 7 | 8 | #include "../IArchive.h" 9 | 10 | #include "UdfIn.h" 11 | 12 | namespace NArchive { 13 | namespace NUdf { 14 | 15 | struct CRef2 16 | { 17 | unsigned Vol; 18 | unsigned Fs; 19 | unsigned Ref; 20 | }; 21 | 22 | class CHandler: 23 | public IInArchive, 24 | public IInArchiveGetStream, 25 | public CMyUnknownImp 26 | { 27 | CMyComPtr _inStream; 28 | CInArchive _archive; 29 | CRecordVector _refs2; 30 | public: 31 | MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream) 32 | INTERFACE_IInArchive(;) 33 | STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); 34 | }; 35 | 36 | }} 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp: -------------------------------------------------------------------------------- 1 | // WimRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "WimHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NWim { 11 | 12 | REGISTER_ARC_IO( 13 | "wim", "wim swm esd", 0, 0xE6, 14 | kSignature, 15 | 0, 16 | NArcInfoFlags::kAltStreams | 17 | NArcInfoFlags::kNtSecure | 18 | NArcInfoFlags::kSymLinks | 19 | NArcInfoFlags::kHardLinks 20 | , NULL) 21 | 22 | }} 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/XzHandler.h: -------------------------------------------------------------------------------- 1 | // XzHandler.h 2 | 3 | #ifndef __XZ_HANDLER_H 4 | #define __XZ_HANDLER_H 5 | 6 | #include "../../../C/Xz.h" 7 | 8 | #include "../ICoder.h" 9 | 10 | namespace NArchive { 11 | namespace NXz { 12 | 13 | struct CXzUnpackerCPP 14 | { 15 | Byte *InBuf; 16 | Byte *OutBuf; 17 | CXzUnpacker p; 18 | 19 | CXzUnpackerCPP(); 20 | ~CXzUnpackerCPP(); 21 | }; 22 | 23 | struct CStatInfo 24 | { 25 | UInt64 InSize; 26 | UInt64 OutSize; 27 | UInt64 PhySize; 28 | 29 | UInt64 NumStreams; 30 | UInt64 NumBlocks; 31 | 32 | bool UnpackSize_Defined; 33 | 34 | bool NumStreams_Defined; 35 | bool NumBlocks_Defined; 36 | 37 | bool IsArc; 38 | bool UnexpectedEnd; 39 | bool DataAfterEnd; 40 | bool Unsupported; 41 | bool HeadersError; 42 | bool DataError; 43 | bool CrcError; 44 | 45 | CStatInfo() { Clear(); } 46 | 47 | void Clear(); 48 | }; 49 | 50 | struct CDecoder: public CStatInfo 51 | { 52 | CXzUnpackerCPP xzu; 53 | SRes DecodeRes; // it's not HRESULT 54 | 55 | CDecoder(): DecodeRes(SZ_OK) {} 56 | 57 | /* Decode() can return ERROR code only if there is progress or stream error. 58 | Decode() returns S_OK in case of xz decoding error, but DecodeRes and CStatInfo contain error information */ 59 | HRESULT Decode(ISequentialInStream *seqInStream, ISequentialOutStream *outStream, ICompressProgressInfo *compressProgress); 60 | Int32 Get_Extract_OperationResult() const; 61 | }; 62 | 63 | }} 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h: -------------------------------------------------------------------------------- 1 | // CompressionMode.h 2 | 3 | #ifndef __ZIP_COMPRESSION_MODE_H 4 | #define __ZIP_COMPRESSION_MODE_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | #ifndef _7ZIP_ST 9 | #include "../../../Windows/System.h" 10 | #endif 11 | 12 | #include "../Common/HandlerOut.h" 13 | 14 | namespace NArchive { 15 | namespace NZip { 16 | 17 | struct CBaseProps 18 | { 19 | CMethodProps MethodInfo; 20 | Int32 Level; 21 | 22 | #ifndef _7ZIP_ST 23 | UInt32 NumThreads; 24 | bool NumThreadsWasChanged; 25 | #endif 26 | bool IsAesMode; 27 | Byte AesKeyMode; 28 | 29 | void Init() 30 | { 31 | MethodInfo.Clear(); 32 | Level = -1; 33 | #ifndef _7ZIP_ST 34 | NumThreads = NWindows::NSystem::GetNumberOfProcessors();; 35 | NumThreadsWasChanged = false; 36 | #endif 37 | IsAesMode = false; 38 | AesKeyMode = 3; 39 | } 40 | }; 41 | 42 | struct CCompressionMethodMode: public CBaseProps 43 | { 44 | CRecordVector MethodSequence; 45 | bool PasswordIsDefined; 46 | AString Password; 47 | 48 | UInt64 _dataSizeReduce; 49 | bool _dataSizeReduceDefined; 50 | 51 | bool IsRealAesMode() const { return PasswordIsDefined && IsAesMode; } 52 | 53 | CCompressionMethodMode(): PasswordIsDefined(false) 54 | { 55 | _dataSizeReduceDefined = false; 56 | _dataSizeReduce = 0; 57 | } 58 | }; 59 | 60 | }} 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp: -------------------------------------------------------------------------------- 1 | // ZipRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/RegisterArc.h" 6 | 7 | #include "ZipHandler.h" 8 | 9 | namespace NArchive { 10 | namespace NZip { 11 | 12 | static const Byte k_Signature[] = { 13 | 4, 0x50, 0x4B, 0x03, 0x04, 14 | 4, 0x50, 0x4B, 0x05, 0x06, 15 | 6, 0x50, 0x4B, 0x07, 0x08, 0x50, 0x4B, 16 | 6, 0x50, 0x4B, 0x30, 0x30, 0x50, 0x4B }; 17 | 18 | REGISTER_ARC_IO( 19 | "zip", "zip z01 zipx jar xpi odt ods docx xlsx epub", 0, 1, 20 | k_Signature, 21 | 0, 22 | NArcInfoFlags::kFindSignature | 23 | NArcInfoFlags::kMultiSignature | 24 | NArcInfoFlags::kUseGlobalOffset, 25 | IsArc_Zip) 26 | 27 | }} 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h: -------------------------------------------------------------------------------- 1 | // ZipUpdate.h 2 | 3 | #ifndef __ZIP_UPDATE_H 4 | #define __ZIP_UPDATE_H 5 | 6 | #include "../../ICoder.h" 7 | #include "../IArchive.h" 8 | 9 | #include "../../Common/CreateCoder.h" 10 | 11 | #include "ZipCompressionMode.h" 12 | #include "ZipIn.h" 13 | 14 | namespace NArchive { 15 | namespace NZip { 16 | 17 | struct CUpdateRange 18 | { 19 | UInt64 Position; 20 | UInt64 Size; 21 | 22 | // CUpdateRange() {}; 23 | CUpdateRange(UInt64 position, UInt64 size): Position(position), Size(size) {}; 24 | }; 25 | 26 | struct CUpdateItem 27 | { 28 | bool NewData; 29 | bool NewProps; 30 | bool IsDir; 31 | bool NtfsTimeIsDefined; 32 | bool IsUtf8; 33 | int IndexInArc; 34 | int IndexInClient; 35 | UInt32 Attrib; 36 | UInt32 Time; 37 | UInt64 Size; 38 | AString Name; 39 | // bool Commented; 40 | // CUpdateRange CommentRange; 41 | FILETIME Ntfs_MTime; 42 | FILETIME Ntfs_ATime; 43 | FILETIME Ntfs_CTime; 44 | 45 | CUpdateItem(): NtfsTimeIsDefined(false), IsUtf8(false), Size(0) {} 46 | }; 47 | 48 | HRESULT Update( 49 | DECL_EXTERNAL_CODECS_LOC_VARS 50 | const CObjectVector &inputItems, 51 | CObjectVector &updateItems, 52 | ISequentialOutStream *seqOutStream, 53 | CInArchive *inArchive, bool removeSfx, 54 | CCompressionMethodMode *compressionMethodMode, 55 | IArchiveUpdateCallback *updateCallback); 56 | 57 | }} 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp: -------------------------------------------------------------------------------- 1 | // FilePathAutoRename.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/Defs.h" 6 | #include "../../Common/IntToString.h" 7 | 8 | #include "../../Windows/FileFind.h" 9 | 10 | #include "FilePathAutoRename.h" 11 | 12 | using namespace NWindows; 13 | 14 | static bool MakeAutoName(const FString &name, 15 | const FString &extension, UInt32 value, FString &path) 16 | { 17 | char temp[16]; 18 | ConvertUInt32ToString(value, temp); 19 | path = name; 20 | path.AddAscii(temp); 21 | path += extension; 22 | return NFile::NFind::DoesFileOrDirExist(path); 23 | } 24 | 25 | bool AutoRenamePath(FString &path) 26 | { 27 | int dotPos = path.ReverseFind_Dot(); 28 | int slashPos = path.ReverseFind_PathSepar(); 29 | 30 | FString name = path; 31 | FString extension; 32 | if (dotPos > slashPos + 1) 33 | { 34 | name.DeleteFrom(dotPos); 35 | extension = path.Ptr(dotPos); 36 | } 37 | name += FTEXT('_'); 38 | 39 | FString temp; 40 | 41 | UInt32 left = 1, right = ((UInt32)1 << 30); 42 | while (left != right) 43 | { 44 | UInt32 mid = (left + right) / 2; 45 | if (MakeAutoName(name, extension, mid, temp)) 46 | left = mid + 1; 47 | else 48 | right = mid; 49 | } 50 | return !MakeAutoName(name, extension, right, path); 51 | } 52 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/FilePathAutoRename.h: -------------------------------------------------------------------------------- 1 | // FilePathAutoRename.h 2 | 3 | #ifndef __FILE_PATH_AUTO_RENAME_H 4 | #define __FILE_PATH_AUTO_RENAME_H 5 | 6 | #include "../../Common/MyString.h" 7 | 8 | bool AutoRenamePath(FString &fullProcessedPath); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/InOutTempBuffer.h: -------------------------------------------------------------------------------- 1 | // InOutTempBuffer.h 2 | 3 | #ifndef __IN_OUT_TEMP_BUFFER_H 4 | #define __IN_OUT_TEMP_BUFFER_H 5 | 6 | #include "../../Common/MyCom.h" 7 | #include "../../Windows/FileDir.h" 8 | 9 | #include "../IStream.h" 10 | 11 | class CInOutTempBuffer 12 | { 13 | NWindows::NFile::NDir::CTempFile _tempFile; 14 | NWindows::NFile::NIO::COutFile _outFile; 15 | Byte *_buf; 16 | size_t _bufPos; 17 | UInt64 _size; 18 | UInt32 _crc; 19 | bool _tempFileCreated; 20 | 21 | bool WriteToFile(const void *data, UInt32 size); 22 | public: 23 | CInOutTempBuffer(); 24 | ~CInOutTempBuffer(); 25 | void Create(); 26 | 27 | void InitWriting(); 28 | bool Write(const void *data, UInt32 size); 29 | 30 | HRESULT WriteToStream(ISequentialOutStream *stream); 31 | UInt64 GetDataSize() const { return _size; } 32 | }; 33 | 34 | /* 35 | class CSequentialOutTempBufferImp: 36 | public ISequentialOutStream, 37 | public CMyUnknownImp 38 | { 39 | CInOutTempBuffer *_buf; 40 | public: 41 | void Init(CInOutTempBuffer *buffer) { _buf = buffer; } 42 | MY_UNKNOWN_IMP 43 | 44 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 45 | }; 46 | */ 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/MethodId.cpp: -------------------------------------------------------------------------------- 1 | // MethodId.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/MethodId.h: -------------------------------------------------------------------------------- 1 | // MethodId.h 2 | 3 | #ifndef __7Z_METHOD_ID_H 4 | #define __7Z_METHOD_ID_H 5 | 6 | #include "../../Common/MyTypes.h" 7 | 8 | typedef UInt64 CMethodId; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/OffsetStream.cpp: -------------------------------------------------------------------------------- 1 | // OffsetStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/Defs.h" 6 | 7 | #include "OffsetStream.h" 8 | 9 | HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset) 10 | { 11 | _offset = offset; 12 | _stream = stream; 13 | return _stream->Seek(offset, STREAM_SEEK_SET, NULL); 14 | } 15 | 16 | STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) 17 | { 18 | return _stream->Write(data, size, processedSize); 19 | } 20 | 21 | STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 22 | { 23 | UInt64 absoluteNewPosition; 24 | if (seekOrigin == STREAM_SEEK_SET) 25 | { 26 | if (offset < 0) 27 | return HRESULT_WIN32_ERROR_NEGATIVE_SEEK; 28 | offset += _offset; 29 | } 30 | HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition); 31 | if (newPosition) 32 | *newPosition = absoluteNewPosition - _offset; 33 | return result; 34 | } 35 | 36 | STDMETHODIMP COffsetOutStream::SetSize(UInt64 newSize) 37 | { 38 | return _stream->SetSize(_offset + newSize); 39 | } 40 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/OffsetStream.h: -------------------------------------------------------------------------------- 1 | // OffsetStream.h 2 | 3 | #ifndef __OFFSET_STREAM_H 4 | #define __OFFSET_STREAM_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../IStream.h" 9 | 10 | class COffsetOutStream: 11 | public IOutStream, 12 | public CMyUnknownImp 13 | { 14 | UInt64 _offset; 15 | CMyComPtr _stream; 16 | public: 17 | HRESULT Init(IOutStream *stream, UInt64 offset); 18 | 19 | MY_UNKNOWN_IMP 20 | 21 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 22 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); 23 | STDMETHOD(SetSize)(UInt64 newSize); 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/ProgressMt.cpp: -------------------------------------------------------------------------------- 1 | // ProgressMt.h 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "ProgressMt.h" 6 | 7 | void CMtCompressProgressMixer::Init(int numItems, ICompressProgressInfo *progress) 8 | { 9 | NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection); 10 | InSizes.Clear(); 11 | OutSizes.Clear(); 12 | for (int i = 0; i < numItems; i++) 13 | { 14 | InSizes.Add(0); 15 | OutSizes.Add(0); 16 | } 17 | TotalInSize = 0; 18 | TotalOutSize = 0; 19 | _progress = progress; 20 | } 21 | 22 | void CMtCompressProgressMixer::Reinit(int index) 23 | { 24 | NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection); 25 | InSizes[index] = 0; 26 | OutSizes[index] = 0; 27 | } 28 | 29 | HRESULT CMtCompressProgressMixer::SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize) 30 | { 31 | NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection); 32 | if (inSize != 0) 33 | { 34 | UInt64 diff = *inSize - InSizes[index]; 35 | InSizes[index] = *inSize; 36 | TotalInSize += diff; 37 | } 38 | if (outSize != 0) 39 | { 40 | UInt64 diff = *outSize - OutSizes[index]; 41 | OutSizes[index] = *outSize; 42 | TotalOutSize += diff; 43 | } 44 | if (_progress) 45 | return _progress->SetRatioInfo(&TotalInSize, &TotalOutSize); 46 | return S_OK; 47 | } 48 | 49 | 50 | STDMETHODIMP CMtCompressProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) 51 | { 52 | return _progress->SetRatioInfo(_index, inSize, outSize); 53 | } 54 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/ProgressMt.h: -------------------------------------------------------------------------------- 1 | // ProgressMt.h 2 | 3 | #ifndef __PROGRESSMT_H 4 | #define __PROGRESSMT_H 5 | 6 | #include "../../Common/MyCom.h" 7 | #include "../../Common/MyVector.h" 8 | #include "../../Windows/Synchronization.h" 9 | 10 | #include "../ICoder.h" 11 | #include "../IProgress.h" 12 | 13 | class CMtCompressProgressMixer 14 | { 15 | CMyComPtr _progress; 16 | CRecordVector InSizes; 17 | CRecordVector OutSizes; 18 | UInt64 TotalInSize; 19 | UInt64 TotalOutSize; 20 | public: 21 | NWindows::NSynchronization::CCriticalSection CriticalSection; 22 | void Init(int numItems, ICompressProgressInfo *progress); 23 | void Reinit(int index); 24 | HRESULT SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize); 25 | }; 26 | 27 | class CMtCompressProgress: 28 | public ICompressProgressInfo, 29 | public CMyUnknownImp 30 | { 31 | CMtCompressProgressMixer *_progress; 32 | int _index; 33 | public: 34 | void Init(CMtCompressProgressMixer *progress, int index) 35 | { 36 | _progress = progress; 37 | _index = index; 38 | } 39 | void Reinit() { _progress->Reinit(_index); } 40 | 41 | MY_UNKNOWN_IMP 42 | 43 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/ProgressUtils.cpp: -------------------------------------------------------------------------------- 1 | // ProgressUtils.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "ProgressUtils.h" 6 | 7 | CLocalProgress::CLocalProgress(): 8 | ProgressOffset(0), 9 | InSize(0), 10 | OutSize(0), 11 | SendRatio(true), 12 | SendProgress(true) 13 | {} 14 | 15 | void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain) 16 | { 17 | _ratioProgress.Release(); 18 | _progress = progress; 19 | _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress); 20 | _inSizeIsMain = inSizeIsMain; 21 | } 22 | 23 | STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) 24 | { 25 | UInt64 inSize2 = InSize; 26 | UInt64 outSize2 = OutSize; 27 | 28 | if (inSize) 29 | inSize2 += (*inSize); 30 | if (outSize) 31 | outSize2 += (*outSize); 32 | 33 | if (SendRatio && _ratioProgress) 34 | { 35 | RINOK(_ratioProgress->SetRatioInfo(&inSize2, &outSize2)); 36 | } 37 | 38 | if (SendProgress) 39 | { 40 | inSize2 += ProgressOffset; 41 | outSize2 += ProgressOffset; 42 | return _progress->SetCompleted(_inSizeIsMain ? &inSize2 : &outSize2); 43 | } 44 | 45 | return S_OK; 46 | } 47 | 48 | HRESULT CLocalProgress::SetCur() 49 | { 50 | return SetRatioInfo(NULL, NULL); 51 | } 52 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/ProgressUtils.h: -------------------------------------------------------------------------------- 1 | // ProgressUtils.h 2 | 3 | #ifndef __PROGRESS_UTILS_H 4 | #define __PROGRESS_UTILS_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | #include "../IProgress.h" 10 | 11 | class CLocalProgress: 12 | public ICompressProgressInfo, 13 | public CMyUnknownImp 14 | { 15 | CMyComPtr _progress; 16 | CMyComPtr _ratioProgress; 17 | bool _inSizeIsMain; 18 | public: 19 | UInt64 ProgressOffset; 20 | UInt64 InSize; 21 | UInt64 OutSize; 22 | bool SendRatio; 23 | bool SendProgress; 24 | 25 | CLocalProgress(); 26 | 27 | void Init(IProgress *progress, bool inSizeIsMain); 28 | HRESULT SetCur(); 29 | 30 | MY_UNKNOWN_IMP1(ICompressProgressInfo) 31 | 32 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/StreamUtils.h: -------------------------------------------------------------------------------- 1 | // StreamUtils.h 2 | 3 | #ifndef __STREAM_UTILS_H 4 | #define __STREAM_UTILS_H 5 | 6 | #include "../IStream.h" 7 | 8 | HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *size) throw(); 9 | HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size) throw(); 10 | HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size) throw(); 11 | HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size) throw(); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/UniqBlocks.cpp: -------------------------------------------------------------------------------- 1 | // UniqBlocks.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | 7 | #include "UniqBlocks.h" 8 | 9 | unsigned CUniqBlocks::AddUniq(const Byte *data, size_t size) 10 | { 11 | unsigned left = 0, right = Sorted.Size(); 12 | while (left != right) 13 | { 14 | unsigned mid = (left + right) / 2; 15 | unsigned index = Sorted[mid]; 16 | const CByteBuffer &buf = Bufs[index]; 17 | size_t sizeMid = buf.Size(); 18 | if (size < sizeMid) 19 | right = mid; 20 | else if (size > sizeMid) 21 | left = mid + 1; 22 | else 23 | { 24 | if (size == 0) 25 | return index; 26 | int cmp = memcmp(data, buf, size); 27 | if (cmp == 0) 28 | return index; 29 | if (cmp < 0) 30 | right = mid; 31 | else 32 | left = mid + 1; 33 | } 34 | } 35 | unsigned index = Bufs.Size(); 36 | Sorted.Insert(left, index); 37 | Bufs.AddNew().CopyFrom(data, size); 38 | return index; 39 | } 40 | 41 | UInt64 CUniqBlocks::GetTotalSizeInBytes() const 42 | { 43 | UInt64 size = 0; 44 | FOR_VECTOR (i, Bufs) 45 | size += Bufs[i].Size(); 46 | return size; 47 | } 48 | 49 | void CUniqBlocks::GetReverseMap() 50 | { 51 | unsigned num = Sorted.Size(); 52 | BufIndexToSortedIndex.ClearAndSetSize(num); 53 | unsigned *p = &BufIndexToSortedIndex[0]; 54 | const unsigned *sorted = &Sorted[0]; 55 | for (unsigned i = 0; i < num; i++) 56 | p[sorted[i]] = i; 57 | } 58 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/UniqBlocks.h: -------------------------------------------------------------------------------- 1 | // UniqBlocks.h 2 | 3 | #ifndef __UNIQ_BLOCKS_H 4 | #define __UNIQ_BLOCKS_H 5 | 6 | #include "../../Common/MyTypes.h" 7 | #include "../../Common/MyBuffer.h" 8 | #include "../../Common/MyVector.h" 9 | 10 | struct CUniqBlocks 11 | { 12 | CObjectVector Bufs; 13 | CUIntVector Sorted; 14 | CUIntVector BufIndexToSortedIndex; 15 | 16 | unsigned AddUniq(const Byte *data, size_t size); 17 | UInt64 GetTotalSizeInBytes() const; 18 | void GetReverseMap(); 19 | 20 | bool IsOnlyEmpty() const 21 | { 22 | return (Bufs.Size() == 0 || Bufs.Size() == 1 && Bufs[0].Size() == 0); 23 | } 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/VirtThread.cpp: -------------------------------------------------------------------------------- 1 | // VirtThread.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "VirtThread.h" 6 | 7 | static THREAD_FUNC_DECL CoderThread(void *p) 8 | { 9 | for (;;) 10 | { 11 | CVirtThread *t = (CVirtThread *)p; 12 | t->StartEvent.Lock(); 13 | if (t->Exit) 14 | return 0; 15 | t->Execute(); 16 | t->FinishedEvent.Set(); 17 | } 18 | } 19 | 20 | WRes CVirtThread::Create() 21 | { 22 | RINOK(StartEvent.CreateIfNotCreated()); 23 | RINOK(FinishedEvent.CreateIfNotCreated()); 24 | StartEvent.Reset(); 25 | FinishedEvent.Reset(); 26 | Exit = false; 27 | if (Thread.IsCreated()) 28 | return S_OK; 29 | return Thread.Create(CoderThread, this); 30 | } 31 | 32 | void CVirtThread::Start() 33 | { 34 | Exit = false; 35 | StartEvent.Set(); 36 | } 37 | 38 | void CVirtThread::WaitThreadFinish() 39 | { 40 | Exit = true; 41 | if (StartEvent.IsCreated()) 42 | StartEvent.Set(); 43 | if (Thread.IsCreated()) 44 | { 45 | Thread.Wait(); 46 | Thread.Close(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Common/VirtThread.h: -------------------------------------------------------------------------------- 1 | // VirtThread.h 2 | 3 | #ifndef __VIRT_THREAD_H 4 | #define __VIRT_THREAD_H 5 | 6 | #include "../../Windows/Synchronization.h" 7 | #include "../../Windows/Thread.h" 8 | 9 | struct CVirtThread 10 | { 11 | NWindows::NSynchronization::CAutoResetEvent StartEvent; 12 | NWindows::NSynchronization::CAutoResetEvent FinishedEvent; 13 | NWindows::CThread Thread; 14 | bool Exit; 15 | 16 | ~CVirtThread() { WaitThreadFinish(); } 17 | void WaitThreadFinish(); // call it in destructor of child class ! 18 | WRes Create(); 19 | void Start(); 20 | virtual void Execute() = 0; 21 | void WaitExecuteFinish() { FinishedEvent.Lock(); } 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BZip2Const.h: -------------------------------------------------------------------------------- 1 | // Compress/BZip2Const.h 2 | 3 | #ifndef __COMPRESS_BZIP2_CONST_H 4 | #define __COMPRESS_BZIP2_CONST_H 5 | 6 | namespace NCompress { 7 | namespace NBZip2 { 8 | 9 | const Byte kArSig0 = 'B'; 10 | const Byte kArSig1 = 'Z'; 11 | const Byte kArSig2 = 'h'; 12 | const Byte kArSig3 = '0'; 13 | 14 | const Byte kFinSig0 = 0x17; 15 | const Byte kFinSig1 = 0x72; 16 | const Byte kFinSig2 = 0x45; 17 | const Byte kFinSig3 = 0x38; 18 | const Byte kFinSig4 = 0x50; 19 | const Byte kFinSig5 = 0x90; 20 | 21 | const Byte kBlockSig0 = 0x31; 22 | const Byte kBlockSig1 = 0x41; 23 | const Byte kBlockSig2 = 0x59; 24 | const Byte kBlockSig3 = 0x26; 25 | const Byte kBlockSig4 = 0x53; 26 | const Byte kBlockSig5 = 0x59; 27 | 28 | const unsigned kNumOrigBits = 24; 29 | 30 | const unsigned kNumTablesBits = 3; 31 | const unsigned kNumTablesMin = 2; 32 | const unsigned kNumTablesMax = 6; 33 | 34 | const unsigned kNumLevelsBits = 5; 35 | 36 | const unsigned kMaxHuffmanLen = 20; // Check it 37 | 38 | const unsigned kMaxAlphaSize = 258; 39 | 40 | const unsigned kGroupSize = 50; 41 | 42 | const unsigned kBlockSizeMultMin = 1; 43 | const unsigned kBlockSizeMultMax = 9; 44 | 45 | const UInt32 kBlockSizeStep = 100000; 46 | const UInt32 kBlockSizeMax = kBlockSizeMultMax * kBlockSizeStep; 47 | 48 | const unsigned kNumSelectorsBits = 15; 49 | const UInt32 kNumSelectorsMax = (2 + (kBlockSizeMax / kGroupSize)); 50 | 51 | const unsigned kRleModeRepSize = 4; 52 | 53 | }} 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BZip2Crc.cpp: -------------------------------------------------------------------------------- 1 | // BZip2Crc.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "BZip2Crc.h" 6 | 7 | UInt32 CBZip2Crc::Table[256]; 8 | 9 | static const UInt32 kBZip2CrcPoly = 0x04c11db7; /* AUTODIN II, Ethernet, & FDDI */ 10 | 11 | void CBZip2Crc::InitTable() 12 | { 13 | for (UInt32 i = 0; i < 256; i++) 14 | { 15 | UInt32 r = (i << 24); 16 | for (int j = 8; j > 0; j--) 17 | r = (r & 0x80000000) ? ((r << 1) ^ kBZip2CrcPoly) : (r << 1); 18 | Table[i] = r; 19 | } 20 | } 21 | 22 | class CBZip2CrcTableInit 23 | { 24 | public: 25 | CBZip2CrcTableInit() { CBZip2Crc::InitTable(); } 26 | } g_BZip2CrcTableInit; 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BZip2Crc.h: -------------------------------------------------------------------------------- 1 | // BZip2Crc.h 2 | 3 | #ifndef __BZIP2_CRC_H 4 | #define __BZIP2_CRC_H 5 | 6 | #include "../../Common/MyTypes.h" 7 | 8 | class CBZip2Crc 9 | { 10 | UInt32 _value; 11 | static UInt32 Table[256]; 12 | public: 13 | static void InitTable(); 14 | CBZip2Crc(): _value(0xFFFFFFFF) {}; 15 | void Init() { _value = 0xFFFFFFFF; } 16 | void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); } 17 | void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); } 18 | UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; } 19 | }; 20 | 21 | class CBZip2CombinedCrc 22 | { 23 | UInt32 _value; 24 | public: 25 | CBZip2CombinedCrc(): _value(0){}; 26 | void Init() { _value = 0; } 27 | void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; } 28 | UInt32 GetDigest() const { return _value ; } 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BZip2Register.cpp: -------------------------------------------------------------------------------- 1 | // BZip2Register.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "BZip2Decoder.h" 8 | #if !defined(EXTRACT_ONLY) && !defined(BZIP2_EXTRACT_ONLY) 9 | #include "BZip2Encoder.h" 10 | #endif 11 | 12 | namespace NCompress { 13 | namespace NBZip2 { 14 | 15 | REGISTER_CODEC_CREATE(CreateDec, CDecoder) 16 | 17 | #if !defined(EXTRACT_ONLY) && !defined(BZIP2_EXTRACT_ONLY) 18 | REGISTER_CODEC_CREATE(CreateEnc, CEncoder) 19 | #else 20 | #define CreateEnc NULL 21 | #endif 22 | 23 | REGISTER_CODEC_2(BZip2, CreateDec, CreateEnc, 0x40202, "BZip2") 24 | 25 | }} 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/Bcj2Register.cpp: -------------------------------------------------------------------------------- 1 | // Bcj2Register.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "Bcj2Coder.h" 8 | 9 | namespace NCompress { 10 | namespace NBcj2 { 11 | 12 | REGISTER_CODEC_CREATE_2(CreateCodec, CDecoder(), ICompressCoder2) 13 | #ifndef EXTRACT_ONLY 14 | REGISTER_CODEC_CREATE_2(CreateCodecOut, CEncoder(), ICompressCoder2) 15 | #else 16 | #define CreateCodecOut NULL 17 | #endif 18 | 19 | REGISTER_CODEC_VAR 20 | { CreateCodec, CreateCodecOut, 0x303011B, "BCJ2", 4, false }; 21 | 22 | REGISTER_CODEC(BCJ2) 23 | 24 | }} 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BcjCoder.cpp: -------------------------------------------------------------------------------- 1 | // BcjCoder.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "BcjCoder.h" 6 | 7 | namespace NCompress { 8 | namespace NBcj { 9 | 10 | STDMETHODIMP CCoder::Init() 11 | { 12 | _bufferPos = 0; 13 | x86_Convert_Init(_prevMask); 14 | return S_OK; 15 | } 16 | 17 | STDMETHODIMP_(UInt32) CCoder::Filter(Byte *data, UInt32 size) 18 | { 19 | UInt32 processed = (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, _encode); 20 | _bufferPos += processed; 21 | return processed; 22 | } 23 | 24 | }} 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BcjCoder.h: -------------------------------------------------------------------------------- 1 | // BcjCoder.h 2 | 3 | #ifndef __COMPRESS_BCJ_CODER_H 4 | #define __COMPRESS_BCJ_CODER_H 5 | 6 | #include "../../../C/Bra.h" 7 | 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../ICoder.h" 11 | 12 | namespace NCompress { 13 | namespace NBcj { 14 | 15 | class CCoder: 16 | public ICompressFilter, 17 | public CMyUnknownImp 18 | { 19 | UInt32 _bufferPos; 20 | UInt32 _prevMask; 21 | int _encode; 22 | public: 23 | MY_UNKNOWN_IMP1(ICompressFilter); 24 | INTERFACE_ICompressFilter(;) 25 | 26 | CCoder(int encode): _bufferPos(0), _encode(encode) { x86_Convert_Init(_prevMask); } 27 | }; 28 | 29 | }} 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BcjRegister.cpp: -------------------------------------------------------------------------------- 1 | // BcjRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "BcjCoder.h" 8 | 9 | namespace NCompress { 10 | namespace NBcj { 11 | 12 | REGISTER_FILTER_E(BCJ, 13 | CCoder(false), 14 | CCoder(true), 15 | 0x3030103, "BCJ") 16 | 17 | }} 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BitlDecoder.cpp: -------------------------------------------------------------------------------- 1 | // BitlDecoder.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "BitlDecoder.h" 6 | 7 | namespace NBitl { 8 | 9 | Byte kInvertTable[256]; 10 | 11 | struct CInverterTableInitializer 12 | { 13 | CInverterTableInitializer() 14 | { 15 | for (unsigned i = 0; i < 256; i++) 16 | { 17 | unsigned x = ((i & 0x55) << 1) | ((i & 0xAA) >> 1); 18 | x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2); 19 | kInvertTable[i] = (Byte)(((x & 0x0F) << 4) | ((x & 0xF0) >> 4)); 20 | } 21 | } 22 | } g_InverterTableInitializer; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BitmEncoder.h: -------------------------------------------------------------------------------- 1 | // BitmEncoder.h -- the Most Significant Bit of byte is First 2 | 3 | #ifndef __BITM_ENCODER_H 4 | #define __BITM_ENCODER_H 5 | 6 | #include "../IStream.h" 7 | 8 | template 9 | class CBitmEncoder 10 | { 11 | unsigned _bitPos; 12 | Byte _curByte; 13 | TOutByte _stream; 14 | public: 15 | bool Create(UInt32 bufferSize) { return _stream.Create(bufferSize); } 16 | void SetStream(ISequentialOutStream *outStream) { _stream.SetStream(outStream);} 17 | UInt64 GetProcessedSize() const { return _stream.GetProcessedSize() + ((8 - _bitPos + 7) >> 3); } 18 | void Init() 19 | { 20 | _stream.Init(); 21 | _bitPos = 8; 22 | _curByte = 0; 23 | } 24 | HRESULT Flush() 25 | { 26 | if (_bitPos < 8) 27 | WriteBits(0, _bitPos); 28 | return _stream.Flush(); 29 | } 30 | void WriteBits(UInt32 value, unsigned numBits) 31 | { 32 | while (numBits > 0) 33 | { 34 | if (numBits < _bitPos) 35 | { 36 | _curByte |= ((Byte)value << (_bitPos -= numBits)); 37 | return; 38 | } 39 | numBits -= _bitPos; 40 | UInt32 newBits = (value >> numBits); 41 | value -= (newBits << numBits); 42 | _stream.WriteByte((Byte)(_curByte | newBits)); 43 | _bitPos = 8; 44 | _curByte = 0; 45 | } 46 | } 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BranchMisc.cpp: -------------------------------------------------------------------------------- 1 | // BranchMisc.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "BranchMisc.h" 6 | 7 | namespace NCompress { 8 | namespace NBranch { 9 | 10 | STDMETHODIMP CCoder::Init() 11 | { 12 | _bufferPos = 0; 13 | return S_OK; 14 | } 15 | 16 | STDMETHODIMP_(UInt32) CCoder::Filter(Byte *data, UInt32 size) 17 | { 18 | UInt32 processed = (UInt32)BraFunc(data, size, _bufferPos, _encode); 19 | _bufferPos += processed; 20 | return processed; 21 | } 22 | 23 | }} 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BranchMisc.h: -------------------------------------------------------------------------------- 1 | // BranchMisc.h 2 | 3 | #ifndef __COMPRESS_BRANCH_MISC_H 4 | #define __COMPRESS_BRANCH_MISC_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | typedef SizeT (*Func_Bra)(Byte *data, SizeT size, UInt32 ip, int encoding); 13 | 14 | EXTERN_C_END 15 | 16 | namespace NCompress { 17 | namespace NBranch { 18 | 19 | class CCoder: 20 | public ICompressFilter, 21 | public CMyUnknownImp 22 | { 23 | UInt32 _bufferPos; 24 | int _encode; 25 | Func_Bra BraFunc; 26 | public: 27 | MY_UNKNOWN_IMP1(ICompressFilter); 28 | INTERFACE_ICompressFilter(;) 29 | 30 | CCoder(Func_Bra bra, int encode): _bufferPos(0), _encode(encode), BraFunc(bra) {} 31 | }; 32 | 33 | }} 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/BranchRegister.cpp: -------------------------------------------------------------------------------- 1 | // BranchRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../../C/Bra.h" 6 | 7 | #include "../Common/RegisterCodec.h" 8 | 9 | #include "BranchMisc.h" 10 | 11 | namespace NCompress { 12 | namespace NBranch { 13 | 14 | #define CREATE_BRA(n) \ 15 | REGISTER_FILTER_CREATE(CreateBra_Decoder_ ## n, CCoder(n ## _Convert, false)) \ 16 | REGISTER_FILTER_CREATE(CreateBra_Encoder_ ## n, CCoder(n ## _Convert, true)) \ 17 | 18 | CREATE_BRA(PPC) 19 | CREATE_BRA(IA64) 20 | CREATE_BRA(ARM) 21 | CREATE_BRA(ARMT) 22 | CREATE_BRA(SPARC) 23 | 24 | #define METHOD_ITEM(n, id, name) \ 25 | REGISTER_FILTER_ITEM( \ 26 | CreateBra_Decoder_ ## n, \ 27 | CreateBra_Encoder_ ## n, \ 28 | 0x3030000 + id, name) 29 | 30 | REGISTER_CODECS_VAR 31 | { 32 | METHOD_ITEM(PPC, 0x205, "PPC"), 33 | METHOD_ITEM(IA64, 0x401, "IA64"), 34 | METHOD_ITEM(ARM, 0x501, "ARM"), 35 | METHOD_ITEM(ARMT, 0x701, "ARMT"), 36 | METHOD_ITEM(SPARC, 0x805, "SPARC") 37 | }; 38 | 39 | REGISTER_CODECS(Branch) 40 | 41 | }} 42 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/CopyCoder.h: -------------------------------------------------------------------------------- 1 | // Compress/CopyCoder.h 2 | 3 | #ifndef __COMPRESS_COPY_CODER_H 4 | #define __COMPRESS_COPY_CODER_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | 10 | namespace NCompress { 11 | 12 | class CCopyCoder: 13 | public ICompressCoder, 14 | public ICompressSetInStream, 15 | public ISequentialInStream, 16 | public ICompressGetInStreamProcessedSize, 17 | public CMyUnknownImp 18 | { 19 | Byte *_buf; 20 | CMyComPtr _inStream; 21 | public: 22 | UInt64 TotalSize; 23 | 24 | CCopyCoder(): _buf(0), TotalSize(0) {}; 25 | ~CCopyCoder(); 26 | 27 | MY_UNKNOWN_IMP4( 28 | ICompressCoder, 29 | ICompressSetInStream, 30 | ISequentialInStream, 31 | ICompressGetInStreamProcessedSize) 32 | 33 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 34 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 35 | STDMETHOD(SetInStream)(ISequentialInStream *inStream); 36 | STDMETHOD(ReleaseInStream)(); 37 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 38 | STDMETHOD(GetInStreamProcessedSize)(UInt64 *value); 39 | }; 40 | 41 | HRESULT CopyStream(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress); 42 | HRESULT CopyStream_ExactSize(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt64 size, ICompressProgressInfo *progress); 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/CopyRegister.cpp: -------------------------------------------------------------------------------- 1 | // CopyRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "CopyCoder.h" 8 | 9 | namespace NCompress { 10 | 11 | REGISTER_CODEC_CREATE(CreateCodec, CCopyCoder()) 12 | 13 | REGISTER_CODEC_2(Copy, CreateCodec, CreateCodec, 0, "Copy") 14 | 15 | } 16 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/Deflate64Register.cpp: -------------------------------------------------------------------------------- 1 | // Deflate64Register.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "DeflateDecoder.h" 8 | 9 | #if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY) 10 | #include "DeflateEncoder.h" 11 | #endif 12 | 13 | namespace NCompress { 14 | namespace NDeflate { 15 | 16 | REGISTER_CODEC_CREATE(CreateDec, NDecoder::CCOMCoder64()) 17 | 18 | #if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY) 19 | REGISTER_CODEC_CREATE(CreateEnc, NEncoder::CCOMCoder64()) 20 | #else 21 | #define CreateEnc NULL 22 | #endif 23 | 24 | REGISTER_CODEC_2(Deflate64, CreateDec, CreateEnc, 0x40109, "Deflate64") 25 | 26 | }} 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/DeflateRegister.cpp: -------------------------------------------------------------------------------- 1 | // DeflateRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "DeflateDecoder.h" 8 | #if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY) 9 | #include "DeflateEncoder.h" 10 | #endif 11 | 12 | namespace NCompress { 13 | namespace NDeflate { 14 | 15 | REGISTER_CODEC_CREATE(CreateDec, NDecoder::CCOMCoder) 16 | 17 | #if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY) 18 | REGISTER_CODEC_CREATE(CreateEnc, NEncoder::CCOMCoder) 19 | #else 20 | #define CreateEnc NULL 21 | #endif 22 | 23 | REGISTER_CODEC_2(Deflate, CreateDec, CreateEnc, 0x40108, "Deflate") 24 | 25 | }} 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h: -------------------------------------------------------------------------------- 1 | // ImplodeHuffmanDecoder.h 2 | 3 | #ifndef __IMPLODE_HUFFMAN_DECODER_H 4 | #define __IMPLODE_HUFFMAN_DECODER_H 5 | 6 | #include "../Common/InBuffer.h" 7 | 8 | #include "BitlDecoder.h" 9 | 10 | namespace NCompress { 11 | namespace NImplode { 12 | namespace NHuffman { 13 | 14 | const unsigned kNumBitsInLongestCode = 16; 15 | 16 | typedef NBitl::CDecoder CInBit; 17 | 18 | class CDecoder 19 | { 20 | UInt32 m_Limitits[kNumBitsInLongestCode + 2]; // m_Limitits[i] = value limit for symbols with length = i 21 | UInt32 m_Positions[kNumBitsInLongestCode + 2]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i 22 | UInt32 m_NumSymbols; // number of symbols in m_Symbols 23 | UInt32 *m_Symbols; // symbols: at first with len=1 then 2, ... 15. 24 | public: 25 | CDecoder(UInt32 numSymbols); 26 | ~CDecoder(); 27 | 28 | bool SetCodeLengths(const Byte *codeLengths); 29 | UInt32 DecodeSymbol(CInBit *inStream); 30 | }; 31 | 32 | }}} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/LzOutWindow.cpp: -------------------------------------------------------------------------------- 1 | // LzOutWindow.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "LzOutWindow.h" 6 | 7 | void CLzOutWindow::Init(bool solid) throw() 8 | { 9 | if (!solid) 10 | COutBuffer::Init(); 11 | #ifdef _NO_EXCEPTIONS 12 | ErrorCode = S_OK; 13 | #endif 14 | } 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/Lzma2Encoder.h: -------------------------------------------------------------------------------- 1 | // Lzma2Encoder.h 2 | 3 | #ifndef __LZMA2_ENCODER_H 4 | #define __LZMA2_ENCODER_H 5 | 6 | #include "../../../C/Lzma2Enc.h" 7 | 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../ICoder.h" 11 | 12 | namespace NCompress { 13 | namespace NLzma2 { 14 | 15 | class CEncoder: 16 | public ICompressCoder, 17 | public ICompressSetCoderProperties, 18 | public ICompressWriteCoderProperties, 19 | public CMyUnknownImp 20 | { 21 | CLzma2EncHandle _encoder; 22 | public: 23 | MY_UNKNOWN_IMP3(ICompressCoder, ICompressSetCoderProperties, ICompressWriteCoderProperties) 24 | 25 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 26 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 27 | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); 28 | STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); 29 | 30 | CEncoder(); 31 | virtual ~CEncoder(); 32 | }; 33 | 34 | }} 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/Lzma2Register.cpp: -------------------------------------------------------------------------------- 1 | // Lzma2Register.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "Lzma2Decoder.h" 8 | 9 | #ifndef EXTRACT_ONLY 10 | #include "Lzma2Encoder.h" 11 | #endif 12 | 13 | namespace NCompress { 14 | namespace NLzma2 { 15 | 16 | REGISTER_CODEC_E(LZMA2, 17 | CDecoder(), 18 | CEncoder(), 19 | 0x21, 20 | "LZMA2") 21 | 22 | }} 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/LzmaEncoder.h: -------------------------------------------------------------------------------- 1 | // LzmaEncoder.h 2 | 3 | #ifndef __LZMA_ENCODER_H 4 | #define __LZMA_ENCODER_H 5 | 6 | #include "../../../C/LzmaEnc.h" 7 | 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../ICoder.h" 11 | 12 | namespace NCompress { 13 | namespace NLzma { 14 | 15 | class CEncoder: 16 | public ICompressCoder, 17 | public ICompressSetCoderProperties, 18 | public ICompressWriteCoderProperties, 19 | public CMyUnknownImp 20 | { 21 | CLzmaEncHandle _encoder; 22 | UInt64 _inputProcessed; 23 | public: 24 | MY_UNKNOWN_IMP3(ICompressCoder, ICompressSetCoderProperties, ICompressWriteCoderProperties) 25 | 26 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 27 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 28 | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); 29 | STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); 30 | 31 | CEncoder(); 32 | virtual ~CEncoder(); 33 | UInt64 GetInputProcessedSize() const { return _inputProcessed; } 34 | }; 35 | 36 | }} 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/LzmaRegister.cpp: -------------------------------------------------------------------------------- 1 | // LzmaRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "LzmaDecoder.h" 8 | 9 | #ifndef EXTRACT_ONLY 10 | #include "LzmaEncoder.h" 11 | #endif 12 | 13 | namespace NCompress { 14 | namespace NLzma { 15 | 16 | REGISTER_CODEC_E(LZMA, 17 | CDecoder(), 18 | CEncoder(), 19 | 0x30101, 20 | "LZMA") 21 | 22 | }} 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/PpmdEncoder.h: -------------------------------------------------------------------------------- 1 | // PpmdEncoder.h 2 | 3 | #ifndef __COMPRESS_PPMD_ENCODER_H 4 | #define __COMPRESS_PPMD_ENCODER_H 5 | 6 | #include "../../../C/Ppmd7.h" 7 | 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../ICoder.h" 11 | 12 | #include "../Common/CWrappers.h" 13 | 14 | namespace NCompress { 15 | namespace NPpmd { 16 | 17 | struct CEncProps 18 | { 19 | UInt32 MemSize; 20 | UInt32 ReduceSize; 21 | int Order; 22 | 23 | CEncProps() 24 | { 25 | MemSize = (UInt32)(Int32)-1; 26 | ReduceSize = (UInt32)(Int32)-1; 27 | Order = -1; 28 | } 29 | void Normalize(int level); 30 | }; 31 | 32 | class CEncoder : 33 | public ICompressCoder, 34 | public ICompressSetCoderProperties, 35 | public ICompressWriteCoderProperties, 36 | public CMyUnknownImp 37 | { 38 | Byte *_inBuf; 39 | CByteOutBufWrap _outStream; 40 | CPpmd7z_RangeEnc _rangeEnc; 41 | CPpmd7 _ppmd; 42 | CEncProps _props; 43 | public: 44 | MY_UNKNOWN_IMP3( 45 | ICompressCoder, 46 | ICompressSetCoderProperties, 47 | ICompressWriteCoderProperties) 48 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 49 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 50 | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); 51 | STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); 52 | CEncoder(); 53 | ~CEncoder(); 54 | }; 55 | 56 | }} 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/PpmdRegister.cpp: -------------------------------------------------------------------------------- 1 | // PpmdRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "PpmdDecoder.h" 8 | 9 | #ifndef EXTRACT_ONLY 10 | #include "PpmdEncoder.h" 11 | #endif 12 | 13 | namespace NCompress { 14 | namespace NPpmd { 15 | 16 | REGISTER_CODEC_E(PPMD, 17 | CDecoder(), 18 | CEncoder(), 19 | 0x30401, 20 | "PPMD") 21 | 22 | }} 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp: -------------------------------------------------------------------------------- 1 | // RarCodecsRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "Rar1Decoder.h" 8 | #include "Rar2Decoder.h" 9 | #include "Rar3Decoder.h" 10 | #include "Rar5Decoder.h" 11 | 12 | namespace NCompress { 13 | 14 | #define CREATE_CODEC(x) REGISTER_CODEC_CREATE(CreateCodec ## x, NRar ## x::CDecoder()) 15 | 16 | CREATE_CODEC(1) 17 | CREATE_CODEC(2) 18 | CREATE_CODEC(3) 19 | CREATE_CODEC(5) 20 | 21 | #define RAR_CODEC(x, name) { CreateCodec ## x, NULL, 0x40300 + x, "Rar" name, 1, false } 22 | 23 | REGISTER_CODECS_VAR 24 | { 25 | RAR_CODEC(1, "1"), 26 | RAR_CODEC(2, "2"), 27 | RAR_CODEC(3, "3"), 28 | RAR_CODEC(5, "5"), 29 | }; 30 | 31 | REGISTER_CODECS(Rar) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/ShrinkDecoder.h: -------------------------------------------------------------------------------- 1 | // ShrinkDecoder.h 2 | 3 | #ifndef __COMPRESS_SHRINK_DECODER_H 4 | #define __COMPRESS_SHRINK_DECODER_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | 10 | namespace NCompress { 11 | namespace NShrink { 12 | 13 | const unsigned kNumMaxBits = 13; 14 | const unsigned kNumItems = 1 << kNumMaxBits; 15 | 16 | class CDecoder : 17 | public ICompressCoder, 18 | public CMyUnknownImp 19 | { 20 | UInt16 _parents[kNumItems]; 21 | Byte _suffixes[kNumItems]; 22 | Byte _stack[kNumItems]; 23 | 24 | public: 25 | MY_UNKNOWN_IMP 26 | 27 | HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, 28 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 29 | 30 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 31 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 32 | }; 33 | 34 | }} 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/XpressDecoder.h: -------------------------------------------------------------------------------- 1 | // XpressDecoder.h 2 | 3 | #ifndef __XPRESS_DECODER_H 4 | #define __XPRESS_DECODER_H 5 | 6 | namespace NCompress { 7 | namespace NXpress { 8 | 9 | HRESULT Decode(const Byte *in, size_t inSize, Byte *out, size_t outSize); 10 | 11 | }} 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Compress/ZlibEncoder.h: -------------------------------------------------------------------------------- 1 | // ZlibEncoder.h 2 | 3 | #ifndef __ZLIB_ENCODER_H 4 | #define __ZLIB_ENCODER_H 5 | 6 | #include "DeflateEncoder.h" 7 | 8 | namespace NCompress { 9 | namespace NZlib { 10 | 11 | class CInStreamWithAdler: 12 | public ISequentialInStream, 13 | public CMyUnknownImp 14 | { 15 | CMyComPtr _stream; 16 | UInt32 _adler; 17 | UInt64 _size; 18 | public: 19 | MY_UNKNOWN_IMP 20 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 21 | void SetStream(ISequentialInStream *stream) { _stream = stream; } 22 | void ReleaseStream() { _stream.Release(); } 23 | void Init() { _adler = 1; _size = 0; } // ADLER_INIT_VAL 24 | UInt32 GetAdler() const { return _adler; } 25 | UInt64 GetSize() const { return _size; } 26 | }; 27 | 28 | class CEncoder: 29 | public ICompressCoder, 30 | public CMyUnknownImp 31 | { 32 | CInStreamWithAdler *AdlerSpec; 33 | CMyComPtr AdlerStream; 34 | CMyComPtr DeflateEncoder; 35 | public: 36 | NCompress::NDeflate::NEncoder::CCOMCoder *DeflateEncoderSpec; 37 | 38 | void Create(); 39 | STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 40 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 41 | UInt64 GetInputProcessedSize() const { return AdlerSpec->GetSize(); } 42 | 43 | MY_UNKNOWN_IMP 44 | }; 45 | 46 | }} 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp: -------------------------------------------------------------------------------- 1 | // 7zAesRegister.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "7zAes.h" 8 | 9 | namespace NCrypto { 10 | namespace N7z { 11 | 12 | REGISTER_FILTER_E(7zAES, 13 | CDecoder(), 14 | CEncoder(), 15 | 0x6F10701, "7zAES") 16 | 17 | }} 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/HmacSha1.h: -------------------------------------------------------------------------------- 1 | // HmacSha1.h 2 | // Implements HMAC-SHA-1 (RFC2104, FIPS-198) 3 | 4 | #ifndef __CRYPTO_HMAC_SHA1_H 5 | #define __CRYPTO_HMAC_SHA1_H 6 | 7 | #include "Sha1Cls.h" 8 | 9 | namespace NCrypto { 10 | namespace NSha1 { 11 | 12 | // Use: SetKey(key, keySize); for () Update(data, size); Final(mac, macSize); 13 | 14 | class CHmac 15 | { 16 | CContext _sha; 17 | CContext _sha2; 18 | public: 19 | void SetKey(const Byte *key, size_t keySize); 20 | void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); } 21 | void Final(Byte *mac, size_t macSize = kDigestSize); 22 | }; 23 | 24 | class CHmac32 25 | { 26 | CContext32 _sha; 27 | CContext32 _sha2; 28 | public: 29 | void SetKey(const Byte *key, size_t keySize); 30 | void Update(const UInt32 *data, size_t dataSize) { _sha.Update(data, dataSize); } 31 | void Final(UInt32 *mac, size_t macSize = kNumDigestWords); 32 | 33 | // It'sa for hmac function. in,out: mac[kNumDigestWords]. 34 | void GetLoopXorDigest(UInt32 *mac, UInt32 numIteration); 35 | }; 36 | 37 | }} 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/HmacSha256.cpp: -------------------------------------------------------------------------------- 1 | // HmacSha256.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../../C/CpuArch.h" 6 | 7 | #include "HmacSha256.h" 8 | 9 | namespace NCrypto { 10 | namespace NSha256 { 11 | 12 | static const unsigned kBlockSize = 64; 13 | 14 | void CHmac::SetKey(const Byte *key, size_t keySize) 15 | { 16 | Byte temp[kBlockSize]; 17 | size_t i; 18 | 19 | for (i = 0; i < kBlockSize; i++) 20 | temp[i] = 0; 21 | 22 | if (keySize > kBlockSize) 23 | { 24 | Sha256_Init(&_sha); 25 | Sha256_Update(&_sha, key, keySize); 26 | Sha256_Final(&_sha, temp); 27 | } 28 | else 29 | for (i = 0; i < keySize; i++) 30 | temp[i] = key[i]; 31 | 32 | for (i = 0; i < kBlockSize; i++) 33 | temp[i] ^= 0x36; 34 | 35 | Sha256_Init(&_sha); 36 | Sha256_Update(&_sha, temp, kBlockSize); 37 | 38 | for (i = 0; i < kBlockSize; i++) 39 | temp[i] ^= 0x36 ^ 0x5C; 40 | 41 | Sha256_Init(&_sha2); 42 | Sha256_Update(&_sha2, temp, kBlockSize); 43 | } 44 | 45 | void CHmac::Final(Byte *mac) 46 | { 47 | Sha256_Final(&_sha, mac); 48 | Sha256_Update(&_sha2, mac, SHA256_DIGEST_SIZE); 49 | Sha256_Final(&_sha2, mac); 50 | } 51 | 52 | /* 53 | void CHmac::Final(Byte *mac, size_t macSize) 54 | { 55 | Byte digest[SHA256_DIGEST_SIZE]; 56 | Final(digest); 57 | for (size_t i = 0; i < macSize; i++) 58 | mac[i] = digest[i]; 59 | } 60 | */ 61 | 62 | }} 63 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/HmacSha256.h: -------------------------------------------------------------------------------- 1 | // HmacSha256.h 2 | // Implements HMAC-SHA-256 (RFC2104, FIPS-198) 3 | 4 | #ifndef __CRYPTO_HMAC_SHA256_H 5 | #define __CRYPTO_HMAC_SHA256_H 6 | 7 | #include "../../../C/Sha256.h" 8 | 9 | namespace NCrypto { 10 | namespace NSha256 { 11 | 12 | const unsigned kDigestSize = SHA256_DIGEST_SIZE; 13 | 14 | class CHmac 15 | { 16 | CSha256 _sha; 17 | CSha256 _sha2; 18 | public: 19 | void SetKey(const Byte *key, size_t keySize); 20 | void Update(const Byte *data, size_t dataSize) { Sha256_Update(&_sha, data, dataSize); } 21 | void Final(Byte *mac); 22 | // void Final(Byte *mac, size_t macSize); 23 | }; 24 | 25 | }} 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/MyAes.h: -------------------------------------------------------------------------------- 1 | // Crypto/MyAes.h 2 | 3 | #ifndef __CRYPTO_MY_AES_H 4 | #define __CRYPTO_MY_AES_H 5 | 6 | #include "../../../C/Aes.h" 7 | 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../ICoder.h" 11 | 12 | namespace NCrypto { 13 | 14 | class CAesCbcCoder: 15 | public ICompressFilter, 16 | public ICryptoProperties, 17 | public ICompressSetCoderProperties, 18 | public CMyUnknownImp 19 | { 20 | AES_CODE_FUNC _codeFunc; 21 | unsigned _offset; 22 | unsigned _keySize; 23 | bool _keyIsSet; 24 | bool _encodeMode; 25 | UInt32 _aes[AES_NUM_IVMRK_WORDS + 3]; 26 | Byte _iv[AES_BLOCK_SIZE]; 27 | 28 | bool SetFunctions(UInt32 algo); 29 | 30 | public: 31 | CAesCbcCoder(bool encodeMode, unsigned keySize); 32 | 33 | MY_UNKNOWN_IMP3(ICompressFilter, ICryptoProperties, ICompressSetCoderProperties) 34 | 35 | INTERFACE_ICompressFilter(;) 36 | 37 | STDMETHOD(SetKey)(const Byte *data, UInt32 size); 38 | STDMETHOD(SetInitVector)(const Byte *data, UInt32 size); 39 | 40 | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); 41 | }; 42 | 43 | struct CAesCbcEncoder: public CAesCbcCoder 44 | { 45 | CAesCbcEncoder(unsigned keySize = 0): CAesCbcCoder(true, keySize) {} 46 | }; 47 | 48 | struct CAesCbcDecoder: public CAesCbcCoder 49 | { 50 | CAesCbcDecoder(unsigned keySize = 0): CAesCbcCoder(false, keySize) {} 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/MyAesReg.cpp: -------------------------------------------------------------------------------- 1 | // MyAesReg.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/RegisterCodec.h" 6 | 7 | #include "MyAes.h" 8 | 9 | namespace NCrypto { 10 | 11 | REGISTER_FILTER_E(AES256CBC, 12 | CAesCbcDecoder(32), 13 | CAesCbcEncoder(32), 14 | 0x6F00181, "AES256CBC") 15 | 16 | } 17 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h: -------------------------------------------------------------------------------- 1 | // Pbkdf2HmacSha1.h 2 | // Password-Based Key Derivation Function (RFC 2898, PKCS #5) based on HMAC-SHA-1 3 | 4 | #ifndef __CRYPTO_PBKDF2_HMAC_SHA1_H 5 | #define __CRYPTO_PBKDF2_HMAC_SHA1_H 6 | 7 | #include 8 | 9 | #include "../../Common/MyTypes.h" 10 | 11 | namespace NCrypto { 12 | namespace NSha1 { 13 | 14 | void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize, 15 | UInt32 numIterations, Byte *key, size_t keySize); 16 | 17 | void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize, 18 | UInt32 numIterations, UInt32 *key, size_t keySize); 19 | 20 | }} 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/RandGen.h: -------------------------------------------------------------------------------- 1 | // RandGen.h 2 | 3 | #ifndef __CRYPTO_RAND_GEN_H 4 | #define __CRYPTO_RAND_GEN_H 5 | 6 | #include "../../../C/Sha256.h" 7 | 8 | class CRandomGenerator 9 | { 10 | Byte _buff[SHA256_DIGEST_SIZE]; 11 | bool _needInit; 12 | 13 | void Init(); 14 | public: 15 | CRandomGenerator(): _needInit(true) {}; 16 | void Generate(Byte *data, unsigned size); 17 | }; 18 | 19 | extern CRandomGenerator g_RandomGenerator; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/Rar20Crypto.h: -------------------------------------------------------------------------------- 1 | // Crypto/Rar20Crypto.h 2 | 3 | #ifndef __CRYPTO_RAR20_CRYPTO_H 4 | #define __CRYPTO_RAR20_CRYPTO_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | 10 | namespace NCrypto { 11 | namespace NRar2 { 12 | 13 | /* ICompressFilter::Init() does nothing for this filter. 14 | Call SetPassword() to initialize filter. */ 15 | 16 | class CData 17 | { 18 | Byte SubstTable[256]; 19 | UInt32 Keys[4]; 20 | 21 | UInt32 SubstLong(UInt32 t) const 22 | { 23 | return (UInt32)SubstTable[(unsigned)t & 255] 24 | | ((UInt32)SubstTable[(unsigned)(t >> 8) & 255] << 8) 25 | | ((UInt32)SubstTable[(unsigned)(t >> 16) & 255] << 16) 26 | | ((UInt32)SubstTable[(unsigned)(t >> 24) & 255] << 24); 27 | } 28 | void UpdateKeys(const Byte *data); 29 | void CryptBlock(Byte *buf, bool encrypt); 30 | public: 31 | void EncryptBlock(Byte *buf) { CryptBlock(buf, true); } 32 | void DecryptBlock(Byte *buf) { CryptBlock(buf, false); } 33 | void SetPassword(const Byte *password, unsigned passwordLen); 34 | }; 35 | 36 | class CDecoder: 37 | public ICompressFilter, 38 | public CMyUnknownImp, 39 | public CData 40 | { 41 | public: 42 | MY_UNKNOWN_IMP 43 | INTERFACE_ICompressFilter(;) 44 | }; 45 | 46 | }} 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/RarAes.h: -------------------------------------------------------------------------------- 1 | // Crypto/RarAes.h 2 | 3 | #ifndef __CRYPTO_RAR_AES_H 4 | #define __CRYPTO_RAR_AES_H 5 | 6 | #include "../../../C/Aes.h" 7 | 8 | #include "../../Common/MyBuffer.h" 9 | 10 | #include "../IPassword.h" 11 | 12 | #include "MyAes.h" 13 | 14 | namespace NCrypto { 15 | namespace NRar3 { 16 | 17 | const unsigned kAesKeySize = 16; 18 | 19 | class CDecoder: 20 | public CAesCbcDecoder 21 | // public ICompressSetDecoderProperties2, 22 | // public ICryptoSetPassword 23 | { 24 | Byte _salt[8]; 25 | bool _thereIsSalt; 26 | bool _needCalc; 27 | // bool _rar350Mode; 28 | 29 | CByteBuffer _password; 30 | 31 | Byte _key[kAesKeySize]; 32 | Byte _iv[AES_BLOCK_SIZE]; 33 | 34 | void CalcKey(); 35 | public: 36 | /* 37 | MY_UNKNOWN_IMP1( 38 | ICryptoSetPassword 39 | // ICompressSetDecoderProperties2 40 | */ 41 | STDMETHOD(Init)(); 42 | 43 | void SetPassword(const Byte *data, unsigned size); 44 | HRESULT SetDecoderProperties2(const Byte *data, UInt32 size); 45 | 46 | CDecoder(); 47 | // void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; } 48 | }; 49 | 50 | }} 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/Crypto/ZipStrong.h: -------------------------------------------------------------------------------- 1 | // Crypto/ZipStrong.h 2 | 3 | #ifndef __CRYPTO_ZIP_STRONG_H 4 | #define __CRYPTO_ZIP_STRONG_H 5 | 6 | #include "../../Common/MyBuffer.h" 7 | 8 | #include "../IPassword.h" 9 | 10 | #include "MyAes.h" 11 | 12 | namespace NCrypto { 13 | namespace NZipStrong { 14 | 15 | /* ICompressFilter::Init() does nothing for this filter. 16 | Call to init: 17 | Decoder: 18 | [CryptoSetPassword();] 19 | ReadHeader(); 20 | [CryptoSetPassword();] Init_and_CheckPassword(); 21 | [CryptoSetPassword();] Init_and_CheckPassword(); 22 | */ 23 | 24 | struct CKeyInfo 25 | { 26 | Byte MasterKey[32]; 27 | UInt32 KeySize; 28 | 29 | void SetPassword(const Byte *data, UInt32 size); 30 | }; 31 | 32 | class CBaseCoder: 33 | public CAesCbcDecoder, 34 | public ICryptoSetPassword 35 | { 36 | protected: 37 | CKeyInfo _key; 38 | CByteBuffer _buf; 39 | Byte *_bufAligned; 40 | public: 41 | STDMETHOD(Init)(); 42 | STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size); 43 | }; 44 | 45 | class CDecoder: public CBaseCoder 46 | { 47 | UInt32 _ivSize; 48 | Byte _iv[16]; 49 | UInt32 _remSize; 50 | public: 51 | MY_UNKNOWN_IMP1(ICryptoSetPassword) 52 | HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize); 53 | HRESULT Init_and_CheckPassword(bool &passwOK); 54 | }; 55 | 56 | }} 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/IDecl.h: -------------------------------------------------------------------------------- 1 | // IDecl.h 2 | 3 | #ifndef __IDECL_H 4 | #define __IDECL_H 5 | 6 | #include "../Common/MyUnknown.h" 7 | 8 | #define k_7zip_GUID_Data1 0x23170F69 9 | #define k_7zip_GUID_Data2 0x40C1 10 | 11 | #define k_7zip_GUID_Data3_Common 0x278A 12 | 13 | #define k_7zip_GUID_Data3_Decoder 0x2790 14 | #define k_7zip_GUID_Data3_Encoder 0x2791 15 | #define k_7zip_GUID_Data3_Hasher 0x2792 16 | 17 | 18 | #define DECL_INTERFACE_SUB(i, base, groupId, subId) \ 19 | DEFINE_GUID(IID_ ## i, \ 20 | k_7zip_GUID_Data1, \ 21 | k_7zip_GUID_Data2, \ 22 | k_7zip_GUID_Data3_Common, \ 23 | 0, 0, 0, (groupId), 0, (subId), 0, 0); \ 24 | struct i: public base 25 | 26 | #define DECL_INTERFACE(i, groupId, subId) DECL_INTERFACE_SUB(i, IUnknown, groupId, subId) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/IPassword.h: -------------------------------------------------------------------------------- 1 | // IPassword.h 2 | 3 | #ifndef __IPASSWORD_H 4 | #define __IPASSWORD_H 5 | 6 | #include "../Common/MyTypes.h" 7 | #include "../Common/MyUnknown.h" 8 | 9 | #include "IDecl.h" 10 | 11 | #define PASSWORD_INTERFACE(i, x) DECL_INTERFACE(i, 5, x) 12 | 13 | PASSWORD_INTERFACE(ICryptoGetTextPassword, 0x10) 14 | { 15 | STDMETHOD(CryptoGetTextPassword)(BSTR *password) PURE; 16 | }; 17 | 18 | PASSWORD_INTERFACE(ICryptoGetTextPassword2, 0x11) 19 | { 20 | STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password) PURE; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/IProgress.h: -------------------------------------------------------------------------------- 1 | // IProgress.h 2 | 3 | #ifndef __IPROGRESS_H 4 | #define __IPROGRESS_H 5 | 6 | #include "../Common/MyTypes.h" 7 | 8 | #include "IDecl.h" 9 | 10 | #define INTERFACE_IProgress(x) \ 11 | STDMETHOD(SetTotal)(UInt64 total) x; \ 12 | STDMETHOD(SetCompleted)(const UInt64 *completeValue) x; \ 13 | 14 | DECL_INTERFACE(IProgress, 0, 5) 15 | { 16 | INTERFACE_IProgress(PURE) 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/MyVersion.h: -------------------------------------------------------------------------------- 1 | #define USE_COPYRIGHT_CR 2 | #include "../../C/7zVersion.h" 3 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/ArchiveName.h: -------------------------------------------------------------------------------- 1 | // ArchiveName.h 2 | 3 | #ifndef __ARCHIVE_NAME_H 4 | #define __ARCHIVE_NAME_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | #include "../../../Windows/FileFind.h" 9 | 10 | UString CreateArchiveName(const UString &path, bool fromPrev, bool keepName); 11 | UString CreateArchiveName(const NWindows::NFile::NFind::CFileInfo &fileInfo, bool keepName); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/DefaultName.cpp: -------------------------------------------------------------------------------- 1 | // DefaultName.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "DefaultName.h" 6 | 7 | static UString GetDefaultName3(const UString &fileName, 8 | const UString &extension, const UString &addSubExtension) 9 | { 10 | const unsigned extLen = extension.Len(); 11 | const unsigned fileNameLen = fileName.Len(); 12 | 13 | if (fileNameLen > extLen + 1) 14 | { 15 | const unsigned dotPos = fileNameLen - (extLen + 1); 16 | if (fileName[dotPos] == '.') 17 | if (extension.IsEqualTo_NoCase(fileName.Ptr(dotPos + 1))) 18 | return fileName.Left(dotPos) + addSubExtension; 19 | } 20 | 21 | int dotPos = fileName.ReverseFind_Dot(); 22 | if (dotPos > 0) 23 | return fileName.Left(dotPos) + addSubExtension; 24 | 25 | if (addSubExtension.IsEmpty()) 26 | return fileName + L'~'; 27 | else 28 | return fileName + addSubExtension; 29 | } 30 | 31 | UString GetDefaultName2(const UString &fileName, 32 | const UString &extension, const UString &addSubExtension) 33 | { 34 | UString name = GetDefaultName3(fileName, extension, addSubExtension); 35 | name.TrimRight(); 36 | return name; 37 | } 38 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/DefaultName.h: -------------------------------------------------------------------------------- 1 | // DefaultName.h 2 | 3 | #ifndef __DEFAULT_NAME_H 4 | #define __DEFAULT_NAME_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | UString GetDefaultName2(const UString &fileName, 9 | const UString &extension, const UString &addSubExtension); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/EnumDirItems.h: -------------------------------------------------------------------------------- 1 | // EnumDirItems.h 2 | 3 | #ifndef __ENUM_DIR_ITEMS_H 4 | #define __ENUM_DIR_ITEMS_H 5 | 6 | #include "../../../Common/Wildcard.h" 7 | 8 | #include "../../../Windows/FileFind.h" 9 | 10 | #include "DirItem.h" 11 | 12 | void AddDirFileInfo(int phyParent, int logParent, int secureIndex, 13 | const NWindows::NFile::NFind::CFileInfo &fi, CObjectVector &dirItems); 14 | 15 | HRESULT EnumerateItems( 16 | const NWildcard::CCensor &censor, 17 | NWildcard::ECensorPathMode pathMode, 18 | const UString &addPathPrefix, 19 | CDirItems &dirItems); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/ExitCode.h: -------------------------------------------------------------------------------- 1 | // ExitCode.h 2 | 3 | #ifndef __EXIT_CODE_H 4 | #define __EXIT_CODE_H 5 | 6 | namespace NExitCode { 7 | 8 | enum EEnum { 9 | 10 | kSuccess = 0, // Successful operation 11 | kWarning = 1, // Non fatal error(s) occurred 12 | kFatalError = 2, // A fatal error occurred 13 | // kCRCError = 3, // A CRC error occurred when unpacking 14 | // kLockedArchive = 4, // Attempt to modify an archive previously locked 15 | // kWriteError = 5, // Write to disk error 16 | // kOpenError = 6, // Open file error 17 | kUserError = 7, // Command line option error 18 | kMemoryError = 8, // Not enough memory for operation 19 | // kCreateFileError = 9, // Create file error 20 | 21 | kUserBreak = 255 // User stopped the process 22 | 23 | }; 24 | 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/ExtractMode.h: -------------------------------------------------------------------------------- 1 | // ExtractMode.h 2 | 3 | #ifndef __EXTRACT_MODE_H 4 | #define __EXTRACT_MODE_H 5 | 6 | namespace NExtract { 7 | 8 | namespace NPathMode 9 | { 10 | enum EEnum 11 | { 12 | kFullPaths, 13 | kCurPaths, 14 | kNoPaths, 15 | kAbsPaths, 16 | kNoPathsAlt // alt streams must be extracted without name of base file 17 | }; 18 | } 19 | 20 | namespace NOverwriteMode 21 | { 22 | enum EEnum 23 | { 24 | kAsk, 25 | kOverwrite, 26 | kSkip, 27 | kRename, 28 | kRenameExisting 29 | }; 30 | } 31 | 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/ExtractingFilePath.h: -------------------------------------------------------------------------------- 1 | // ExtractingFilePath.h 2 | 3 | #ifndef __EXTRACTING_FILE_PATH_H 4 | #define __EXTRACTING_FILE_PATH_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | // #ifdef _WIN32 9 | void Correct_AltStream_Name(UString &s); 10 | // #endif 11 | 12 | // replaces unsuported characters, and replaces "." , ".." and "" to "[]" 13 | UString Get_Correct_FsFile_Name(const UString &name); 14 | 15 | void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir); 16 | 17 | UString MakePathFromParts(const UStringVector &parts); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/PropIDUtils.h: -------------------------------------------------------------------------------- 1 | // PropIDUtils.h 2 | 3 | #ifndef __PROPID_UTILS_H 4 | #define __PROPID_UTILS_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | // provide at least 64 bytes for buffer including zero-end 9 | void ConvertPropertyToShortString(char *dest, const PROPVARIANT &propVariant, PROPID propID, bool full = true) throw(); 10 | void ConvertPropertyToString(UString &dest, const PROPVARIANT &propVariant, PROPID propID, bool full = true); 11 | 12 | bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s); 13 | void ConvertNtSecureToString(const Byte *data, UInt32 size, AString &s); 14 | bool CheckNtSecure(const Byte *data, UInt32 size) throw();; 15 | 16 | void ConvertWinAttribToString(char *s, UInt32 wa) throw(); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/Property.h: -------------------------------------------------------------------------------- 1 | // Property.h 2 | 3 | #ifndef __7Z_PROPERTY_H 4 | #define __7Z_PROPERTY_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | struct CProperty 9 | { 10 | UString Name; 11 | UString Value; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/SetProperties.h: -------------------------------------------------------------------------------- 1 | // SetProperties.h 2 | 3 | #ifndef __SETPROPERTIES_H 4 | #define __SETPROPERTIES_H 5 | 6 | #include "Property.h" 7 | 8 | HRESULT SetProperties(IUnknown *unknown, const CObjectVector &properties); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/SortUtils.cpp: -------------------------------------------------------------------------------- 1 | // SortUtils.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../../Common/Wildcard.h" 6 | 7 | #include "SortUtils.h" 8 | 9 | static int CompareStrings(const unsigned *p1, const unsigned *p2, void *param) 10 | { 11 | const UStringVector &strings = *(const UStringVector *)param; 12 | return CompareFileNames(strings[*p1], strings[*p2]); 13 | } 14 | 15 | void SortFileNames(const UStringVector &strings, CUIntVector &indices) 16 | { 17 | const unsigned numItems = strings.Size(); 18 | indices.ClearAndSetSize(numItems); 19 | if (numItems == 0) 20 | return; 21 | unsigned *vals = &indices[0]; 22 | for (unsigned i = 0; i < numItems; i++) 23 | vals[i] = i; 24 | indices.Sort(CompareStrings, (void *)&strings); 25 | } 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/SortUtils.h: -------------------------------------------------------------------------------- 1 | // SortUtils.h 2 | 3 | #ifndef __SORT_UTLS_H 4 | #define __SORT_UTLS_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | void SortFileNames(const UStringVector &strings, CUIntVector &indices); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/TempFiles.cpp: -------------------------------------------------------------------------------- 1 | // TempFiles.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../../Windows/FileDir.h" 6 | 7 | #include "TempFiles.h" 8 | 9 | using namespace NWindows; 10 | using namespace NFile; 11 | 12 | void CTempFiles::Clear() 13 | { 14 | while (!Paths.IsEmpty()) 15 | { 16 | NDir::DeleteFileAlways(Paths.Back()); 17 | Paths.DeleteBack(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/TempFiles.h: -------------------------------------------------------------------------------- 1 | // TempFiles.h 2 | 3 | #ifndef __TEMP_FILES_H 4 | #define __TEMP_FILES_H 5 | 6 | #include "../../../Common/MyString.h" 7 | 8 | class CTempFiles 9 | { 10 | void Clear(); 11 | public: 12 | FStringVector Paths; 13 | ~CTempFiles() { Clear(); } 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/UpdateAction.cpp: -------------------------------------------------------------------------------- 1 | // UpdateAction.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "UpdateAction.h" 6 | 7 | namespace NUpdateArchive { 8 | 9 | const CActionSet k_ActionSet_Add = 10 | {{ 11 | NPairAction::kCopy, 12 | NPairAction::kCopy, 13 | NPairAction::kCompress, 14 | NPairAction::kCompress, 15 | NPairAction::kCompress, 16 | NPairAction::kCompress, 17 | NPairAction::kCompress 18 | }}; 19 | 20 | const CActionSet k_ActionSet_Update = 21 | {{ 22 | NPairAction::kCopy, 23 | NPairAction::kCopy, 24 | NPairAction::kCompress, 25 | NPairAction::kCopy, 26 | NPairAction::kCompress, 27 | NPairAction::kCopy, 28 | NPairAction::kCompress 29 | }}; 30 | 31 | const CActionSet k_ActionSet_Fresh = 32 | {{ 33 | NPairAction::kCopy, 34 | NPairAction::kCopy, 35 | NPairAction::kIgnore, 36 | NPairAction::kCopy, 37 | NPairAction::kCompress, 38 | NPairAction::kCopy, 39 | NPairAction::kCompress 40 | }}; 41 | 42 | const CActionSet k_ActionSet_Sync = 43 | {{ 44 | NPairAction::kCopy, 45 | NPairAction::kIgnore, 46 | NPairAction::kCompress, 47 | NPairAction::kCopy, 48 | NPairAction::kCompress, 49 | NPairAction::kCopy, 50 | NPairAction::kCompress, 51 | }}; 52 | 53 | const CActionSet k_ActionSet_Delete = 54 | {{ 55 | NPairAction::kCopy, 56 | NPairAction::kIgnore, 57 | NPairAction::kIgnore, 58 | NPairAction::kIgnore, 59 | NPairAction::kIgnore, 60 | NPairAction::kIgnore, 61 | NPairAction::kIgnore 62 | }}; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/UpdatePair.h: -------------------------------------------------------------------------------- 1 | // UpdatePair.h 2 | 3 | #ifndef __UPDATE_PAIR_H 4 | #define __UPDATE_PAIR_H 5 | 6 | #include "DirItem.h" 7 | #include "UpdateAction.h" 8 | 9 | #include "../../Archive/IArchive.h" 10 | 11 | struct CUpdatePair 12 | { 13 | NUpdateArchive::NPairState::EEnum State; 14 | int ArcIndex; 15 | int DirIndex; 16 | int HostIndex; // >= 0 for alt streams only, contains index of host pair 17 | 18 | CUpdatePair(): ArcIndex(-1), DirIndex(-1), HostIndex(-1) {} 19 | }; 20 | 21 | void GetUpdatePairInfoList( 22 | const CDirItems &dirItems, 23 | const CObjectVector &arcItems, 24 | NFileTimeType::EEnum fileTimeType, 25 | CRecordVector &updatePairs); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Common/UpdateProduce.h: -------------------------------------------------------------------------------- 1 | // UpdateProduce.h 2 | 3 | #ifndef __UPDATE_PRODUCE_H 4 | #define __UPDATE_PRODUCE_H 5 | 6 | #include "UpdatePair.h" 7 | 8 | struct CUpdatePair2 9 | { 10 | bool NewData; 11 | bool NewProps; 12 | bool UseArcProps; // if (UseArcProps && NewProps), we want to change only some properties. 13 | bool IsAnti; // if (!IsAnti) we use other ways to detect Anti status 14 | 15 | int DirIndex; 16 | int ArcIndex; 17 | int NewNameIndex; 18 | 19 | bool IsMainRenameItem; 20 | 21 | void SetAs_NoChangeArcItem(int arcIndex) 22 | { 23 | NewData = NewProps = false; 24 | UseArcProps = true; 25 | IsAnti = false; 26 | ArcIndex = arcIndex; 27 | } 28 | 29 | bool ExistOnDisk() const { return DirIndex != -1; } 30 | bool ExistInArchive() const { return ArcIndex != -1; } 31 | 32 | CUpdatePair2(): 33 | NewData(false), 34 | NewProps(false), 35 | UseArcProps(false), 36 | IsAnti(false), 37 | DirIndex(-1), 38 | ArcIndex(-1), 39 | NewNameIndex(-1), 40 | IsMainRenameItem(false) 41 | {} 42 | }; 43 | 44 | struct IUpdateProduceCallback 45 | { 46 | virtual HRESULT ShowDeleteFile(unsigned arcIndex) = 0; 47 | }; 48 | 49 | void UpdateProduce( 50 | const CRecordVector &updatePairs, 51 | const NUpdateArchive::CActionSet &actionSet, 52 | CRecordVector &operationChain, 53 | IUpdateProduceCallback *callback); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/BenchCon.cpp: -------------------------------------------------------------------------------- 1 | // BenchCon.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../Common/Bench.h" 6 | 7 | #include "BenchCon.h" 8 | #include "ConsoleClose.h" 9 | 10 | struct CPrintBenchCallback: public IBenchPrintCallback 11 | { 12 | FILE *_file; 13 | 14 | void Print(const char *s); 15 | void NewLine(); 16 | HRESULT CheckBreak(); 17 | }; 18 | 19 | void CPrintBenchCallback::Print(const char *s) 20 | { 21 | fputs(s, _file); 22 | } 23 | 24 | void CPrintBenchCallback::NewLine() 25 | { 26 | fputc('\n', _file); 27 | } 28 | 29 | HRESULT CPrintBenchCallback::CheckBreak() 30 | { 31 | return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK; 32 | } 33 | 34 | HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS 35 | const CObjectVector &props, UInt32 numIterations, FILE *f) 36 | { 37 | CPrintBenchCallback callback; 38 | callback._file = f; 39 | return Bench(EXTERNAL_CODECS_LOC_VARS 40 | &callback, NULL, props, numIterations, true); 41 | } 42 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/BenchCon.h: -------------------------------------------------------------------------------- 1 | // BenchCon.h 2 | 3 | #ifndef __BENCH_CON_H 4 | #define __BENCH_CON_H 5 | 6 | #include 7 | 8 | #include "../../Common/CreateCoder.h" 9 | #include "../../UI/Common/Property.h" 10 | 11 | HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS 12 | const CObjectVector &props, UInt32 numIterations, FILE *f); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/ConsoleClose.cpp: -------------------------------------------------------------------------------- 1 | // ConsoleClose.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "ConsoleClose.h" 6 | 7 | #include 8 | 9 | static int g_BreakCounter = 0; 10 | static const int kBreakAbortThreshold = 2; 11 | 12 | namespace NConsoleClose { 13 | 14 | static void HandlerRoutine(int) 15 | { 16 | g_BreakCounter++; 17 | if (g_BreakCounter < kBreakAbortThreshold) 18 | return ; 19 | exit(EXIT_FAILURE); 20 | } 21 | 22 | bool TestBreakSignal() 23 | { 24 | return (g_BreakCounter > 0); 25 | } 26 | 27 | void CheckCtrlBreak() 28 | { 29 | if (TestBreakSignal()) 30 | throw CCtrlBreakException(); 31 | } 32 | 33 | CCtrlHandlerSetter::CCtrlHandlerSetter() 34 | { 35 | memo_sig_int = signal(SIGINT,HandlerRoutine); // CTRL-C 36 | if (memo_sig_int == SIG_ERR) 37 | throw "SetConsoleCtrlHandler fails (SIGINT)"; 38 | memo_sig_term = signal(SIGTERM,HandlerRoutine); // for kill -15 (before "kill -9") 39 | if (memo_sig_term == SIG_ERR) 40 | throw "SetConsoleCtrlHandler fails (SIGTERM)"; 41 | } 42 | 43 | CCtrlHandlerSetter::~CCtrlHandlerSetter() 44 | { 45 | signal(SIGINT,memo_sig_int); // CTRL-C 46 | signal(SIGTERM,memo_sig_term); // kill {pid} 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/ConsoleClose.h: -------------------------------------------------------------------------------- 1 | // ConsoleCloseUtils.h 2 | 3 | #ifndef __CONSOLECLOSEUTILS_H 4 | #define __CONSOLECLOSEUTILS_H 5 | 6 | namespace NConsoleClose { 7 | 8 | bool TestBreakSignal(); 9 | 10 | class CCtrlHandlerSetter 11 | { 12 | void (*memo_sig_int)(int); 13 | void (*memo_sig_term)(int); 14 | public: 15 | CCtrlHandlerSetter(); 16 | virtual ~CCtrlHandlerSetter(); 17 | }; 18 | 19 | class CCtrlBreakException 20 | {}; 21 | 22 | void CheckCtrlBreak(); 23 | 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/HashCon.h: -------------------------------------------------------------------------------- 1 | // HashCon.h 2 | 3 | #ifndef __HASH_CON_H 4 | #define __HASH_CON_H 5 | 6 | #include "../Common/HashCalc.h" 7 | 8 | #include "UpdateCallbackConsole.h" 9 | 10 | class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase 11 | { 12 | UString _fileName; 13 | AString _s; 14 | 15 | void AddSpacesBeforeName() 16 | { 17 | _s.Add_Space(); 18 | _s.Add_Space(); 19 | } 20 | 21 | void PrintSeparatorLine(const CObjectVector &hashers); 22 | void PrintResultLine(UInt64 fileSize, 23 | const CObjectVector &hashers, unsigned digestIndex, bool showHash); 24 | void PrintProperty(const char *name, UInt64 value); 25 | 26 | public: 27 | bool PrintNameInPercents; 28 | 29 | bool PrintHeaders; 30 | 31 | bool PrintSize; 32 | bool PrintName; 33 | 34 | CHashCallbackConsole(): 35 | PrintNameInPercents(true), 36 | PrintHeaders(false), 37 | PrintSize(true), 38 | PrintName(true) 39 | {} 40 | 41 | ~CHashCallbackConsole() { } 42 | 43 | INTERFACE_IHashCallbackUI(;) 44 | }; 45 | 46 | void PrintHashStat(CStdOutStream &so, const CHashBundle &hb); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/List.h: -------------------------------------------------------------------------------- 1 | // List.h 2 | 3 | #ifndef __LIST_H 4 | #define __LIST_H 5 | 6 | #include "../../../Common/Wildcard.h" 7 | 8 | #include "../Common/LoadCodecs.h" 9 | 10 | HRESULT ListArchives(CCodecs *codecs, 11 | const CObjectVector &types, 12 | const CIntVector &excludedFormats, 13 | bool stdInMode, 14 | UStringVector &archivePaths, UStringVector &archivePathsFull, 15 | bool processAltStreams, bool showAltStreams, 16 | const NWildcard::CCensorNode &wildcardCensor, 17 | bool enableHeaders, bool techMode, 18 | #ifndef _NO_CRYPTO 19 | bool &passwordEnabled, UString &password, 20 | #endif 21 | #ifndef _SFX 22 | const CObjectVector *props, 23 | #endif 24 | UInt64 &errors, 25 | UInt64 &numWarnings); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/PercentPrinter.h: -------------------------------------------------------------------------------- 1 | // PercentPrinter.h 2 | 3 | #ifndef __PERCENT_PRINTER_H 4 | #define __PERCENT_PRINTER_H 5 | 6 | #include "../../../Common/StdOutStream.h" 7 | 8 | struct CPercentPrinterState 9 | { 10 | UInt64 Completed; 11 | UInt64 Total; 12 | 13 | UInt64 Files; 14 | 15 | AString Command; 16 | UString FileName; 17 | 18 | void ClearCurState(); 19 | 20 | CPercentPrinterState(): 21 | Completed(0), 22 | Total((UInt64)(Int64)-1), 23 | Files(0) 24 | {} 25 | }; 26 | 27 | class CPercentPrinter: public CPercentPrinterState 28 | { 29 | UInt32 _tickStep; 30 | DWORD _prevTick; 31 | 32 | AString _s; 33 | 34 | AString _printedString; 35 | AString _temp; 36 | UString _tempU; 37 | 38 | CPercentPrinterState _printedState; 39 | AString _printedPercents; 40 | 41 | void GetPercents(); 42 | 43 | public: 44 | CStdOutStream *_so; 45 | 46 | bool NeedFlush; 47 | unsigned MaxLen; 48 | 49 | CPercentPrinter(UInt32 tickStep = 200): 50 | _tickStep(tickStep), 51 | _prevTick(0), 52 | NeedFlush(true), 53 | MaxLen(80 - 1) 54 | {} 55 | 56 | ~CPercentPrinter(); 57 | 58 | void ClosePrint(bool needFlush); 59 | void Print(); 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/7zip/UI/Console/UserInputUtils.h: -------------------------------------------------------------------------------- 1 | // UserInputUtils.h 2 | 3 | #ifndef __USER_INPUT_UTILS_H 4 | #define __USER_INPUT_UTILS_H 5 | 6 | #include "../../../Common/StdOutStream.h" 7 | 8 | namespace NUserAnswerMode { 9 | 10 | enum EEnum 11 | { 12 | kYes, 13 | kNo, 14 | kYesAll, 15 | kNoAll, 16 | kAutoRenameAll, 17 | kQuit 18 | }; 19 | } 20 | 21 | NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream); 22 | UString GetPassword(CStdOutStream *outStream,bool verify = false); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/AutoPtr.h: -------------------------------------------------------------------------------- 1 | // Common/AutoPtr.h 2 | 3 | #ifndef __COMMON_AUTOPTR_H 4 | #define __COMMON_AUTOPTR_H 5 | 6 | template class CMyAutoPtr 7 | { 8 | T *_p; 9 | public: 10 | CMyAutoPtr(T *p = 0) : _p(p) {} 11 | CMyAutoPtr(CMyAutoPtr& p): _p(p.release()) {} 12 | CMyAutoPtr& operator=(CMyAutoPtr& p) 13 | { 14 | reset(p.release()); 15 | return (*this); 16 | } 17 | ~CMyAutoPtr() { delete _p; } 18 | T& operator*() const { return *_p; } 19 | // T* operator->() const { return (&**this); } 20 | T* get() const { return _p; } 21 | T* release() 22 | { 23 | T *tmp = _p; 24 | _p = 0; 25 | return tmp; 26 | } 27 | void reset(T* p = 0) 28 | { 29 | if (p != _p) 30 | delete _p; 31 | _p = p; 32 | } 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/CRC.cpp: -------------------------------------------------------------------------------- 1 | // Common/CRC.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../C/7zCrc.h" 6 | 7 | struct CCRCTableInit { CCRCTableInit() { CrcGenerateTable(); } } g_CRCTableInit; 8 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/C_FileIO.h: -------------------------------------------------------------------------------- 1 | // Common/C_FileIO.h 2 | 3 | #ifndef __COMMON_C_FILEIO_H 4 | #define __COMMON_C_FILEIO_H 5 | 6 | #include 7 | #include 8 | 9 | #include "MyTypes.h" 10 | #include "MyWindows.h" 11 | 12 | #ifdef _WIN32 13 | #ifdef _MSC_VER 14 | typedef size_t ssize_t; 15 | #endif 16 | #endif 17 | 18 | namespace NC { 19 | namespace NFile { 20 | namespace NIO { 21 | 22 | class CFileBase 23 | { 24 | protected: 25 | int _handle; 26 | bool OpenBinary(const char *name, int flags); 27 | public: 28 | CFileBase(): _handle(-1) {}; 29 | ~CFileBase() { Close(); } 30 | bool Close(); 31 | bool GetLength(UInt64 &length) const; 32 | off_t Seek(off_t distanceToMove, int moveMethod) const; 33 | }; 34 | 35 | class CInFile: public CFileBase 36 | { 37 | public: 38 | bool Open(const char *name); 39 | bool OpenShared(const char *name, bool shareForWrite); 40 | ssize_t Read(void *data, size_t size); 41 | }; 42 | 43 | class COutFile: public CFileBase 44 | { 45 | public: 46 | bool Create(const char *name, bool createAlways); 47 | bool Open(const char *name, DWORD creationDisposition); 48 | ssize_t Write(const void *data, size_t size); 49 | }; 50 | 51 | }}} 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/ComTry.h: -------------------------------------------------------------------------------- 1 | // ComTry.h 2 | 3 | #ifndef __COM_TRY_H 4 | #define __COM_TRY_H 5 | 6 | #include "MyWindows.h" 7 | // #include "Exception.h" 8 | // #include "NewHandler.h" 9 | 10 | #define COM_TRY_BEGIN try { 11 | #define COM_TRY_END } catch(const char * s) { throw s ; } \ 12 | catch(...) { return E_OUTOFMEMORY; } 13 | 14 | // catch(const CNewException &) { return E_OUTOFMEMORY; } 15 | // catch(const CSystemException &e) { return e.ErrorCode; } 16 | // catch(...) { return E_FAIL; } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/CommandLineParser.h: -------------------------------------------------------------------------------- 1 | // Common/CommandLineParser.h 2 | 3 | #ifndef __COMMON_COMMAND_LINE_PARSER_H 4 | #define __COMMON_COMMAND_LINE_PARSER_H 5 | 6 | #include "MyString.h" 7 | 8 | namespace NCommandLineParser { 9 | 10 | bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2); 11 | void SplitCommandLine(const UString &s, UStringVector &parts); 12 | 13 | namespace NSwitchType 14 | { 15 | enum EEnum 16 | { 17 | kSimple, 18 | kMinus, 19 | kString, 20 | kChar 21 | }; 22 | } 23 | 24 | struct CSwitchForm 25 | { 26 | const char *Key; 27 | Byte Type; 28 | bool Multi; 29 | Byte MinLen; 30 | // int MaxLen; 31 | const char *PostCharSet; 32 | }; 33 | 34 | struct CSwitchResult 35 | { 36 | bool ThereIs; 37 | bool WithMinus; 38 | int PostCharIndex; 39 | UStringVector PostStrings; 40 | 41 | CSwitchResult(): ThereIs(false) {}; 42 | }; 43 | 44 | class CParser 45 | { 46 | unsigned _numSwitches; 47 | CSwitchResult *_switches; 48 | 49 | bool ParseString(const UString &s, const CSwitchForm *switchForms); 50 | public: 51 | UStringVector NonSwitchStrings; 52 | AString ErrorMessage; 53 | UString ErrorLine; 54 | 55 | CParser(unsigned numSwitches); 56 | ~CParser(); 57 | bool ParseStrings(const CSwitchForm *switchForms, const UStringVector &commandStrings); 58 | const CSwitchResult& operator[](size_t index) const { return _switches[index]; } 59 | }; 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Common.h: -------------------------------------------------------------------------------- 1 | // Common.h 2 | 3 | #ifndef __COMMON_COMMON_H 4 | #define __COMMON_COMMON_H 5 | 6 | #include "../../C/Compiler.h" 7 | 8 | #include "MyWindows.h" 9 | #include "NewHandler.h" 10 | 11 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[1])) 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Defs.h: -------------------------------------------------------------------------------- 1 | // Common/Defs.h 2 | 3 | #ifndef __COMMON_DEFS_H 4 | #define __COMMON_DEFS_H 5 | 6 | template inline T MyMin(T a, T b) { return a < b ? a : b; } 7 | template inline T MyMax(T a, T b) { return a > b ? a : b; } 8 | 9 | template inline int MyCompare(T a, T b) 10 | { return a == b ? 0 : (a < b ? -1 : 1); } 11 | 12 | inline int BoolToInt(bool v) { return (v ? 1 : 0); } 13 | inline bool IntToBool(int v) { return (v != 0); } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/DynLimBuf.h: -------------------------------------------------------------------------------- 1 | // Common/DynLimBuf.h 2 | 3 | #ifndef __COMMON_DYN_LIM_BUF_H 4 | #define __COMMON_DYN_LIM_BUF_H 5 | 6 | #include 7 | 8 | #include "../../C/Alloc.h" 9 | 10 | #include "MyString.h" 11 | 12 | class CDynLimBuf 13 | { 14 | Byte *_chars; 15 | size_t _pos; 16 | size_t _size; 17 | size_t _sizeLimit; 18 | bool _error; 19 | 20 | CDynLimBuf(const CDynLimBuf &s); 21 | 22 | // ---------- forbidden functions ---------- 23 | CDynLimBuf &operator+=(wchar_t c); 24 | 25 | public: 26 | CDynLimBuf(size_t limit) throw(); 27 | ~CDynLimBuf() { MyFree(_chars); } 28 | 29 | size_t Len() const { return _pos; } 30 | void Empty() { _pos = 0; } 31 | 32 | operator const Byte *() const { return _chars; } 33 | // const char *Ptr() const { return _chars; } 34 | 35 | CDynLimBuf &operator+=(char c) throw(); 36 | CDynLimBuf &operator+=(const char *s) throw(); 37 | }; 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/IntToString.h: -------------------------------------------------------------------------------- 1 | // Common/IntToString.h 2 | 3 | #ifndef __COMMON_INT_TO_STRING_H 4 | #define __COMMON_INT_TO_STRING_H 5 | 6 | #include "MyTypes.h" 7 | 8 | void ConvertUInt32ToString(UInt32 value, char *s) throw(); 9 | void ConvertUInt64ToString(UInt64 value, char *s) throw(); 10 | 11 | void ConvertUInt32ToString(UInt32 value, wchar_t *s) throw(); 12 | void ConvertUInt64ToString(UInt64 value, wchar_t *s) throw(); 13 | 14 | void ConvertUInt64ToOct(UInt64 value, char *s) throw(); 15 | 16 | void ConvertUInt32ToHex(UInt32 value, char *s) throw(); 17 | void ConvertUInt64ToHex(UInt64 value, char *s) throw(); 18 | void ConvertUInt32ToHex8Digits(UInt32 value, char *s) throw(); 19 | // void ConvertUInt32ToHex8Digits(UInt32 value, wchar_t *s) throw(); 20 | 21 | void ConvertInt64ToString(Int64 value, char *s) throw(); 22 | void ConvertInt64ToString(Int64 value, wchar_t *s) throw(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Lang.h: -------------------------------------------------------------------------------- 1 | // Common/Lang.h 2 | 3 | #ifndef __COMMON_LANG_H 4 | #define __COMMON_LANG_H 5 | 6 | #include "MyString.h" 7 | 8 | class CLang 9 | { 10 | wchar_t *_text; 11 | CRecordVector _ids; 12 | CRecordVector _offsets; 13 | 14 | bool OpenFromString(const AString &s); 15 | public: 16 | CLang(): _text(0) {} 17 | ~CLang() { Clear(); } 18 | bool Open(CFSTR fileName, const wchar_t *id); 19 | void Clear() throw(); 20 | const wchar_t *Get(UInt32 id) const throw(); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/ListFileUtils.h: -------------------------------------------------------------------------------- 1 | // Common/ListFileUtils.h 2 | 3 | #ifndef __COMMON_LIST_FILE_UTILS_H 4 | #define __COMMON_LIST_FILE_UTILS_H 5 | 6 | #include "MyString.h" 7 | #include "MyTypes.h" 8 | 9 | #define MY__CP_UTF16 1200 10 | #define MY__CP_UTF16BE 1201 11 | 12 | bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyException.h: -------------------------------------------------------------------------------- 1 | // Common/Exception.h 2 | 3 | #ifndef __COMMON_EXCEPTION_H 4 | #define __COMMON_EXCEPTION_H 5 | 6 | #include "MyWindows.h" 7 | 8 | struct CSystemException 9 | { 10 | HRESULT ErrorCode; 11 | CSystemException(HRESULT errorCode): ErrorCode(errorCode) {} 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyGuidDef.h: -------------------------------------------------------------------------------- 1 | // Common/MyGuidDef.h 2 | 3 | #ifndef GUID_DEFINED 4 | #define GUID_DEFINED 5 | 6 | #include "MyTypes.h" 7 | 8 | typedef struct { 9 | UInt32 Data1; 10 | UInt16 Data2; 11 | UInt16 Data3; 12 | unsigned char Data4[8]; 13 | } GUID; 14 | 15 | #ifdef __cplusplus 16 | #define REFGUID const GUID & 17 | #else 18 | #define REFGUID const GUID * 19 | #endif 20 | 21 | #define REFCLSID REFGUID 22 | #define REFIID REFGUID 23 | 24 | #ifdef __cplusplus 25 | inline int operator==(REFGUID g1, REFGUID g2) 26 | { 27 | for (int i = 0; i < (int)sizeof(g1); i++) 28 | if (((unsigned char *)&g1)[i] != ((unsigned char *)&g2)[i]) 29 | return 0; 30 | return 1; 31 | } 32 | inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); } 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | #define MY_EXTERN_C extern "C" 37 | #else 38 | #define MY_EXTERN_C extern 39 | #endif 40 | 41 | #endif 42 | 43 | 44 | #ifdef DEFINE_GUID 45 | #undef DEFINE_GUID 46 | #endif 47 | 48 | #ifdef INITGUID 49 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 50 | MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } 51 | #else 52 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 53 | MY_EXTERN_C const GUID name 54 | #endif 55 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyInitGuid.h: -------------------------------------------------------------------------------- 1 | // Common/MyInitGuid.h 2 | 3 | #ifndef __COMMON_MY_INITGUID_H 4 | #define __COMMON_MY_INITGUID_H 5 | 6 | /* 7 | This file must be included only to one C++ file in project before 8 | declarations of COM interfaces with DEFINE_GUID macro. 9 | 10 | Each GUID must be initialized exactly once in project. 11 | There are two different versions of the DEFINE_GUID macro in guiddef.h (MyGuidDef.h): 12 | - if INITGUID is not defined: DEFINE_GUID declares an external reference to the symbol name. 13 | - if INITGUID is defined: DEFINE_GUID initializes the symbol name to the value of the GUID. 14 | 15 | Also we need IID_IUnknown that is initialized in some file for linking: 16 | MSVC: by default the linker uses some lib file that contains IID_IUnknown 17 | MinGW: add -luuid switch for linker 18 | WinCE: we define IID_IUnknown in this file 19 | Other: we define IID_IUnknown in this file 20 | */ 21 | 22 | #ifdef _WIN32 23 | 24 | #ifdef UNDER_CE 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #ifdef UNDER_CE 31 | DEFINE_GUID(IID_IUnknown, 32 | 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); 33 | #endif 34 | 35 | #else 36 | 37 | #define INITGUID 38 | #include "MyGuidDef.h" 39 | DEFINE_GUID(IID_IUnknown, 40 | 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); 41 | 42 | #endif 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyLinux.h: -------------------------------------------------------------------------------- 1 | // MyLinux.h 2 | 3 | #ifndef __MY_LIN_LINUX_H 4 | #define __MY_LIN_LINUX_H 5 | 6 | #define MY_LIN_S_IFMT 00170000 7 | #define MY_LIN_S_IFSOCK 0140000 8 | #define MY_LIN_S_IFLNK 0120000 9 | #define MY_LIN_S_IFREG 0100000 10 | #define MY_LIN_S_IFBLK 0060000 11 | #define MY_LIN_S_IFDIR 0040000 12 | #define MY_LIN_S_IFCHR 0020000 13 | #define MY_LIN_S_IFIFO 0010000 14 | 15 | #define MY_LIN_S_ISLNK(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFLNK) 16 | #define MY_LIN_S_ISREG(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFREG) 17 | #define MY_LIN_S_ISDIR(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFDIR) 18 | #define MY_LIN_S_ISCHR(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFCHR) 19 | #define MY_LIN_S_ISBLK(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFBLK) 20 | #define MY_LIN_S_ISFIFO(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFIFO) 21 | #define MY_LIN_S_ISSOCK(m) (((m) & MY_LIN_S_IFMT) == MY_LIN_S_IFSOCK) 22 | 23 | #define MY_LIN_S_ISUID 0004000 24 | #define MY_LIN_S_ISGID 0002000 25 | #define MY_LIN_S_ISVTX 0001000 26 | 27 | #define MY_LIN_S_IRWXU 00700 28 | #define MY_LIN_S_IRUSR 00400 29 | #define MY_LIN_S_IWUSR 00200 30 | #define MY_LIN_S_IXUSR 00100 31 | 32 | #define MY_LIN_S_IRWXG 00070 33 | #define MY_LIN_S_IRGRP 00040 34 | #define MY_LIN_S_IWGRP 00020 35 | #define MY_LIN_S_IXGRP 00010 36 | 37 | #define MY_LIN_S_IRWXO 00007 38 | #define MY_LIN_S_IROTH 00004 39 | #define MY_LIN_S_IWOTH 00002 40 | #define MY_LIN_S_IXOTH 00001 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyMap.h: -------------------------------------------------------------------------------- 1 | // MyMap.h 2 | 3 | #ifndef __COMMON_MYMAP_H 4 | #define __COMMON_MYMAP_H 5 | 6 | #include "MyTypes.h" 7 | #include "MyVector.h" 8 | 9 | class CMap32 10 | { 11 | struct CNode 12 | { 13 | UInt32 Key; 14 | UInt32 Keys[2]; 15 | UInt32 Values[2]; 16 | UInt16 Len; 17 | Byte IsLeaf[2]; 18 | }; 19 | CRecordVector Nodes; 20 | 21 | public: 22 | 23 | void Clear() { Nodes.Clear(); } 24 | bool Find(UInt32 key, UInt32 &valueRes) const throw(); 25 | bool Set(UInt32 key, UInt32 value); // returns true, if there is such key already 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyTypes.h: -------------------------------------------------------------------------------- 1 | // Common/MyTypes.h 2 | 3 | #ifndef __COMMON_MY_TYPES_H 4 | #define __COMMON_MY_TYPES_H 5 | 6 | #include "../../C/7zTypes.h" 7 | 8 | typedef int HRes; 9 | 10 | #ifdef __cplusplus 11 | struct CBoolPair 12 | { 13 | bool Val; 14 | bool Def; 15 | 16 | CBoolPair(): Val(false), Def(false) {} 17 | 18 | void Init() 19 | { 20 | Val = false; 21 | Def = false; 22 | } 23 | 24 | void SetTrueTrue() 25 | { 26 | Val = true; 27 | Def = true; 28 | } 29 | }; 30 | 31 | #define CLASS_NO_COPY(cls) \ 32 | private: \ 33 | cls(const cls &); \ 34 | cls &operator=(const cls &); 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyUnknown.h: -------------------------------------------------------------------------------- 1 | // MyUnknown.h 2 | 3 | #ifndef __MY_UNKNOWN_H 4 | #define __MY_UNKNOWN_H 5 | 6 | #include "MyWindows.h" 7 | 8 | /* 9 | #ifdef _WIN32 10 | #include 11 | #include 12 | #else 13 | #include "MyWindows.h" 14 | #endif 15 | */ 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyVector.cpp: -------------------------------------------------------------------------------- 1 | // Common/MyVector.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/MyXml.h: -------------------------------------------------------------------------------- 1 | // MyXml.h 2 | 3 | #ifndef __MY_XML_H 4 | #define __MY_XML_H 5 | 6 | #include "MyString.h" 7 | 8 | struct CXmlProp 9 | { 10 | AString Name; 11 | AString Value; 12 | }; 13 | 14 | class CXmlItem 15 | { 16 | public: 17 | AString Name; 18 | bool IsTag; 19 | CObjectVector Props; 20 | CObjectVector SubItems; 21 | 22 | const char * ParseItem(const char *s, int numAllowedLevels); 23 | 24 | bool IsTagged(const AString &tag) const throw(); 25 | int FindProp(const AString &propName) const throw(); 26 | AString GetPropVal(const AString &propName) const; 27 | AString GetSubString() const; 28 | const AString * GetSubStringPtr() const throw(); 29 | int FindSubTag(const AString &tag) const throw(); 30 | AString GetSubStringForTag(const AString &tag) const; 31 | 32 | void AppendTo(AString &s) const; 33 | }; 34 | 35 | struct CXml 36 | { 37 | CXmlItem Root; 38 | 39 | bool Parse(const char *s); 40 | // void AppendTo(AString &s) const; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/NewHandler.cpp: -------------------------------------------------------------------------------- 1 | // NewHandler.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../C/Alloc.h" 6 | 7 | 8 | #ifdef DONT_REDEFINE_NEW 9 | 10 | int g_NewHandler = 0; 11 | 12 | #else 13 | 14 | /* An overload function for the C++ new */ 15 | void * operator new(size_t size) 16 | { 17 | return MyAlloc(size); 18 | } 19 | 20 | /* An overload function for the C++ new[] */ 21 | void * operator new[](size_t size) 22 | { 23 | return MyAlloc(size); 24 | } 25 | 26 | /* An overload function for the C++ delete */ 27 | void operator delete(void *pnt) 28 | { 29 | MyFree(pnt); 30 | } 31 | 32 | /* An overload function for the C++ delete[] */ 33 | void operator delete[](void *pnt) 34 | { 35 | MyFree(pnt); 36 | } 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Random.h: -------------------------------------------------------------------------------- 1 | // Common/Random.h 2 | 3 | #ifndef __COMMON_RANDOM_H 4 | #define __COMMON_RANDOM_H 5 | 6 | class CRandom 7 | { 8 | public: 9 | void Init(); 10 | void Init(unsigned int seed); 11 | int Generate() const; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Sha1Reg.cpp: -------------------------------------------------------------------------------- 1 | // Sha1Reg.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../C/Sha1.h" 6 | 7 | #include "../Common/MyCom.h" 8 | 9 | #include "../7zip/Common/RegisterCodec.h" 10 | 11 | class CSha1Hasher: 12 | public IHasher, 13 | public CMyUnknownImp 14 | { 15 | CSha1 _sha; 16 | Byte mtDummy[1 << 7]; 17 | 18 | public: 19 | CSha1Hasher() { Sha1_Init(&_sha); } 20 | 21 | MY_UNKNOWN_IMP1(IHasher) 22 | INTERFACE_IHasher(;) 23 | }; 24 | 25 | STDMETHODIMP_(void) CSha1Hasher::Init() throw() 26 | { 27 | Sha1_Init(&_sha); 28 | } 29 | 30 | STDMETHODIMP_(void) CSha1Hasher::Update(const void *data, UInt32 size) throw() 31 | { 32 | Sha1_Update(&_sha, (const Byte *)data, size); 33 | } 34 | 35 | STDMETHODIMP_(void) CSha1Hasher::Final(Byte *digest) throw() 36 | { 37 | Sha1_Final(&_sha, digest); 38 | } 39 | 40 | REGISTER_HASHER(CSha1Hasher, 0x201, "SHA1", SHA1_DIGEST_SIZE) 41 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/Sha256Reg.cpp: -------------------------------------------------------------------------------- 1 | // Sha256Reg.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../C/Sha256.h" 6 | 7 | #include "../Common/MyCom.h" 8 | 9 | #include "../7zip/Common/RegisterCodec.h" 10 | 11 | class CSha256Hasher: 12 | public IHasher, 13 | public CMyUnknownImp 14 | { 15 | CSha256 _sha; 16 | Byte mtDummy[1 << 7]; 17 | 18 | public: 19 | CSha256Hasher() { Sha256_Init(&_sha); } 20 | 21 | MY_UNKNOWN_IMP1(IHasher) 22 | INTERFACE_IHasher(;) 23 | }; 24 | 25 | STDMETHODIMP_(void) CSha256Hasher::Init() throw() 26 | { 27 | Sha256_Init(&_sha); 28 | } 29 | 30 | STDMETHODIMP_(void) CSha256Hasher::Update(const void *data, UInt32 size) throw() 31 | { 32 | Sha256_Update(&_sha, (const Byte *)data, size); 33 | } 34 | 35 | STDMETHODIMP_(void) CSha256Hasher::Final(Byte *digest) throw() 36 | { 37 | Sha256_Final(&_sha, digest); 38 | } 39 | 40 | REGISTER_HASHER(CSha256Hasher, 0xA, "SHA256", SHA256_DIGEST_SIZE) 41 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/StdInStream.h: -------------------------------------------------------------------------------- 1 | // Common/StdInStream.h 2 | 3 | #ifndef __COMMON_STD_IN_STREAM_H 4 | #define __COMMON_STD_IN_STREAM_H 5 | 6 | #include 7 | 8 | #include "MyString.h" 9 | #include "MyTypes.h" 10 | 11 | class CStdInStream 12 | { 13 | FILE *_stream; 14 | bool _streamIsOpen; 15 | public: 16 | CStdInStream(): _stream(0), _streamIsOpen(false) {}; 17 | CStdInStream(FILE *stream): _stream(stream), _streamIsOpen(false) {}; 18 | ~CStdInStream() { Close(); } 19 | 20 | bool Open(LPCTSTR fileName) throw(); 21 | bool Close() throw(); 22 | 23 | AString ScanStringUntilNewLine(bool allowEOF = false); 24 | void ReadToString(AString &resultString); 25 | UString ScanUStringUntilNewLine(); 26 | 27 | bool Eof() throw(); 28 | int GetChar(); 29 | }; 30 | 31 | extern CStdInStream g_StdIn; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/StringToInt.h: -------------------------------------------------------------------------------- 1 | // Common/StringToInt.h 2 | 3 | #ifndef __COMMON_STRING_TO_INT_H 4 | #define __COMMON_STRING_TO_INT_H 5 | 6 | #include "MyTypes.h" 7 | 8 | UInt32 ConvertStringToUInt32(const char *s, const char **end) throw(); 9 | UInt64 ConvertStringToUInt64(const char *s, const char **end) throw(); 10 | UInt32 ConvertStringToUInt32(const wchar_t *s, const wchar_t **end) throw(); 11 | UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end) throw(); 12 | 13 | Int32 ConvertStringToInt32(const wchar_t *s, const wchar_t **end) throw(); 14 | 15 | UInt32 ConvertOctStringToUInt32(const char *s, const char **end) throw(); 16 | UInt64 ConvertOctStringToUInt64(const char *s, const char **end) throw(); 17 | 18 | UInt32 ConvertHexStringToUInt32(const char *s, const char **end) throw(); 19 | UInt64 ConvertHexStringToUInt64(const char *s, const char **end) throw(); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/TextConfig.h: -------------------------------------------------------------------------------- 1 | // Common/TextConfig.h 2 | 3 | #ifndef __COMMON_TEXT_CONFIG_H 4 | #define __COMMON_TEXT_CONFIG_H 5 | 6 | #include "MyString.h" 7 | 8 | struct CTextConfigPair 9 | { 10 | UString ID; 11 | UString String; 12 | }; 13 | 14 | bool GetTextConfig(const AString &text, CObjectVector &pairs); 15 | 16 | int FindTextConfigItem(const CObjectVector &pairs, const UString &id) throw(); 17 | UString GetTextConfigValue(const CObjectVector &pairs, const UString &id); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/UTFConvert.h: -------------------------------------------------------------------------------- 1 | // Common/UTFConvert.h 2 | 3 | #ifndef __COMMON_UTF_CONVERT_H 4 | #define __COMMON_UTF_CONVERT_H 5 | 6 | #include "MyString.h" 7 | 8 | bool CheckUTF8(const char *src, bool allowReduced = false) throw(); 9 | bool ConvertUTF8ToUnicode(const AString &utfString, UString &resultString); 10 | void ConvertUnicodeToUTF8(const UString &unicodeString, AString &resultString); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Common/XzCrc64Reg.cpp: -------------------------------------------------------------------------------- 1 | // XzCrc64Reg.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../C/CpuArch.h" 6 | #include "../../C/XzCrc64.h" 7 | 8 | #include "../Common/MyCom.h" 9 | 10 | #include "../7zip/Common/RegisterCodec.h" 11 | 12 | class CXzCrc64Hasher: 13 | public IHasher, 14 | public CMyUnknownImp 15 | { 16 | UInt64 _crc; 17 | Byte mtDummy[1 << 7]; 18 | 19 | public: 20 | CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {} 21 | 22 | MY_UNKNOWN_IMP1(IHasher) 23 | INTERFACE_IHasher(;) 24 | }; 25 | 26 | STDMETHODIMP_(void) CXzCrc64Hasher::Init() throw() 27 | { 28 | _crc = CRC64_INIT_VAL; 29 | } 30 | 31 | STDMETHODIMP_(void) CXzCrc64Hasher::Update(const void *data, UInt32 size) throw() 32 | { 33 | _crc = Crc64Update(_crc, data, size); 34 | } 35 | 36 | STDMETHODIMP_(void) CXzCrc64Hasher::Final(Byte *digest) throw() 37 | { 38 | UInt64 val = CRC64_GET_DIGEST(_crc); 39 | SetUi64(digest, val); 40 | } 41 | 42 | REGISTER_HASHER(CXzCrc64Hasher, 0x4, "CRC64", 8) 43 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/DLL.h: -------------------------------------------------------------------------------- 1 | // Windows/DLL.h 2 | 3 | #ifndef __WINDOWS_DLL_H 4 | #define __WINDOWS_DLL_H 5 | 6 | #include "../Common/MyString.h" 7 | 8 | typedef void * HMODULE; 9 | // #define LOAD_LIBRARY_AS_DATAFILE 0 10 | typedef int (*FARPROC)(); 11 | 12 | namespace NWindows { 13 | namespace NDLL { 14 | 15 | class CLibrary 16 | { 17 | HMODULE _module; 18 | public: 19 | CLibrary(): _module(NULL) {}; 20 | ~CLibrary() { Free(); } 21 | 22 | operator HMODULE() const { return _module; } 23 | HMODULE* operator&() { return &_module; } 24 | bool IsLoaded() const { return (_module != NULL); }; 25 | 26 | void Attach(HMODULE m) 27 | { 28 | Free(); 29 | _module = m; 30 | } 31 | HMODULE Detach() 32 | { 33 | HMODULE m = _module; 34 | _module = NULL; 35 | return m; 36 | } 37 | 38 | bool Free(); 39 | // bool LoadEx(CFSTR path, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); 40 | bool Load(CFSTR path); 41 | FARPROC GetProc(LPCSTR procName) const; // { return My_GetProcAddress(_module, procName); } 42 | }; 43 | 44 | bool MyGetModuleFileName(FString &path); 45 | 46 | FString GetModuleDirPrefix(); 47 | 48 | }} 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/Defs.h: -------------------------------------------------------------------------------- 1 | // Windows/Defs.h 2 | 3 | #ifndef __WINDOWS_DEFS_H 4 | #define __WINDOWS_DEFS_H 5 | 6 | #include "../Common/MyWindows.h" 7 | 8 | // #ifdef _WIN32 9 | inline bool LRESULTToBool(LRESULT v) { return (v != FALSE); } 10 | inline bool BOOLToBool(BOOL v) { return (v != FALSE); } 11 | inline BOOL BoolToBOOL(bool v) { return (v ? TRUE: FALSE); } 12 | // #endif 13 | 14 | inline VARIANT_BOOL BoolToVARIANT_BOOL(bool v) { return (v ? VARIANT_TRUE: VARIANT_FALSE); } 15 | inline bool VARIANT_BOOLToBool(VARIANT_BOOL v) { return (v != VARIANT_FALSE); } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/ErrorMsg.h: -------------------------------------------------------------------------------- 1 | // Windows/ErrorMsg.h 2 | 3 | #ifndef __WINDOWS_ERROR_MSG_H 4 | #define __WINDOWS_ERROR_MSG_H 5 | 6 | #include "../Common/MyString.h" 7 | 8 | namespace NWindows { 9 | namespace NError { 10 | 11 | UString MyFormatMessage(DWORD errorCode); 12 | 13 | }} 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/FileName.h: -------------------------------------------------------------------------------- 1 | // Windows/FileName.h 2 | 3 | #ifndef __WINDOWS_FILENAME_H 4 | #define __WINDOWS_FILENAME_H 5 | 6 | #include "../../C/7zTypes.h" 7 | 8 | #include "../Common/MyString.h" 9 | 10 | namespace NWindows { 11 | namespace NFile { 12 | namespace NName { 13 | 14 | int FindSepar(const wchar_t *s) throw(); 15 | #ifndef USE_UNICODE_FSTRING 16 | int FindSepar(const FChar *s) throw(); 17 | #endif 18 | 19 | const TCHAR kDirDelimiter = CHAR_PATH_SEPARATOR; 20 | const TCHAR kAnyStringWildcard = '*'; 21 | 22 | void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with '\\' 23 | #ifndef _UNICODE 24 | void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\' 25 | #endif 26 | 27 | bool IsAbsolutePath(const wchar_t *s) throw(); 28 | unsigned GetRootPrefixSize(const wchar_t *s) throw(); 29 | 30 | bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath); 31 | bool GetFullPath(CFSTR path, FString &fullPath); 32 | 33 | }}} 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/Menu.h: -------------------------------------------------------------------------------- 1 | 2 | /* TODO */ 3 | 4 | 5 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/NtCheck.h: -------------------------------------------------------------------------------- 1 | // Windows/NtCheck.h 2 | 3 | #ifndef __WINDOWS_NT_CHECK_H 4 | #define __WINDOWS_NT_CHECK_H 5 | 6 | #ifdef _WIN32 7 | 8 | #include "../Common/MyWindows.h" 9 | 10 | #if !defined(_WIN64) && !defined(UNDER_CE) 11 | static inline bool IsItWindowsNT() 12 | { 13 | OSVERSIONINFO vi; 14 | vi.dwOSVersionInfoSize = sizeof(vi); 15 | return (::GetVersionEx(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_NT); 16 | } 17 | #endif 18 | 19 | #ifndef _UNICODE 20 | #if defined(_WIN64) || defined(UNDER_CE) 21 | bool g_IsNT = true; 22 | #define SET_IS_NT 23 | #else 24 | bool g_IsNT = false; 25 | #define SET_IS_NT g_IsNT = IsItWindowsNT(); 26 | #endif 27 | #define NT_CHECK_ACTION 28 | // #define NT_CHECK_ACTION { NT_CHECK_FAIL_ACTION } 29 | #else 30 | #if !defined(_WIN64) && !defined(UNDER_CE) 31 | #define NT_CHECK_ACTION if (!IsItWindowsNT()) { NT_CHECK_FAIL_ACTION } 32 | #else 33 | #define NT_CHECK_ACTION 34 | #endif 35 | #define SET_IS_NT 36 | #endif 37 | 38 | #define NT_CHECK NT_CHECK_ACTION SET_IS_NT 39 | 40 | #else 41 | 42 | #define NT_CHECK 43 | 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/PropVariantConv.h: -------------------------------------------------------------------------------- 1 | // Windows/PropVariantConv.h 2 | 3 | #ifndef __PROP_VARIANT_CONV_H 4 | #define __PROP_VARIANT_CONV_H 5 | 6 | #include "../Common/MyTypes.h" 7 | 8 | // provide at least 32 bytes for buffer including zero-end 9 | bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true) throw(); 10 | void ConvertFileTimeToString(const FILETIME &ft, wchar_t *s, bool includeTime = true, bool includeSeconds = true) throw(); 11 | 12 | // provide at least 32 bytes for buffer including zero-end 13 | // don't send VT_BSTR to these functions 14 | void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw(); 15 | void ConvertPropVariantToShortString(const PROPVARIANT &prop, wchar_t *dest) throw(); 16 | 17 | inline bool ConvertPropVariantToUInt64(const PROPVARIANT &prop, UInt64 &value) 18 | { 19 | switch (prop.vt) 20 | { 21 | case VT_UI8: value = (UInt64)prop.uhVal.QuadPart; return true; 22 | case VT_UI4: value = prop.ulVal; return true; 23 | case VT_UI2: value = prop.uiVal; return true; 24 | case VT_UI1: value = prop.bVal; return true; 25 | case VT_EMPTY: return false; 26 | default: throw 151199; 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/PropVariantUtils.h: -------------------------------------------------------------------------------- 1 | // Windows/PropVariantUtils.h 2 | 3 | #ifndef __PROP_VARIANT_UTILS_H 4 | #define __PROP_VARIANT_UTILS_H 5 | 6 | #include "../Common/MyString.h" 7 | 8 | #include "PropVariant.h" 9 | 10 | struct CUInt32PCharPair 11 | { 12 | UInt32 Value; 13 | const char *Name; 14 | }; 15 | 16 | AString TypePairToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 value); 17 | void PairToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop); 18 | 19 | AString FlagsToString(const char * const *names, unsigned num, UInt32 flags); 20 | AString FlagsToString(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags); 21 | void FlagsToProp(const CUInt32PCharPair *pairs, unsigned num, UInt32 flags, NWindows::NCOM::CPropVariant &prop); 22 | 23 | AString TypeToString(const char * const table[], unsigned num, UInt32 value); 24 | void TypeToProp(const char * const table[], unsigned num, UInt32 value, NWindows::NCOM::CPropVariant &prop); 25 | 26 | #define PAIR_TO_PROP(pairs, value, prop) PairToProp(pairs, ARRAY_SIZE(pairs), value, prop) 27 | #define FLAGS_TO_PROP(pairs, value, prop) FlagsToProp(pairs, ARRAY_SIZE(pairs), value, prop) 28 | #define TYPE_TO_PROP(table, value, prop) TypeToProp(table, ARRAY_SIZE(table), value, prop) 29 | 30 | void Flags64ToProp(const CUInt32PCharPair *pairs, unsigned num, UInt64 flags, NWindows::NCOM::CPropVariant &prop); 31 | #define FLAGS64_TO_PROP(pairs, value, prop) Flags64ToProp(pairs, ARRAY_SIZE(pairs), value, prop) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/System.h: -------------------------------------------------------------------------------- 1 | // Windows/System.h 2 | 3 | #ifndef __WINDOWS_SYSTEM_H 4 | #define __WINDOWS_SYSTEM_H 5 | 6 | #include "../Common/MyTypes.h" 7 | 8 | namespace NWindows { 9 | namespace NSystem { 10 | 11 | UInt32 GetNumberOfProcessors(); 12 | 13 | bool GetRamSize(UInt64 &size); // returns false, if unknown ram size 14 | 15 | }} 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/Thread.h: -------------------------------------------------------------------------------- 1 | // Windows/Thread.h 2 | 3 | #ifndef __WINDOWS_THREAD_H 4 | #define __WINDOWS_THREAD_H 5 | 6 | #include "Defs.h" 7 | 8 | extern "C" 9 | { 10 | #include "../../C/Threads.h" 11 | } 12 | 13 | namespace NWindows { 14 | 15 | class CThread 16 | { 17 | ::CThread thread; 18 | public: 19 | CThread() { Thread_Construct(&thread); } 20 | ~CThread() { Close(); } 21 | bool IsCreated() { return Thread_WasCreated(&thread) != 0; } 22 | WRes Close() { return Thread_Close(&thread); } 23 | WRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter) 24 | { return Thread_Create(&thread, startAddress, parameter); } 25 | WRes Wait() { return Thread_Wait(&thread); } 26 | 27 | #ifdef _WIN32 28 | operator HANDLE() { return thread; } 29 | void Attach(HANDLE handle) { thread = handle; } 30 | HANDLE Detach() { HANDLE h = thread; thread = NULL; return h; } 31 | DWORD Resume() { return ::ResumeThread(thread); } 32 | DWORD Suspend() { return ::SuspendThread(thread); } 33 | bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(thread, exitCode)); } 34 | int GetPriority() { return ::GetThreadPriority(thread); } 35 | bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(thread, priority)); } 36 | #endif 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/Windows/TimeUtils.h: -------------------------------------------------------------------------------- 1 | // Windows/TimeUtils.h 2 | 3 | #ifndef __WINDOWS_TIME_UTILS_H 4 | #define __WINDOWS_TIME_UTILS_H 5 | 6 | #include "../Common/MyTypes.h" 7 | #include "../Common/MyWindows.h" 8 | 9 | namespace NWindows { 10 | namespace NTime { 11 | 12 | bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime) throw(); 13 | bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime) throw(); 14 | void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime) throw(); 15 | bool UnixTime64ToFileTime(Int64 unixTime, FILETIME &fileTime) throw(); 16 | bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime) throw(); 17 | Int64 FileTimeToUnixTime64(const FILETIME &ft) throw(); 18 | bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day, 19 | unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds) throw(); 20 | void GetCurUtcFileTime(FILETIME &ft) throw(); 21 | 22 | }} 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/include_windows/basetyps.h: -------------------------------------------------------------------------------- 1 | #ifndef _BASETYPS_H 2 | #define _BASETYPS_H 3 | 4 | #ifdef ENV_HAVE_GCCVISIBILITYPATCH 5 | #define DLLEXPORT __attribute__ ((visibility("default"))) 6 | #else 7 | #define DLLEXPORT 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | #define STDAPI extern "C" DLLEXPORT HRESULT 12 | #else 13 | #define STDAPI extern DLLEXPORT HRESULT 14 | #endif /* __cplusplus */ 15 | 16 | typedef GUID IID; 17 | typedef GUID CLSID; 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/myWindows/initguid.h: -------------------------------------------------------------------------------- 1 | // initguid.h 2 | 3 | #include "Common/MyInitGuid.h" 4 | 5 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/myWindows/myAddExeFlag.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #define NEED_NAME_WINDOWS_TO_UNIX 9 | #include "myPrivate.h" 10 | 11 | #include "Common/StringConvert.h" 12 | 13 | void myAddExeFlag(const UString &u_name) 14 | { 15 | AString filename = UnicodeStringToMultiByte(u_name, CP_ACP); // FIXME 16 | const char * name = nameWindowToUnix(filename); 17 | // printf("myAddExeFlag(%s)\n",name); 18 | chmod(name,0700); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/p7zip/CPP/myWindows/myPrivate.h: -------------------------------------------------------------------------------- 1 | 2 | void WINAPI RtlSecondsSince1970ToFileTime( DWORD Seconds, FILETIME * ft ); 3 | 4 | extern "C" int global_use_utf16_conversion; 5 | #ifdef ENV_HAVE_LSTAT 6 | extern "C" int global_use_lstat; 7 | #endif 8 | 9 | const char *my_getlocale(void); 10 | 11 | #ifdef NEED_NAME_WINDOWS_TO_UNIX 12 | static inline const char * nameWindowToUnix(const char * lpFileName) { 13 | if ((lpFileName[0] == 'c') && (lpFileName[1] == ':')) return lpFileName+2; 14 | return lpFileName; 15 | } 16 | 17 | 18 | 19 | #endif 20 | 21 | // From mySplitCommandLine.cpp 22 | void mySplitCommandLine(int numArguments, char *arguments[],UStringVector &parts); 23 | class CStdOutStream; 24 | void showP7zipInfo(CStdOutStream *so); 25 | 26 | -------------------------------------------------------------------------------- /libp7zip/src/main/cpp/str2args/str2args.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROIDP7ZIP_STR2ARGS_H 2 | #define ANDROIDP7ZIP_STR2ARGS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define ARGV_LEN_MAX 512 9 | #define ARGC_MAX 256 10 | 11 | bool str2args(const char *s, char argv[][ARGV_LEN_MAX], int* argc); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /libp7zip/src/main/java/com/hzy/libp7zip/ExitCode.java: -------------------------------------------------------------------------------- 1 | package com.hzy.libp7zip; 2 | 3 | /** 4 | * Created by huzongyao on 8/1/17. 5 | */ 6 | 7 | public class ExitCode { 8 | /** 9 | * 0 No error 10 | * 1 Warning (Non fatal error(s)). For example, one or more files 11 | * were locked by some other application, so they were not compressed. 12 | * 2 Fatal error 13 | * 7 Command line error 14 | * 8 Not enough memory for operation 15 | * 255 User stopped the process 16 | */ 17 | public static final int EXIT_OK = 0; 18 | public static final int EXIT_WARNING = 1; 19 | public static final int EXIT_FATAL = 2; 20 | public static final int EXIT_CMD_ERROR = 7; 21 | public static final int EXIT_MEMORY_ERROR = 8; 22 | public static final int EXIT_NOT_SUPPORT = 255; 23 | } 24 | -------------------------------------------------------------------------------- /libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java: -------------------------------------------------------------------------------- 1 | package com.hzy.libp7zip; 2 | 3 | /** 4 | * Created by huzongyao on 17-7-5. 5 | */ 6 | 7 | public class P7ZipApi { 8 | 9 | /** 10 | * Get P7zip version info 11 | */ 12 | public static native String get7zVersionInfo(); 13 | 14 | /** 15 | * Execute some p7zip command 16 | * 17 | * @param command command string 18 | * @return exit code 19 | * @see ExitCode 20 | */ 21 | public static native int executeCommand(String command); 22 | 23 | static { 24 | System.loadLibrary("p7zip"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libp7zip/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | maven { url 'https://jitpack.io' } 7 | } 8 | } 9 | dependencyResolutionManagement { 10 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 11 | repositories { 12 | google() 13 | mavenCentral() 14 | maven { url 'https://jitpack.io' } 15 | 16 | } 17 | } 18 | rootProject.name = "PythonkTX" 19 | include ':app' 20 | include ':libp7zip' 21 | --------------------------------------------------------------------------------