Changeset 81 for trunk


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

Refactoring.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/TODO

    r80 r81  
    1010----------------------- 
    1111 
    12 What happens if you do a cd(...) in the shell while directory_tester 
    13 is running (try with an absolute path and with a relative path in the 
    14 init args)? 
    15  
    16 Try running directory_tester from erl started with various -pa 
    17 (relative, absolute, ../ etc). 
    18  
    1912Features? 
    2013--------- 
  • 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.