{"id":13410179,"url":"https://github.com/onox/dcf-ada","last_synced_at":"2026-02-19T10:01:22.376Z","repository":{"id":50553677,"uuid":"186181761","full_name":"onox/dcf-ada","owner":"onox","description":"An Ada 2012 library for document container files","archived":false,"fork":false,"pushed_at":"2022-07-31T13:14:59.000Z","size":1367,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:40:55.243Z","etag":null,"topics":["ada","archiving","dcf","dcf-ada","zip"],"latest_commit_sha":null,"homepage":null,"language":"Ada","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-11T21:11:51.000Z","updated_at":"2023-09-27T11:57:40.000Z","dependencies_parsed_at":"2022-08-31T21:02:32.635Z","dependency_job_id":null,"html_url":"https://github.com/onox/dcf-ada","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fdcf-ada","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fdcf-ada/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fdcf-ada/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onox%2Fdcf-ada/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onox","download_url":"https://codeload.github.com/onox/dcf-ada/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221481997,"owners_count":16829979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ada","archiving","dcf","dcf-ada","zip"],"created_at":"2024-07-30T20:01:05.387Z","updated_at":"2026-02-19T10:01:17.336Z","avatar_url":"https://github.com/onox.png","language":"Ada","funding_links":[],"categories":["Libraries"],"sub_categories":["Compression"],"readme":"[![Alire dcf](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/dcf.json)](https://alire.ada.dev/crates/dcf.html)\n[![Alire zipdcf](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/zipdcf.json)](https://alire.ada.dev/crates/zipdcf.html)\n[![License](https://img.shields.io/github/license/onox/dcf-ada.svg?color=blue)](https://github.com/onox/dcf-ada/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/onox/dcf-ada.svg)](https://github.com/onox/dcf-ada/releases/latest)\n[![IRC](https://img.shields.io/badge/IRC-%23ada%20on%20libera.chat-orange.svg)](https://libera.chat)\n[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/ada-lang/Lobby)\n\n# dcf-ada\n\nAn Ada 2012 library for document container files, a Zip-based archive files\nwith some limitations:\n\n * Only the \"store\" (uncompressed) and \"deflate\" ([RFC 1951][url-deflate])\n   compression methods can be used\n\n * Archives cannot be encrypted or contain digital signatures\n\n * Archives cannot be split into multiple files\n\nThis library is based on the [Zip-Ada][url-zip-ada] library, with extensive\nmodifications:\n\n * Binary and Windows-specific files have been removed with [The BFG Repo Cleaner][url-bfg]\n\n * Reformatted code to Ada default style guide\n\n * Removed obsolescent features and implementation-defined extensions\n\n * All packages except one that uses `Ada.Calendar` are preelaborated\n\n * Removed unneeded features\n\n * Removed lots of duplicated code and simplified the API, reducing SLOC from 12k to 4.5k\n\n## Usage\n\nBefore the archived files in a document container file can be queried\nor extracted, the archive first needs to be opened and loaded:\n\n```ada\nArchive_Stream : aliased DCF.Streams.File_Zipstream := DCF.Streams.Open (Archive_Name);\nInfo : DCF.Zip.Zip_Info;\n```\n\nThen load the archive by calling `DCF.Zip.Load (Info, Archive_Stream)`.\nWhile the `Info` and `Archive_Stream` objects are in scope, the files\ncan be visited in order to extract them.\n\n### Visiting archived files in a document container file\n\nFiles can be extracted by visiting over all the archived files in the\narchive and then extracting each of them:\n\n```ada\nprocedure Visit_File (File : DCF.Zip.Archived_File) is\nbegin\n   Ada.Text_IO.Put_Line (\"Visiting \" \u0026 File.Name);\nend Visit_File;\n\nprocedure Visit_All_Files is new DCF.Zip.Traverse (Visit_File);\nprocedure Visit_One_File  is new DCF.Zip.Traverse_One_File (Visit_File);\n```\n\nCall `Visit_All_Files (Info)` to visit all files. To extract a single\nfile, call `Visit_One_File (Info, \"my-file.txt\")` instead.\n\n### Querying an archived file\n\nA `File` object of type `Archived_File` can be queried:\n\n * `Name` returns the name (path) of the file\n\n * `Compressed_Size` gives the compressed size\n\n * `Uncompressed_Size` gives the uncompressed size\n\n * `Date_Time` returns the modification date and time\n\n * `Compressed` returns True if compressed with the \"deflate\" algorithm\n   and False if stored uncompressed\n\n * `Encrypted` returns True if the file is encrypted and False otherwise.\n   Note that encryption is prohibited and not supported, thus these files\n   cannot be decrypted and extracted\n\n * `CRC_32` returns the CRC code. This number can be printed with\n   `DCF.Zip.CRC.Image`\n\n### Extracting an archived file\n\nWhile visiting an archived file, the file can be extracted using a\n`Stream_Writer` object. First create the file and then write to it:\n\n```ada\ndeclare\n   File_Stream   : aliased DCF.Streams.File_Zipstream := DCF.Streams.Create (File.Name);\n   Stream_Writer : DCF.Unzip.Streams.Stream_Writer (File_Stream'Access);\nbegin\n   DCF.Unzip.Streams.Extract\n     (Destination      =\u003e Stream_Writer,\n      Archive_Info     =\u003e Info,\n      File             =\u003e File,\n      Verify_Integrity =\u003e False);\nend;\n```\n\nIf you want to extract to a `Stream_Element_Array`, use `DCF.Streams.Array_Zipstream`:\n\n```ada\ndeclare\n   Byte_Stream   : aliased DCF.Streams.Array_Zipstream (My_Element_Array'Access);\n   Stream_Writer : DCF.Unzip.Streams.Stream_Writer (Byte_Stream'Access);\nbegin\n```\n\nIf you want to verify the integrity of the file without extracting it, set\n`Verify_Integrity` to `True` and use `null` in the discriminant of `Stream_Writer`.\n\nNote that you should verify that `File.Name` is a valid path and sanitize\nit before attempting to create and write to the file.\n\n## Dependencies\n\nIn order to build the library, you need to have:\n\n * An Ada 2012 compiler\n\n * [Alire][url-alire] and `make`\n\n## Using the library\n\nUse the library in your crates as follows:\n\n```\nalr with dcf\n```\n\n## Installing the tools\n\nSome tools to compress or decompress document container files can be build with:\n\n```\n$ make\n$ make PREFIX=~/.local install\n```\n\n## Thanks\n\nMuch thanks to @zertovitch for the Zip-Ada project.\n\n## Contributing\n\nPlease read the [contributing guidelines][url-contributing] before opening\nissues or pull requests.\n\n## License\n\nThis library is distributed under the terms of the [MIT License][url-mit].\nThe first line of each Ada file should contain an SPDX license identifier\ntag that refers to this license:\n\n    SPDX-License-Identifier: MIT\n\n  [url-alire]: https://alire.ada.dev/\n  [url-bfg]: https://rtyley.github.io/bfg-repo-cleaner\n  [url-contributing]: /CONTRIBUTING.md\n  [url-deflate]: https://tools.ietf.org/html/rfc1951\n  [url-mit]: https://opensource.org/licenses/mit\n  [url-zip-ada]: https://unzip-ada.sourceforge.net\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonox%2Fdcf-ada","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonox%2Fdcf-ada","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonox%2Fdcf-ada/lists"}