Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:07:55+00:00 2026-06-13T12:07:55+00:00

I’ve written an Ada program which encrypts files. It reads them block by block

  • 0

I’ve written an Ada program which encrypts files. It reads them block by block to conserve memory on the target machine. Unfortunately Ada’s Directories library reads filesizes in a Long_Integer, limiting the read to almost 2GB files. When trying to read files over 2GB, the program fails at runtime getting a stack overflow error.

The documentation for it here is the origin of my understanding above. How can I read a filesize into a type I define myself? One I can make requiring something like 25 bytes to increase the cap to 100GB.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:07:56+00:00Added an answer on June 13, 2026 at 12:07 pm

    I just posted GCC bug 55119 on this.

    While you’re waiting (!), the code below works on Mac OS X Mountain Lion. On Windows, it’s more complicated; see adainclude/adaint.{c,h}.

    The Ada spec:

    with Ada.Directories;
    package Large_Files is
    
       function Size (Name : String) return Ada.Directories.File_Size;
    
    end Large_Files;
    

    and body (copied in part from Ada.Directories):

    with GNAT.OS_Lib;
    with System;
    package body Large_Files is
    
       function Size (Name : String) return Ada.Directories.File_Size
       is
          C_Name : String (1 .. Name'Length + 1);
          function C_Size (Name : System.Address) return Long_Long_Integer;
          pragma Import (C, C_Size, "large_file_length");
       begin
          if not GNAT.OS_Lib.Is_Regular_File (Name) then
             raise Ada.Directories.Name_Error
               with "file """ & Name & """ does not exist";
          else
             C_Name (1 .. Name'Length) := Name;
             C_Name (C_Name'Last) := ASCII.NUL;
             return Ada.Directories.File_Size (C_Size (C_Name'Address));
          end if;
       end Size;
    
    end Large_Files;
    

    and the C interface:

    /* large_files_interface.c */
    
    #include <sys/stat.h>
    
    long long large_file_length (const char *name)
    {
      struct stat statbuf;
      if (stat(name, &statbuf) != 0) {
        return 0;
      } else {
        return (long long) statbuf.st_size;
      }
    }
    

    You might need to use struct stat64 and stat64() on other Unix systems.

    Compile the C interface as normal, then add -largs large_files_interface.o to your gnatmake command line.

    EDIT: on Mac OS X (and Debian), which are x86_64 machines, sizeof(long) is 8 bytes; so the comment in adaint.c is misleading and Ada.Directories.Size can return up to 2**63-1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.