Hi,<br><br>I've written a small Erlang program that copies directory trees. I cannot figure out how to set the owner (Unix UID and GID) for symbolic links, because file:write_file_info/2 modifies the target file, not the symlink. Unix command chown has -h option for this purpose. Is there any way of doing this in Erlang? Why isn't there file:write_link_info/2? Perhaps I've missed something, is there a way to copy the symlink as it is? (I do use read_link and read_link_info.)<br>
<br>My second question relates to eprof. I analysed the execution of my program (copying /usr/local/lib to NFS directory). The eprof:total_analyse/0 results are below ("mirror11" is my module). It shows that 82% of the time goes in file_name_1/1, which "Generates a flat file name from a deep list of atoms and characters (integers)". Does this really mean that 82% of time is spent here, instead of doing disk I/O? I would have expected file:copy/2 to be on the top of the list. (There are 481 directories and 6744 files in my /usr/local/lib.)<br>
<br>Any comments would be appreciated!<br><br>Thanks,<br>Ville<br><br>7> eprof:total_analyse().<br>FUNCTION CALLS TIME <br>file:file_name_1/1 3086234 82 % <br>
gen:do_call/4 29869 2 % <br>file:check_args/1 93941 2 % <br>gen:wait_resp_mon/3 29869 1 % <br>mirror11:get_file_info/2 21195 1 % <br>
file:check_and_call/2 29869 1 % <br>file:call/2 29869 1 % <br>gen:call/4 29869 1 % <br>file:file_name/1 36615 1 % <br>
gen_server:call/3 29869 1 % <br>mirror11:do_file/4 6744 1 % <br>erlang:'++'/2 21680 0 % <br>erlang:monitor/2 29869 0 % <br>
file:read_link_info/1 14451 0 % <br>file:copy_int/3 13488 0 % <br>erlang:whereis/1 29869 0 % <br>erlang:demonitor/1 29869 0 % <br>
erlang:list_to_tuple/1 29869 0 % <br>erlang:list_to_binary/1 21195 0 % <br>mirror11:by_type/6 7707 0 % <br>lists:foreach/2 7708 0 % <br>
ets:lookup/2 21195 0 % <br>mirror11:log_debug/2 6748 0 % <br>file:write_file_info/2 7225 0 % <br>ets:insert/2 7707 0 % <br>
mirror11:do_dir/3 481 0 % <br>mirror11:'-do_dir/3-fun-5-'/4 6744 0 % <br>file:copy/2 6744 0 % <br>mirror11:start_dir_workers/5 963 0 % <br>
ets:delete/1 481 0 % <br>file:list_dir/1 962 0 % <br>mirror11:rendezvous/1 963 0 % <br>erlang:apply/2 481 0 % <br>
erlang:spawn/3 481 0 % <br>file:make_dir/1 481 0 % <br>ets:new/2 481 0 % <br>erlang:spawn/1 481 0 % <br>
mirror11:'-start_dir_workers/5-fun-0-'/3 481 0 % <br>mirror11:do_symlink/4 2 0 % <br>mirror11:master_loop/0 1 0 % <br>file:read_link/1 4 0 % <br>
file:make_symlink/2 2 0 % <br>mirror11:'-do_dir/3-fun-6-'/4 2 0 % <br><br>Total time: 51.30<br>Measurement overhead: 13.48<br>ok<br><br><br><br>