Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just posted <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55119" rel="nofollow">GCC bug 55119</a> on this.</p> <p>While you're waiting (!), the code below works on Mac OS X Mountain Lion. On Windows, it's more complicated; see <code>adainclude/adaint.{c,h}</code>.</p> <p>The Ada spec:</p> <pre><code>with Ada.Directories; package Large_Files is function Size (Name : String) return Ada.Directories.File_Size; end Large_Files; </code></pre> <p>and body (copied in part from <code>Ada.Directories</code>):</p> <pre><code>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 """ &amp; Name &amp; """ 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; </code></pre> <p>and the C interface:</p> <pre><code>/* large_files_interface.c */ #include &lt;sys/stat.h&gt; long long large_file_length (const char *name) { struct stat statbuf; if (stat(name, &amp;statbuf) != 0) { return 0; } else { return (long long) statbuf.st_size; } } </code></pre> <p>You might need to use <code>struct stat64</code> and <code>stat64()</code> on other Unix systems.</p> <p>Compile the C interface as normal, then add <code>-largs large_files_interface.o</code> to your gnatmake command line.</p> <p>EDIT: on Mac OS X (and Debian), which are x86_64 machines, <code>sizeof(long)</code> is 8 bytes; so the comment in <code>adaint.c</code> is misleading and <code>Ada.Directories.Size</code> can return up to 2**63-1.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload