Okay, so bassicly I used unRAR library to unrar my archieve which constainst graphics and also sounds for my game, everything works fine till deleting.
I can easlie delete all graphic files but can't delete sounds file.
Here's problem:
I use one sfMusic* Pointer to all types of clicking so bassicly when You click in that area You get another sound and when You click in another area You get another sound.
I also got one background music, which deletes without any problems, I think it's because I use it only for one purpose.(background music ofcourse)
When i want to switch music in that one pointer I do something like:
Pointer = sfMusic_CreateFromFile(blabla);
And when I closing my game I do something like:
sfMusic_Destroy(Pointer);
system("RD /S /Q Dzwieki"); <- directory with sounds
And I get permission error saying that I am tring to delete something that is already in use.
But if I don't click anywhere and just close the game it deletes without problem.
So how should I prevent this?
It's not working because of adressing different types of files to that same pointer, I tried nulling this pointer everyime I change it's file but it's not helping. I am sure about that because just now I ran some test, do I have to use different sfMusic for every music file that I want? Come one there's got to be some kind of solution.
Minimal code of problem:
extern "C"
{
#include <SFML/System.h>
#include <SFML/Audio.h>
#include <SFML/Window.h>
}
int main() //Name of files are "aaa.ogg" and "aaa1.ogg"
{
sfMusic* Tescior = NULL; <--- used for test
sfWindowSettings Ustawienia = {24, 8, 0};
sfVideoMode Tryb = {800, 600, 32};
sfRenderWindow* Glowne;
sfEvent Wydarzenie;
Glowne = sfRenderWindow_Create(Tryb, "Gra v0.1 Alpha", sfClose, Ustawienia);
while (sfRenderWindow_IsOpened(Glowne))
{
while (sfRenderWindow_GetEvent(Glowne, &Wydarzenie)) //Pobiera Wydarzenia
{
if (Wydarzenie.Type == sfEvtClosed) //Jesli wydarzenie to X
{
sfRenderWindow_Close(Glowne);
}
if (Wydarzenie.Type == sfEvtKeyPressed && Wydarzenie.Key.Code == sfKeyQ)
{
Tescior = sfMusic_CreateFromFile("aaa.ogg");
sfMusic_Play(Tescior);
}
if (Wydarzenie.Type == sfEvtKeyPressed && Wydarzenie.Key.Code == sfKeyE)
{
Tescior = sfMusic_CreateFromFile("aaa1.ogg");
sfMusic_Play(Tescior);
}
}
}
sfRenderWindow_Clear(Glowne, sfBlack);
sfRenderWindow_Display(Glowne);
}
sfRenderWindow_Destroy(Glowne);
sfMusic_Destroy(Tescior);
remove("aaa.ogg");
remove("aaa1.ogg");
getch();
return EXIT_SUCCESS;
}