A few rarely useful tools, with probably far superior alternatives out there...

namark 933e61ba98 Awkward header, but clear conscience. 8 months ago
tests 97a61b94d6 Initial source, Makefile and license 7 years ago
.gitignore 3d33bb27a4 Ignoring output and temporary files 7 years ago
COPYRIGHT 9c7f09501c Updated copyright. 9 months ago
LICENSE 97a61b94d6 Initial source, Makefile and license 7 years ago
Makefile 5c5da89207 worth it 9 months ago
README.md 9eeba380ec Updated readme, 8 months ago
crop.cpp 2a33594c5f crop improvements 9 months ago
diff.cpp 933e61ba98 Awkward header, but clear conscience. 8 months ago
diffprose.sh fa216d690a Some helper scripts to show a side by side diff of two text files. 9 months ago
glue.cpp 5c5da89207 worth it 9 months ago
pop_test.cpp 5c5da89207 worth it 9 months ago
show_diff_at.sh fa216d690a Some helper scripts to show a side by side diff of two text files. 9 months ago
show_word_diff_at.sh fa216d690a Some helper scripts to show a side by side diff of two text files. 9 months ago
shred.cpp 5c5da89207 worth it 9 months ago
swap.cpp f7aadb3341 Using perror to report errno errors. 6 years ago
word_diffprose.sh fa216d690a Some helper scripts to show a side by side diff of two text files. 9 months ago

README.md

Intro

Each cpp file is a standalone little program. The initial idea was to show that modern C++(just by itself and standard library) can be as "easy to use" as some higher level languages for certain simple tasks. That was a total failure, and I decided to cheat and move some of the code out into a few simple libraries, so while the programs here look more or less clear and concise and don't exceed 200 lines, they depend on some external code that does not... at all.

Since these are file tools they all depend on libsimple_file. Additional dependencies for each program (if any) are listed below.


shred.cpp

Splits a given file(s) into small pieces, generating a .info file(s) that can be used to reassemble them. You can specify the size of the pieces (in bytes) with the -s option, which affects all the files specified after it. The size can be specified several times in a single command. Use -- to prevent option parsing if it conflicts with your file name(s).
When run without parameters enters interactive mode, expecting a piece size followed by a list of files to "shred", input on separate lines (not just separated with whitespace). To specify new size just input an empty line and the program will expect a size again.
Does not modify or delete the input files.
Any errors will likely terminate the program.

Additional dependencies
libsimple_support


glue.cpp

Assembles a file(s) split by shred program according to specified .info file(s).
When run without parameters enters interactive mode, expecting a list of .info files to "glue", input on separate lines (not just separated with whitespace).
Does not modify or delete the input files or associated pieces.
Any errors will likely terminate the program.


swap.cpp

Look how easy it is to swap two files now! Please don't ever use this...


diff.cpp

Couldn't find an option for existing diff tools to show difference byte by byte as opposed to line by line(I didn't look too hard) so thought I could write my own. It was fun. It takes two files and outputs the position and size of differences(additions/deletions) between them. Completely non standard output format but makes sense in the context of the underlying algorithm.
Can't handle "large" files.
Any errors will likely terminate the program.

Additional dependencies
libsimple_geom
libsimple_support


crop.cpp

Displays a portion of a file, specified by a position and size(position:size), or a range(start-end). Has a lot(relatively) of parameters... I should document those as well... someday...
Does not modify or delete the input files.
Can't handle "large" files.
Any errors will likely terminate the program.

Additional dependencies
libsimple_support


diffprose.sh word_diffprose.sh

Helper scripts for showing horizontal side by side differrence of two text files using diff and crop.
Can't handle "large" files.
Any errors will likely terminate the program.




Building and installation

It's all in the makefile... but you'll need to install the dependencies manually. Make sure to use a c++17 compliant compiler, since that's what I do. I also primarily use GNU/linux based systems so no guarantee that the makefile won't spectacularly break for you, if you don't.

Here is an example of installing all dependencies and building all programs.

# get the project
git clone https://github.com/namark/filetools

# get the dependencies
git clone https://notabug.org/namark/cpp_tools
git clone https://notabug.org/namark/libsimple_support
git clone https://notabug.org/namark/libsimple_geom
git clone https://notabug.org/namark/libsimple_file

# install dependencies locally for this porject only
cd ../cpp_tools
make install-includes PREFIX=../libsimple_support
make install-includes PREFIX=../libsimple_geom
make install-includes PREFIX=../libsimple_file
cd ../libsimple_support
make install PREFIX=../filetools
make install PREFIX=../libsimple_file
cd ../libsimple_geom
make install PREFIX=../filetools
cd ..
cd libsimple_file
make install PREFIX=../filetools

# remove repositories of the dependencies
rm -rf libsimple_file libsimple_support libsimple_geom cpp_tools

# build the entire project
cd filetools
make

After this you should have all the binaries available in ./out directory, and can install them anywhere with make install(by default /usr/local/bin/).

Each .cpp file is compiled to(and installed as) a binary with the same name, prefixed with the letter f, without an extension.
For example swap.cpp will turn into fswap.
.sh files are installed as their name, without any prefix or extension, so diffprose.sh will become diffprose.