Operating System - Linux
1753792 Members
7542 Online
108799 Solutions
New Discussion юеВ

Re: Rename a file in C++ on Unix platform

 
Steven Schweda
Honored Contributor

Re: Rename a file in C++ on Unix platform

> But i need a way that renames the file both
> in unix and windows.

I thought that I explained how to do it, as
have others. I even explained how to avoid
the problem by writing your temporary file to
the right place, instead of to "/var/tmp".
Do you need someone to write the code for
you, or what? What's not clear yet?
Soumya Krishnan
New Member

Re: Rename a file in C++ on Unix platform

Hii...

Thanks alot........
It is working fine now.I have used Preprocessor directives for the compatiblity problem .
#ifdef UNIX

system("mv /var/tmp/xyz.pdf ./Result/abc.pdf");

#else
if(rename(tmpfn[0], filename))
{
map_msg_err("Can't rename temp-PDF file '%s' to '%s'\n", tmpfn[0], filename);
mexit(EXIT_PDFRENAME);
}
#endif

Once again thanking u all for ur valubale suggestions...:-)
Torsten.
Acclaimed Contributor

Re: Rename a file in C++ on Unix platform

Even if this works under some circumstances, I really doubt if "rename" will always "move" your file ... but it's your code ...

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
James R. Ferguson
Acclaimed Contributor

Re: Rename a file in C++ on Unix platform

Hi:

As a new Forum member, welcome! If you are happy with the suggestions you have received, please read:

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: Rename a file in C++ on Unix platform

> [...] ... but it's your code ...

Yeah. Sometimes it'd be nice to know more
about the people who post these questions, so
you'd know what not to buy.
Torsten.
Acclaimed Contributor

Re: Rename a file in C++ on Unix platform

LOL

Steven, we have the same point of view.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!