home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20273 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.2 KB  |  53 lines

  1. Path: sparky!uunet!europa.eng.gtefsd.com!emory!swrinde!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!julienas!corton!geocub!taliesin!mendez
  2. From: mendez@taliesin.greco-prog.fr (Mendez Marc)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: File manipulation from a program...PLEASE HELP!
  5. Message-ID: <1993Jan27.223250.11843@greco-prog.fr>
  6. Date: 27 Jan 93 22:32:50 GMT
  7. References: <C1BH3B.5pD@cs.uiuc.edu>
  8. Sender: usenet@greco-prog.fr (le facteur fnet)
  9. Organization: LMI (LaBRI University Bordeaux France)
  10. Lines: 40
  11. X-Newsreader: TIN [version 1.1 PL7]
  12.  
  13. Jason Pardee (pardee@cs.uiuc.edu) wrote:
  14. > i want to know if there is a way to rename a file from a C program.  you know,
  15. > the equivalent of the command 'ren ldfilename> <newfilename>'.  is there
  16. > such a function in C?  if not,  is there a way to invoke a DOS command from
  17. > within a program, meaning, is there a way i can execute the 'ren' command
  18. > inside my program?
  19.  
  20. Well, use the "rename" function. Here is an extract from Unix manual :
  21.  
  22.      NAME
  23.           rename - change the name of a file
  24.  
  25.      SYNOPSIS
  26.           int rename(from, to)
  27.           char *from, *to;
  28.  
  29.      DESCRIPTION
  30.           rename causes the link named from to be renamed as to.  If
  31.           to exists, it is first removed.  Both from and to must be of
  32.           the same type (that is, both directories or both non-
  33.           directories) and must reside on the same file system.
  34.  
  35.           rename guarantees that an instance of to will always exist,
  36.           even if the system should crash in the middle of the
  37.           operation.
  38. [...]
  39. --
  40.  
  41.    =====================================================================
  42.   |   MENDEZ Marc     E-Mail        : mendez@taliesin.greco-prog.fr    |
  43.   |                       mendez@taliesin.emi.u-bordeaux.fr  |
  44.   |            Home Phone : (33) 56 46 14 52            |
  45.   |        Licence d'informatique - UFR d'informatique -        |
  46.   |          Universite de Bordeaux 1 - France            |
  47.    =====================================================================
  48.    "The trouble with computers is they do everything we tell them to do,
  49.          but not what we would like them to do." (unknown)
  50.    "Un homme n'a pas lieu d'etre malheureux tant que ses regrets n'ont
  51.          pas remplace ses reves." (unknown)
  52.