[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49820] fseek fails for large (>4GByte files)
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #49820] fseek fails for large (>4GByte files) |
Date: |
Sat, 10 Dec 2016 13:07:17 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?49820>
Summary: fseek fails for large (>4GByte files)
Project: GNU Octave
Submitted by: None
Submitted on: Sat 10 Dec 2016 01:07:15 PM UTC
Category: Libraries
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Pat Gioannini
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.2.0
Operating System: GNU/Linux
_______________________________________________________
Details:
In file_io.cc the function for fseek contains the code:
DEFUN (fseek, args, ,
doc: /* -*- texinfo -*-
@deftypefn {} {} fseek (@var{fid}, @var{offset})
@deftypefnx {} {} fseek (@var{fid}, @var{offset}, @var{origin})
@deftypefnx {} address@hidden =} fseek (@dots{})
Set the file pointer to the location @var{offset} within the file @var{fid}.
The pointer is positioned @var{offset} characters from the @var{origin},
which may be one of the predefined variables @address@hidden (current
position), @address@hidden (beginning), or @address@hidden (end of
file) or strings @qcode{"cof"}, @qcode{"bof"} or @qcode{"eof"}. If
@var{origin} is omitted, @address@hidden is assumed. @var{offset} may
be positive, negative, or zero but not all combinations of @var{origin} and
@var{offset} can be realized.
@code{fseek} returns 0 on success and -1 on error.
@seealso{fskipl, frewind, ftell, fopen}
@end deftypefn */)
{
int nargin = args.length ();
if (nargin < 2 || nargin > 3)
print_usage ();
octave_stream os = octave_stream_list::lookup (args(0), "fseek");
octave_value origin_arg = (nargin == 3) ? args(2) : octave_value (-1.0);
return ovl (os.seek (args(1), origin_arg));
}
--
The conversion from octave_value in the last line converts args(1) to an int
(32bits) rather than an off_t (64 bits). I changed the last two lines of code
to be:
++
off_t offset = args(1).int64_value();
return ovl (os.seek (offset, origin_arg));
--
I am not familiar enough with octal_value to know if this is really the best
solution. However you must treat the offset parameter as a 64 bit (off_t)
rather than 32 bits for fseek to work properly.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49820>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #49820] fseek fails for large (>4GByte files),
anonymous <=