home *** CD-ROM | disk | FTP | other *** search
- 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
- From: mendez@taliesin.greco-prog.fr (Mendez Marc)
- Newsgroups: comp.lang.c
- Subject: Re: File manipulation from a program...PLEASE HELP!
- Message-ID: <1993Jan27.223250.11843@greco-prog.fr>
- Date: 27 Jan 93 22:32:50 GMT
- References: <C1BH3B.5pD@cs.uiuc.edu>
- Sender: usenet@greco-prog.fr (le facteur fnet)
- Organization: LMI (LaBRI University Bordeaux France)
- Lines: 40
- X-Newsreader: TIN [version 1.1 PL7]
-
- Jason Pardee (pardee@cs.uiuc.edu) wrote:
- > i want to know if there is a way to rename a file from a C program. you know,
- > the equivalent of the command 'ren ldfilename> <newfilename>'. is there
- > such a function in C? if not, is there a way to invoke a DOS command from
- > within a program, meaning, is there a way i can execute the 'ren' command
- > inside my program?
- >
-
- Well, use the "rename" function. Here is an extract from Unix manual :
-
- NAME
- rename - change the name of a file
-
- SYNOPSIS
- int rename(from, to)
- char *from, *to;
-
- DESCRIPTION
- rename causes the link named from to be renamed as to. If
- to exists, it is first removed. Both from and to must be of
- the same type (that is, both directories or both non-
- directories) and must reside on the same file system.
-
- rename guarantees that an instance of to will always exist,
- even if the system should crash in the middle of the
- operation.
- [...]
- --
-
- =====================================================================
- | MENDEZ Marc E-Mail : mendez@taliesin.greco-prog.fr |
- | mendez@taliesin.emi.u-bordeaux.fr |
- | Home Phone : (33) 56 46 14 52 |
- | Licence d'informatique - UFR d'informatique - |
- | Universite de Bordeaux 1 - France |
- =====================================================================
- "The trouble with computers is they do everything we tell them to do,
- but not what we would like them to do." (unknown)
- "Un homme n'a pas lieu d'etre malheureux tant que ses regrets n'ont
- pas remplace ses reves." (unknown)
-