sar - create and extract a directory structure in a file
sar -c directory
sar [-e|-l] sar_file
-c directory
With the -c option, specifies a directory and the program creates one file called name.sar, containing all the files and sub-directories contained on the indicated directory.
-e sar_file
The -e option indicates a file extraction and, in that case, a file with the .sar extension is indicated as argument. The entire hierarchy of directories and files contained in the .sar file is extracted.
-l sar_file
The listing option, indicated by -l, receives a file with .sar extension and shows in the screen the entire hierarchy of directories and files contained in the .sar file.
Sar produces the following return values:
0: successful execution
1: the argument passed in the criation is not a directory
2: the argument passed in the listing or extraction is not a valid .sar file
The first 4 bytes are the file type followed by an end-of-line character.
SAR
Then whe have the first data area, where we find the relation of files and directories separated by an end-of-file character. In the second area we find the compressed files, following the structure below and repeating for all files:
<!dir>
file name
<!bin>
file content
And finally the end of the file is indicated by the closure tag:
<!end>
Both in Linux and Windows the compilation is done by g++ (MinGW in Windows).
On Linux:
g++ -o sar sar.cpp
On Windows:
g++ -o sar sar.cpp -static-libstdc++
On Linux:
./sar [option] [directory or file]
On Windows:
sar.exe [option] [directory or file]
- Translate README
- Translate comments
- Change bounding tags