4
echo Usage: $0 swapfile
8
if test ! -d "$1/clusters.data" || test ! -d "$1/clusters.meta"; then
13
if test -f "$1/.lock"; then
18
# called with $1 directory to convert (non-rec.)
22
files=`find $1 -type f -maxdepth 1`
26
mv $i $1/.newfiles/`printf "%X" $basen`
32
# called with $1 directory to convert (non-rec.)
36
files=`find $1 -type f -maxdepth 1`
40
mv $i $1/.newfiles/$[0x$basen + 0]
46
# called with $1 directory to hash (non-rec.)
49
# create hash dirs (with leading . to prevent clashes)
50
for i in `seq 0 255`; do
51
mkdir $1/.`printf "%X" $i`
53
# insert all files into their hash slots (renaming them, too)
54
files=`find $1 -type f -maxdepth 1`
57
hashname=$[0x$basen / 256]
58
hashdir=$[0x$basen - $hashname*256]
59
mv $i $1/.`printf "%X" $hashdir`/`printf "%X" $hashname`
61
# move . hash dirs to real names
62
for i in `seq 0 255`; do
63
mv $1/.`printf "%X" $i` $1/`printf "%X" $i`
67
# called with $1 directory to unhash
68
do_unhash_and_hex2dec()
70
# move hash dirs to .hash to avoid clashes
71
dirs=`find $1/ -type d -maxdepth 1 -name '[^d.]*'`
73
mv $d $1/.`basename $d`
75
# unhash / rename files
78
files=`find $1/.$hashdir -type f -maxdepth 1`
80
hashfile=`basename $i`
81
name=$[0x$hashfile*256 + 0x$hashdir]
87
rm -Rf $1/.`basename $d`
92
if test -d $1/clusters.meta/FF; then
93
echo Converting from 0.5 format to 0.4 format
96
do_convert_hex2dec $1/
97
echo Unhashing $1/clusters.data
98
do_unhash_and_hex2dec $1/clusters.data
99
echo Unhashing $1/clusters.meta
100
do_unhash_and_hex2dec $1/clusters.meta
103
echo Converting from 0.4 format to 0.5 format
106
do_convert_dec2hex $1/
107
echo Converting $1/clusters.data
108
do_convert_dec2hex $1/clusters.data
109
echo Converting $1/clusters.meta
110
do_convert_dec2hex $1/clusters.meta
111
echo Hashing $1/clusters.data
112
do_hash $1/clusters.data
113
echo Hashing $1/clusters.meta
114
do_hash $1/clusters.meta