Skip to content

Commit 6ec6850

Browse files
committed
Add example description and purpose
1 parent 4ed0f94 commit 6ec6850

File tree

2 files changed

+68
-3
lines changed

2 files changed

+68
-3
lines changed

examples/arion/arion.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,43 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
THE SOFTWARE.
2121
*/
2222

23+
//------------------------------------------------------------------------------
24+
// arion.cpp
25+
//
26+
// This example demonstrates how to use the ARIO library to inspect and list the
27+
// contents of a UNIX archive (.ar) file. It provides a simple command-line tool
28+
// that displays information about each member of the archive, including its name,
29+
// size, file mode, and any associated symbols.
30+
//
31+
// Purpose:
32+
// - Showcase ARIO’s API for reading and iterating over archive members.
33+
// - Provide a minimal example for archive inspection and symbol listing.
34+
//
35+
// Abilities:
36+
// - Loads and parses a specified archive file.
37+
// - Lists all members with their names, sizes, and file modes.
38+
// - Displays symbols associated with each member, if available.
39+
// - Command-line interface: Accepts the archive file name as an argument.
40+
//
41+
// This example serves as a reference for basic ARIO usage and as a foundation
42+
// for building custom archive inspection tools.
43+
//------------------------------------------------------------------------------
44+
45+
#include <iostream>
2346
#include <ario/ario.hpp>
2447

2548
using namespace ARIO;
2649

2750
int main( int argc, char** argv )
2851
{
2952
if ( argc != 2 ) {
30-
printf( "Usage: arion <file_name>\n" );
53+
std::cout << "Usage: arion <file_name>" << std::endl;
3154
return 1;
3255
}
3356

3457
ario archive;
3558

36-
auto result = archive.load( argv[1] );
59+
const auto result = archive.load( argv[1] );
3760
if ( !result.ok() ) {
3861
std::cerr << "Error loading archive: " << result.what() << std::endl;
3962
return 1;

examples/arioso/arioso.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
// This example demonstrates how to use the ARIO library to read and manipulate UNIX archive files.
1+
/*
2+
Copyright (C) 2025-present by Serge Lamikhov-Center
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.
21+
*/
22+
23+
//------------------------------------------------------------------------------
24+
// arioso.cpp
25+
//
26+
// This example demonstrates how to use the ARIO library (with optional ELFIO integration)
27+
// to manage UNIX archive (.ar) files from the command line. It provides a practical tool
28+
// for extracting, deleting, and adding files to an archive, similar to the standard 'ar' utility.
29+
//
30+
// Purpose:
31+
// - Showcase ARIO’s API for reading, modifying, and writing UNIX archive files.
32+
// - Illustrate integration with ELFIO for symbol extraction from ELF object files.
33+
//
34+
// Abilities:
35+
// - Extraction: Extracts specified files from the archive to the current directory.
36+
// - Deletion: Removes specified files from the archive.
37+
// - Addition: Adds new files to the archive, collecting and storing global symbols if the file is an ELF object.
38+
// - Archive update: Safely writes changes to the archive using a temporary file for atomic updates.
39+
// - Command-line interface: Accepts commands in the form:
40+
// arioso <archive> [-e <files...>] [-d <files...>] [-a <files...>]
41+
//
42+
// This example serves as both a reference for ARIO/ELFIO usage and a foundation for building custom archive management tools.
43+
//
244

345
#include <iostream>
446
#include <vector>

0 commit comments

Comments
 (0)