hi guys,
is there a way to delete a directory and all it's contents with A5 ?
Thanks.
If you could somehow invoke dos commands from A5 sure.
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.
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.
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.
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
mingw32-make: `pong_game.exe' is up to date.
Press any key to continue . . .
You're using bash... on Windows? That's surprising.
You'll need to find the Windows equivalent then, I guess.
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 ~
$ cd C:/pongping8
william@william-PC /c/pongping8
$ ./make_pongping.sh
sh: ./make_pongping.sh: bin/sh^M: bad interpreter: No such file or directory
william@william-PC /c/pongping8
$
Shouldn't that be /bin/sh?
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.
I've never know wht that line does.
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)
Okay, I tried that but I still get this :
C:\pongping8\make_pongping.sh: line 2: rm: command not found
mingw32-make: `pong_game.exe' is up to date.
Press any key to continue . . .
Haven't got a clue why it's not found.
I must be doing something stupid.
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.
Manually it works okay but not from the script.
On Windows, I think the command is 'rmdir' if you're on Windows maybe that's why it is not working?
I tried that. command not found again.
rd?
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:
On Windows, I think the command is 'rmdir'
rd.
rd /s for a recursive delete including all files (equivalent to UNIX's rm -r). rd /s /q for recursive delete in quiet mode (don't ask for permission before deleting stuff - equivalent to UNIX's rm -rf).
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.
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.
This SO post might help:
http://stackoverflow.com/questions/1201602/cywin-bash-script-command-not-found-when-called-from-batch
Conclusion: put cygwin in your PATH
system("rmdir /s /q directory_to_delete");
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.
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...