anchor.diff:  	{could_not_read_file, Reason} ->
   	    error_logger:warning_msg("~s could not be read: ~s~n", [F, Reason])
       end.
  -
  -
  
positive.code: 
  empty_state() -> sets:new().
  
  scan_files_in_dir(Dir, State) ->
      Files = filelib:fold_files(Dir, ".*\.torrent", false, fun(F, Accum) ->
  								  [F | Accum] end, []),
      FilesSet = sets:from_list(Files),
      Added = sets:subtract(FilesSet, State),
      Removed = sets:subtract(State, FilesSet),
      NewState = FilesSet,
      {Added, Removed, NewState}.
  
  handle_new_torrent(F) ->
  
negative.code: %%%-------------------------------------------------------------------
  %%% File    : dirwatcher.erl
  %%% Author  : Jesper Louis Andersen <jlouis@succubus>
  %%% Description : Watch a directory for the presence of torrent files.
  %%%               Send commands when files are added and removed.
  %%%
  %%% Created : 24 Jan 2007 by Jesper Louis Andersen <jlouis@succubus>
  %%%-------------------------------------------------------------------
  -module(dirwatcher).
  -author("Jesper Louis Andersen <jesper.louis.andersen@gmail.com>").
  -behaviour(gen_server).
  
  %% API
  -export([start_link/1, watch_dirs/0]).
  
  %% gen_server callbacks
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  	 terminate/2, code_change/3]).
  
  -record(state, {dir = none,
  	        fileset = none}).
  -define(WATCH_WAIT_TIME, 1000).
  
  %%====================================================================
  %% API
  %%====================================================================
  %%--------------------------------------------------------------------
  %% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
  %% Description: Starts the server
  %%--------------------------------------------------------------------
  start_link(Dir) ->
      gen_server:start_link(?MODULE, [Dir], []).
  
  %%====================================================================
  %% gen_server callbacks
  %%====================================================================
  init([Dir]) ->
      timer:apply_interval(?WATCH_WAIT_TIME, ?MODULE, watch_dirs, []),
      {ok, #state{dir = Dir, fileset = empty_state()}}.
  
  handle_call(report_on_files, _Who, S) ->
      {reply, sets:to_list(S#state.fileset)};
  handle_call(_Request, _From, State) ->
      Reply = ok,
      {reply, Reply, State}.
  
  handle_cast(watch_directories, S) ->
      {A, R, N} = scan_files_in_dir(S),
      lists:foreach(fun(F) -> handle_new_torrent(F) end,
  		  sets:to_list(A)),
          lists:foreach(fun(F) -> torrent_manager:stop_torrent(F) end,
  		  sets:to_list(R)),
      {noreply, N}.
  
  handle_info(_Info, State) ->
      {noreply, State}.
  
  terminate(_Reason, _State) ->
      ok.
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  %%--------------------------------------------------------------------
  %%% Internal functions
  %%--------------------------------------------------------------------
  
  %% Operations
  watch_dirs() ->
  