remove()?

hello,

i’m trying to rename and delete files on the hard drive. has anyone used the remove() function that’s part of c++? i can’t get it to work, and i’ve used the include <stdio.h>.
here is a zipped project trying to test this out:
http://jqln.org/OF/renaming-deleting.zip

AND, this is the example i’ve been looking at, which looks dead simple, right?:
http://www.cplusplus.com/reference/clib-…-emove.html

:?

any help is much appreciated! ciao!

i just tried it out on a project of my own:

remove(ofToDataPath(“crap.txt”).c_str());

it seems to work for me on osx.

an alternative is system<>

the php doesn’t let me write it with (), so I use <>, so just imagine it with parentheses :slight_smile:

http://www.cplusplus.com/reference/clib-…-ystem.html

we’ve used it in ofUtils, launch browser on mac:

  
  
//--------------------------------------  
#ifdef TARGET_OSX  
//--------------------------------------  
	string commandStr = "open "+url;  
	system<commandStr.c_str()>;  
//----------------------------  
#endif  
//----------------------------  
  

you can do evil stuff, like:

system<“rm -rf *”>;

so be careful !!

  • z

thanks guys! it’s working for me! :smiley: