comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan Bellon <bellon@software-erosion.org>
Subject: Re: Ada.Directories.Size wraps on over 2Gb files
Date: Mon, 10 Dec 2007 23:28:46 +0100
Date: 2007-12-10T23:28:46+01:00	[thread overview]
Message-ID: <20071210232846.480b5898@cube.tz.axivion.com> (raw)
In-Reply-To: 0db40dde-17f0-40a9-9dc0-55f9b0a8e1b1@x69g2000hsx.googlegroups.com

On Mo, 10 Dez, gpriv@axonx.com wrote:

[2GB limitation]

> Types are all seem to be long integers, so it looks like truncation is
> being made somewhere in C code (?)

I cannot speak for Ada.Directories.Size as I have not looked closer at
it, but the same 2 GB restriction is present on other parts of the GNAT
libraries at present as well (i.e. the whole of adaint.c does not make
use of O_LARGEFILE), so we ended up in coding our own binding to the
open/read/write/close category of functions with something like this:

#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#ifndef __MINGW32__
#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#define O_BINARY 0
#else
#define PERM (S_IREAD | S_IWRITE)
#define O_LARGEFILE 0
#endif

And later on we do something like the following:

int my_open(const char *pathname)
{   
    return open
        (pathname,
         O_RDONLY | O_BINARY | O_LARGEFILE);
}

int my_create(const char *pathname)
{
    return open
        (pathname,
         O_CREAT | O_WRONLY | O_TRUNC | O_BINARY | O_LARGEFILE,
         PERM);
}

NB: This is just an excerpt and only part of the code for illustration
purposes.

-- 
Stefan Bellon



  reply	other threads:[~2007-12-10 22:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-10 21:38 Ada.Directories.Size wraps on over 2Gb files gpriv
2007-12-10 22:28 ` Stefan Bellon [this message]
2007-12-11  1:29 ` Randy Brukardt
2007-12-11  1:36   ` gpriv
  -- strict thread matches above, loose matches on Subject: below --
2007-12-10 21:37 gpriv
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox