|
deleting directory |
William Labbett
Member #4,486
March 2004
|
hi guys, is there a way to delete a directory and all it's contents with A5 ? Thanks.
|
verthex
Member #11,340
September 2009
|
If you could somehow invoke dos commands from A5 sure.
|
SiegeLord
Member #7,827
October 2006
|
Yes, by recursively looking through a directory using al_open_directory /al_read_directory (using al_get_fs_entry_mode to tell if the current entry is a directory and needs to be recursed into) and then using al_remove_fs_entry to actually delete the file/empty directory. There's obviously no convenience function for that, but doing the above shouldn't take more than 10-20 lines. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
William Labbett
Member #4,486
March 2004
|
Thanks. Maybe it'd be easier to do with a scipt ? I'm using a script to compile and run my program. I've tried using the rmdir command but it says command not found, even though it's in the bash docs.
|
SiegeLord
Member #7,827
October 2006
|
Well, in that case you'd use rm: rm -rf directory_name Be careful with what you put in the directory_name lest you delete something you didn't want to delete. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
William Labbett
Member #4,486
March 2004
|
Thanks. Still getting a command not found. #!bin/bash rm -rf "C:\pongping8\feature_hits_circle_dir_01" cd C:/pongping8 if mingw32-make then ./pong_game.exe fi read -p "press a key"
C:\pongping8\make_pongping.sh: line 2: rm: command not found
|
SiegeLord
Member #7,827
October 2006
|
You're using bash... on Windows? That's surprising. You'll need to find the Windows equivalent then, I guess. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
William Labbett
Member #4,486
March 2004
|
On Windows, MSYS can be used to use the bash commands. Although I only get this when I call it from MSYS : william@william-PC ~ william@william-PC /c/pongping8 william@william-PC /c/pongping8
|
J-Gamer
Member #12,491
January 2011
|
Shouldn't that be /bin/sh? " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
William Labbett
Member #4,486
March 2004
|
I don't know. I changed it to that to see if it would work. I've changed it back and I still get the same output.
|
J-Gamer
Member #12,491
January 2011
|
It tells the system that the program should be opened with bin/sh. As it seems it is already being opened with sh, try removing the line.(I'm just guessing here) " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
William Labbett
Member #4,486
March 2004
|
Okay, I tried that but I still get this : C:\pongping8\make_pongping.sh: line 2: rm: command not found Haven't got a clue why it's not found. I must be doing something stupid.
|
J-Gamer
Member #12,491
January 2011
|
This file works for me in Ubuntu 11.10. #!/bin/sh touch "blargh" rm blargh Does msys have rm? Try the steps of the program manually on the command-line. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
William Labbett
Member #4,486
March 2004
|
Manually it works okay but not from the script.
|
jmasterx
Member #11,410
October 2009
|
On Windows, I think the command is 'rmdir' if you're on Windows maybe that's why it is not working? Agui GUI API -> https://github.com/jmasterx/Agui |
William Labbett
Member #4,486
March 2004
|
I tried that. command not found again.
|
Dario ff
Member #10,065
August 2008
|
rd? TranslatorHack 2010, a human translation chain in a.cc. |
jmasterx
Member #11,410
October 2009
|
As well as to be restricting yourself to Windows, you might as well do it right and use RemoveDirectory http://msdn.microsoft.com/en-us/library/aa365488%28VS.85%29.aspx Or this for non-empty directories: 1void silently_remove_directory(LPCTSTR dir) // Fully qualified name of the directory being deleted, without trailing backslash
2{
3 SHFILEOPSTRUCT file_op = {
4 NULL,
5 FO_DELETE,
6 dir,
7 "",
8 FOF_NOCONFIRMATION |
9 FOF_NOERRORUI |
10 FOF_SILENT,
11 false,
12 0,
13 "" };
14 SHFileOperation(&file_op);
15}
Agui GUI API -> https://github.com/jmasterx/Agui |
gnolam
Member #2,030
March 2002
|
jmasterx said: On Windows, I think the command is 'rmdir'
rd. -- |
Sirocco
Member #88
April 2000
|
Remove is portable, and although I haven't tried to use it in that fashion, is supposedly able to remove directories as well as files. I'm not sure if it can get the directory and all the files in one shot, but it'd be worth trying. --> |
William Labbett
Member #4,486
March 2004
|
Thanks jmasterx. I got that to work.. I'm still puzzled about why none of rm -rf, rmdir, or rd work when other commands like cd work fine.
|
J-Gamer
Member #12,491
January 2011
|
This SO post might help: " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
system("rmdir /s /q directory_to_delete");
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Trent Gamblin
Member #261
April 2000
|
cd works because it's both a bash and cmd.exe command. rmdir and rd don't work in bash because they're not bash commands. rm doesn't work because you don't have rm installed. You can get many unix utils like rm for Windows here.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
I think the question is why doesn't a .sh script using rm work in MSYS, when it already has rm. And it should work... My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|