fcopy(); - 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)
+--- Thread: fcopy(); (
/showthread.php?tid=316816)
fcopy(); -
Ash. - 08.02.2012
Does anyone have a custom 'fcopy' function? I was thinking of something like:
pawn Код:
stock fcopy(szOne[64], szTwo[64])
{
new szContents[256]; //Appropriate in this case, possibly make it bigger if handling larger files?
new File:f = fopen(szOne, io_read);
fread(f, szContents);
fclose(f);
f = fopen(szTwo, io_write);
fwrite(f, szContents);
fclose(f);
}
I do include some additional checks as to whether the files exist and whatnot in my version, however I'm on my phone at the moment and can't copy + paste it from my laptop haha!
Anyway; I can't seem to get these to work. They only appear to copy the first line of the file. Is there any way round this or a working fcopy function lying around? I searched the forums however any results I got were just suggestions/requests on the creation.
Thanks,
Ash
Re: fcopy(); -
Konstantinos - 08.02.2012
pawn Код:
stock fcopy(oldname[],newname[]) // By MadeMan (But I am not sure 100 percent)
{
new File:ohnd,File:nhnd;
if (!fexist(oldname))
{
return 0;
}
ohnd=fopen(oldname,io_read);
nhnd=fopen(newname,io_write);
new buf2[1];
for (new i=flength(ohnd);i>0;i--)
{
fputchar(nhnd, fgetchar(ohnd, buf2[0],false),false);
}
fclose(ohnd);
fclose(nhnd);
return 1;
}
Re: fcopy(); -
Ash. - 08.02.2012
Thank's Dwane! Perfect!