new_unique              package:runjags              R Documentation

_C_r_e_a_t_e _a _U_n_i_q_u_e _F_i_l_e_n_a_m_e

_D_e_s_c_r_i_p_t_i_o_n:

     Search the current working directory for a file or directory
     matching the input name, and if it exists suggest a new name by
     appending a counter to the input name.  Alternatively, the
     function can ask the user if the existing file should be
     overwritten, in which case the existing file will be erased if the
     answer is 'yes'.  The function also checks for write access
     permissions at the current working directory.

_U_s_a_g_e:

     new_unique(name = NA, suffix = "", ask = FALSE, 
        prompt = "A file or directory with this name already exists.  Overwrite?")

_A_r_g_u_m_e_n_t_s:

    name: the filename to be used (character string).  A vector of
          character strings is also permissible, in which case they
          will be pasted together.  One or more missing (NA) values can
          also be used, which will be replaced with a randomly
          generated 9 character alphanumeric string.  Default NA.

  suffix: the file extension (including '.') to use (character string).
           Default none.

     ask: if a file exists with the input name, should the function ask
          to overwrite the file? (logical)  If FALSE, a new filename is
          used instead and no files will be over-written.  Default
          FALSE.

  prompt: what text string should be used to prompt the user?
          (character string)  Ignored is ask==FALSE.  A generic default
          is supplied.

_V_a_l_u_e:

     A unique filename that is safe to use without fear of destroying
     existing files

_A_u_t_h_o_r(_s):

     Matthew Denwood m.denwood@vet.gla.ac.uk funded as part of the
     DEFRA VTRI project 0101.

_S_e_e _A_l_s_o:

     'ask'

_E_x_a_m_p_l_e_s:

     #  Create a file name that is unlikely to exist already, with a .R extension.
     new_unique(c("new_file", NA), ".R", ask=FALSE)

