diff options
author | Damien F. Katz <damien@apache.org> | 2008-05-15 21:51:22 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-05-15 21:51:22 +0000 |
commit | a684f95cbcee7f2568a2ce04e7dc2bbb605a27b3 (patch) | |
tree | 3b2fafecde418e10834ec2e896efffb64b16a33a /src/couchdb/couch_util.erl | |
parent | 41eeac05bff1b0a8b05f1110270c0beecd62991a (diff) |
Incremental reduce first checkin. Warning! Disk format change.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@656861 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_util.erl')
-rw-r--r-- | src/couchdb/couch_util.erl | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index 0c51f39b..81234c2b 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -16,7 +16,7 @@ -export([parse_ini/1,should_flush/0, should_flush/1]). -export([new_uuid/0, rand32/0, implode/2, collate/2, collate/3]). -export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]). --export([encodeBase64/1, decodeBase64/1]). +-export([encodeBase64/1, decodeBase64/1, to_hex/1]). % arbitrarily chosen amount of memory to use before flushing to disk @@ -30,20 +30,21 @@ start_driver(LibDir) -> {error, already_loaded} -> ok; Error -> exit(Error) end. - - + + + new_uuid() -> - to_hex(binary_to_list(crypto:rand_bytes(16))). - + to_hex(crypto:rand_bytes(16)). + to_hex([]) -> []; +to_hex(Bin) when is_binary(Bin) -> + to_hex(binary_to_list(Bin)); to_hex([H|T]) -> [to_digit(H div 16), to_digit(H rem 16) | to_hex(T)]. -to_digit(N) when N < 10 -> - $0 + N; -to_digit(N) -> - $a + N-10. +to_digit(N) when N < 10 -> $0 + N; +to_digit(N) -> $a + N-10. % returns a random integer |