Finished chapter 2 now with the exercise. Good read so far
@AstonJ how is your solution?
Here’s mine:
Client:
put_file(Server, FileName, FileContent) ->
Server ! {self(), {put_file, FileName, FileContent}},
receive
{Server, Response} -> Response
end.
Server:
loop(Dir) ->
receive
{Client, list_dir} ->
Client ! {self(), file:list_dir(Dir)};
{Client, {get_file, File}} ->
Full = filename:join(Dir, File),
Client ! {self(), file:read_file(Full)};
{Client, {put_file, FileName, FileContent}} ->
Client ! {self(), file:write_file(FileName, FileContent)}
end,
loop(Dir).