Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.72 KB | None | 0 0
  1.  
  2. %% send_file_to_local_share/4
  3. %% ==========================
  4. %% This function creates a soft link on the local shared folder to the original file to be shared.
  5. %% LocalLinkname: full path of the local file
  6. %%
  7. async_send_file_to_local_share(ImagePathname, LocalLinkName, Destination, Id, _State) ->
  8.   %BaseDir = get_cwd(),
  9.   %ImageFullPathname = case is_target_device() of
  10.   % true -> ImagePathname;
  11.   % _ -> BaseDir ++ "/" ++ ImagePathname
  12.   %end,
  13.   %ImageFullPathname = ImagePathname,
  14.   %lager:debug("ImagePathname = ~s~n ImageFullPathname = ~s", [ImagePathname, ImageFullPathname]),
  15.  
  16.   LocalCompleteLinkname = io_lib:format("~s/~s/~s", [get_local_share_folder_prefix(), get_local_share_folder_name(), LocalLinkName ]),
  17.  
  18.   lager:notice("[SHF] Sending file to LOCAL share i.e. creating local soft link."),
  19.   lager:info("[SHF] ImagePathname = ~s~n ",      [ImagePathname]),
  20.   lager:info("[SHF] LocalLinkName = ~s",         [LocalLinkName]),
  21.   lager:info("[SHF] LocalCompleteLinkname = ~s", [LocalCompleteLinkname]),
  22.   lager:info("[SHF] Destination   = ~s",         [Destination]),
  23.   lager:info("[SHF] Id            = ~p",         [Id]),
  24.  
  25.   %Command = io_lib:format("sudo /bin/ln -sf '~s' '~s' ", [ImagePathname, LocalCompleteLinkname]),
  26.   %lager:debug("Command => |~s|", [Command]),
  27.   %execute_export_command_and_update(Command, Id).
  28.  
  29.   Pid=self(),
  30.   Ref=make_ref(),
  31.   CmdString = code:priv_dir(gsd_service) ++ lists:flatten(io_lib:format("/samba_local_create_link.sh \"~s\" \"~s\" ", [ImagePathname, LocalCompleteLinkname])),
  32.   lager:info("[SHF] async-send-file-to-local-share - Pid = ~p, Ref = ~p, CmdString = ~s", [Pid, Ref, CmdString]),
  33.   gen_server:cast(gsd_script_server, {async_command, Pid, Ref, CmdString}),
  34.   {shf_ok, Ref}.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement