SA-MP Forums Archive
[HELP] Changing file directory - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Changing file directory (/showthread.php?tid=161812)



[HELP] Changing file directory - Holnista - 21.07.2010

Hey guys.

I have a problem and I do not know how to solve it.
It's about moving files to another directory.
for example:

move file: cars/owned/car101.txt
to: cars/free/car101.txt

Can someone give me function, callback or something please?

I really need this!


Re: [HELP] Changing file directory - MadeMan - 21.07.2010

pawn Код:
stock fcopytextfile(oldname[],newname[])
{
    new File:ohnd,File:nhnd;
    if (!fexist(oldname)) return 0;
    ohnd=fopen(oldname,io_read);
    nhnd=fopen(newname,io_write);
    new tmpres[256];
    while (fread(ohnd,tmpres))
    {
        fwrite(nhnd,tmpres);
    }
    fclose(ohnd);
    fclose(nhnd);
    return 1;
}
pawn Код:
fcopytextfile("cars/owned/car101.txt", "cars/free/car101.txt");
This will make a copy. Use fremove to remove the old file.


Re: [HELP] Changing file directory - Holnista - 21.07.2010

Sorry, solved before.
i have own code:
Код:
stock dini_Move(filename[], destination[])
{
   dini_Create(destination);
new string[256], File:From = fopen(filename, io_read), File:To = fopen(destination, io_append);
while(fread(From, string))
{
    format(string, sizeof(string), "%s\r\n", string);
    fwrite(To, string);
 }
dini_Remove(filename);
}
Lock!