Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
48 user(s) are online (34 user(s) are browsing Forums)

Members: 0
Guests: 48

more...
Support us!
Recent OS4 Files
OS4Depot.net
Report message:*
 

Re: Porting to AmigaOS4 thread

Subject: Re: Porting to AmigaOS4 thread
by BSzili on 2019/2/23 10:15:16

@NoCache
I ended up creating my own wrapper function to do this:
void fseek_mos(FILE *fplong ofs)
{
    
long cpos ftell(fp);
    
    if (
cpos == ofs)
    {
        return;
    }
    else if (
cpos ofs)
    {
        
fseek(fpofsSEEK_SET);
    }
    else
    {
        
fseek(fp0SEEK_END);
        
        
cpos ftell(fp);
        
        if (
cpos == ofs)
        {
            return;
        }
        else if (
cpos ofs)
        {
            
fseek(fpofsSEEK_SET);
        }
        else
        {    
            
long i;
            
long diff ofs cpos;
            
            for (
0diffi++)
            {
                
fputc(0fp);
            }
        }
    }
}

The fputc loop could be replaced with fwrite, but I wrote this as a quick workaround for NX Engine.

Edit: I just noticed that my example uses FILE pointers, but it can be rewritten to use lseek/write for file descriptors. I have a version for C++ iostreams too that I used in Arx Libertatis.
Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project