www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5452] New: Signed file lengths and positions

http://d.puremagic.com/issues/show_bug.cgi?id=5452

           Summary: Signed file lengths and positions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



In File size() returns an ulong, given by seek():
http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d?rev=2284#L585
http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d?rev=2284#L1245

It uses fseek, that seems to return a signed value:
http://www.cplusplus.com/reference/clibrary/cstdio/ftell/

So isn't it better and safer if those functions of File return a long instead
of an ulong?

See also bug 3843 but here the values are 64 bit, so while 4 GB arrays of bytes
are possible, files of just 9_223_372_036_854_775_807 bytes are not a
significant limitation compared to files 18_446_744_073_709_551_615 bytes long.

Currently unsigned values are quite dangerous in D, so I suggest to avoid
introducing them in Phobos unless where they are necessary.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 13 2011