Commits

Anonymous committed 25bb547

a little bit refactoring; removed unnessesary functions and so on.

  • Participants
  • Parent commits ca199f2
  • Branches dev
  • Tags 0.10

Comments (0)

Files changed (4)

+2009-11-20  UENISHI Kota  <kuenishi@gmail.com>
+
+	* src/yatce.erl (db): API changed;
+	 yatce:newdb/2 -> yatce:db/2
+	this API change aims at confirmation for users that API has changed.
+	versioned as 0.10.0 for new feature - application-ized.
+
 2009-09-10  UENISHI Kota  <kuenishi@gmail.com>
 
 	* src/yatce.erl (newdb): open options enabled.
 group: tools
-short: Yet Another Tokyo Cabinet-Erlang binding
+short: Yet Another TokyoCabinet-Erlang binding
 -export([start/0, stop/0, db/2]).
 -include("tokyocabinet.hrl").
 
-start(_Type, RestartType)->
-    {ok, LibPath} = find_ddll_path(),
+start(_Type, _RestartType)->
+    LibPath = code:priv_dir(?MODULE)++ "/lib",
 %    io:format("~p ~p: ~p~n", [?FILE, ?LINE, LibPath]),
     case erl_ddll:try_load(LibPath, ?DYLIB_NAME, []) of
 	{ok, _Status} -> 
 	    {error, Other}
     end.
 
-stop(State)->
+stop(_State)->
     SharedLib = ?DYLIB_NAME,
 %    io:format("~p (~p, ~p) terminating.~n", [?MODULE, self(), State]),
     case erl_ddll:unload(SharedLib) of
 stop()->  application:stop(?MODULE).    
 
 -spec db( tablename(), [option()] ) -> tcadb().
-db(TableName, Options)->    % TODO: parse Options here and create a real tablename
+db(TableName, Options)->
     yatce_server:newdb(TableName,Options).
 
-
-find_ddll_path()->
-    case code:priv_dir(?MODULE) of
-	{error, _}->
-	    find_ddll_path_(["./c_src", "../c_src", "../../c_src", "../../../c_src"]);
-	Path when is_list(Path)->
-	    {ok, Path++"/lib"};
-	Other ->
-	    {error, Other}
-    end.
-
-find_ddll_path_([])->
-    {error, not_found};
-find_ddll_path_([Head|Tail])->
-    erlang:display(Head),
-    case file:open( Head ++"/" ++ ?DYLIB_NAME ++ ".so", [read] ) of
-	{ok, IODevice}->
-	    file:close(IODevice),
-	    {ok, Head};
-	{error, _} ->
-	    find_ddll_path_(Tail)
-    end.
-	    

src/yatce_server.erl

 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2 ]).
 
 -spec newdb( tablename(), [option()] ) -> tcadb().
-newdb(TableName, Options)->    % TODO: parse Options here and create a real tablename
+newdb(TableName, Options)->
     {ok, Port} = get_port(),
     FullTableName = generate_open_argv(TableName, Options),
     tcadb:new(FullTableName, Options, Port ).
 code_change(_,_,State)->
     {ok, State}.
 
-get_libdir([])->
-    file:get_cwd();
-get_libdir([OneConfigPair|OtherConfigs])->
-    case OneConfigPair of
-	{libdir, LibDir}->
-	    {ok, LibDir};
-	_Other ->
-	    get_libdir( OtherConfigs )
-    end.
-