Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 4th, 2005, 3:00 PM   #1
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
remove();

Is it possible to use a wild card "*" (believe that is what it is called) with in the remove function?

Ex.
remove( "C:\\Documents and Settings\\username\\Favorites\\*.htm" );

Thanks in advance.
-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Old Nov 4th, 2005, 3:14 PM   #2
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 3 MBirchmeier is on a distinguished road
Quote:
Originally Posted by The Web
Standard C++ knows neither of wildcards nor _unlink.
[It's a platform-specific extension. Posting in a forum dedicated to the
particular platform upon which you are working will most likely get you
the help you need.]
http://groups.google.com/group/comp....2bd18460c76268

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Nov 4th, 2005, 3:14 PM   #3
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
No, wildcards are the function of your shell, not the C runtime environment. If you want the shell to translate wildcards, you would be better off doing the equivalent shell command with the system function. Then, the command interpreter will do it's thing (if it's accessible).
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Nov 4th, 2005, 3:21 PM   #4
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Would you mind explaining that alittle farther Narue? How can I create a shell command using the system function?


Thanks,
-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Old Nov 4th, 2005, 3:59 PM   #5
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 3 MBirchmeier is on a distinguished road
Quote:
Originally Posted by badbasser98
Would you mind explaining that alittle farther Narue? How can I create a shell command using the system function?


Thanks,
-BB98
The System(...) command STDLIB:ystem() passes a string to the operating system and lets the OS run the command correctly

Assuming you're using windows :
System("del C:\\Documents and Settings\\username\\Favorites\\*.htm");
*nix :
System("rm \\Documents and Settings\\username\\Favorites\\*.htm");

should do the trick, however this will execute the command then only return if the command executed properly (or the command's error code).

Another solution is to find a filestructure object, and utilize that, so you can see more and do 'smart deletes'. I believe such structures exist in <dos.h>. But again that's operating system dependant, and I have reservations against dos.h anyway.

Hope this helps.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Nov 6th, 2005, 11:13 AM   #6
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Yeah, that should get me going. Thanks, and I am using Windows.

-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Old Nov 7th, 2005, 10:46 AM   #7
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Quote:
Originally Posted by MBirchmeier
...
Assuming you're using windows :
System("del C:\\Documents and Settings\\username\\Favorites\\*.htm");
This command does not work, I tried running it on the command line as well and it says "The system cannot find the path specified." What I typed in was
del C:\Documents and Settings\username\Local Settings\Temporary Internet Files\*.txt
I am trying to create a cache clearing utility, to remove cookies, temp files, etc.

thanks,
-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Old Nov 7th, 2005, 12:09 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You have to watch out for spaces in a directory or file name, otherwise the parts of the name are picked up as separate tokens. Careful attention is required in quoting for the shell.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 7th, 2005, 1:15 PM   #9
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
This cleans out all temp files (worked for me on WinXp) including temp internet files and h istory
system("DEL /F /S %TEMP%");

Put in /Q if you don't want the command prompt to ask you are you sure.
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old Nov 7th, 2005, 1:26 PM   #10
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Prm753,

Thanks, I'll give it a try and see what happens.
-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC