fcopy();
#1

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
Reply
#2

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;
}
Reply
#3

Thank's Dwane! Perfect!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)