Ignore:
Timestamp:
07/17/09 13:40:38 (3 years ago)
Author:
dom
Message:

Refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/directory_watcher.erl

    r80 r81  
    1010init (Directory, F) -> 
    1111    D = filename: absname (Directory), 
    12     check (D, F, []). 
     12    check (D, F, dict: new ()). 
    1313 
    1414init_recursive (Directory, F) -> 
     
    2020check (Directory, F, State) -> 
    2121    New_state = list_dir (Directory, F), 
    22     sort_and_compare (F, State, New_state), 
     22    compare (F, State, New_state), 
    2323    loop (Directory, F, New_state). 
    2424 
     
    3131list_dir (Directory, F, Error) -> 
    3232    F ({directory, Directory, Error}), 
    33     []. 
     33    dict: new (). 
    3434 
    3535read_state (Filenames) -> 
    36     lists: foldl (fun read_state/2, [], Filenames). 
     36    lists: foldl (fun read_state/2, dict: new (), Filenames). 
    3737 
    38 read_state (Filename, State) -> 
    39     case file: read_file_info (Filename) of 
     38read_state (File_name, State) -> 
     39    case file: read_file_info (File_name) of 
    4040        {ok, Info} -> 
    41             [{Filename, value (Info#file_info.type, Filename)} | State]; 
     41            Value = value (Info#file_info.type, File_name), 
     42            dict: store (File_name, Value, State); 
    4243        _ -> 
    4344            State 
     
    8081    end. 
    8182 
    82 sort_and_compare (F, Old, New) -> 
    83     Original = dict: from_list (Old), 
    84     Modified = dict: from_list (New), 
     83compare (F, Original, Modified) -> 
    8584    Compared = adlib: compare_dict (Modified, Original), 
    8685    dict: fold (fun notify_new/3, F, dict: fetch (new, Compared)), 
Note: See TracChangeset for help on using the changeset viewer.