diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-04-09 22:15:04 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-04-09 22:15:04 +0300 |
commit | 24b1e8f39302f3a5698e45b3fcc40efdf121262d (patch) | |
tree | 06a646423ffc71906033654e2e51f30e49be78a6 /lib/_ak_fs | |
parent | 9188050f8737c0bf610feaba0005b622e1a63d05 (diff) | |
download | arching-kaos-tools-24b1e8f39302f3a5698e45b3fcc40efdf121262d.tar.gz arching-kaos-tools-24b1e8f39302f3a5698e45b3fcc40efdf121262d.tar.bz2 arching-kaos-tools-24b1e8f39302f3a5698e45b3fcc40efdf121262d.zip |
I guess I learnt something today
Diffstat (limited to 'lib/_ak_fs')
-rwxr-xr-x | lib/_ak_fs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/_ak_fs b/lib/_ak_fs new file mode 100755 index 0000000..becbac1 --- /dev/null +++ b/lib/_ak_fs @@ -0,0 +1,29 @@ +#!/bin/bash + +_ak_return_hash_path(){ + hashpath="$(echo -n "$1" |sed 's/./&\//g;s/\/$//g')" + echo -n "$hashpath" +} + +_ak_return_hash_dir(){ + hashdir="$(echo -n "$1" | sed -e 's/./&\//g' | grep '\(./\)\{128\}' | sed -e 's/..$//')" + echo -n "$hashdir" +} + +_ak_verify_input_is_hash(){ + if [ ! -z "$1" ] && echo "$1" | grep '[0123456789abcdef]\{128\}' > /dev/null 2>&1 + then + return 0 + else + echo "no hash?!" >&2 + exit 1 + fi +} + +_ak_create_dir_for_hash(){ + if [ ! -z $1 ] && [ ! -z $2 ] && [ -n "$1" ] && [ -n "$2" ] + then + mkdir -p "$1/$(_ak_return_hash_diri $2)" + fi + +} |