[macruby-changes] [1588] MacRuby/branches/experimental/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 22 10:36:54 PDT 2009
Revision: 1588
http://trac.macosforge.org/projects/ruby/changeset/1588
Author: pthomson at apple.com
Date: 2009-05-22 10:36:53 -0700 (Fri, 22 May 2009)
Log Message:
-----------
Changed to using off_t for setting CFStream offsets.
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-05-22 12:18:50 UTC (rev 1587)
+++ MacRuby/branches/experimental/io.c 2009-05-22 17:36:53 UTC (rev 1588)
@@ -511,23 +511,23 @@
* f.pos #=> 17
*/
-static inline long long
+static inline off_t
rb_io_read_stream_get_offset(CFReadStreamRef stream)
{
- long long result = 0LL;
+ off_t result;
CFNumberRef pos = CFReadStreamCopyProperty(stream,
kCFStreamPropertyFileCurrentOffset);
- CFNumberGetValue(pos, kCFNumberLongLongType, &result);
+ CFNumberGetValue(pos, kCFNumberLongLongType, (void*)&result);
CFRelease(pos);
return result;
}
static inline void
-rb_io_read_stream_set_offset(CFReadStreamRef stream, long long offset)
+rb_io_read_stream_set_offset(CFReadStreamRef stream, off_t offset)
{
- CFNumberRef pos = CFNumberCreate(NULL, kCFNumberLongLongType, &offset);
+ CFNumberRef pos = CFNumberCreate(NULL, kCFNumberSInt64Type, (const void*)&offset);
CFReadStreamSetProperty(stream, kCFStreamPropertyFileCurrentOffset, pos);
CFRelease(pos);
}
@@ -538,7 +538,7 @@
rb_io_t *io_struct = ExtractIOStruct(io);
rb_io_assert_readable(io_struct);
- return LL2NUM(rb_io_read_stream_get_offset(io_struct->readStream));
+ return OFFT2NUM(rb_io_read_stream_get_offset(io_struct->readStream));
}
static VALUE
@@ -546,10 +546,12 @@
{
rb_io_t *io_struct = ExtractIOStruct(io);
rb_io_assert_readable(io_struct);
-
+ if (whence == SEEK_CUR) {
+ offset += rb_io_read_stream_get_offset(io_struct->readStream);
+ }
// TODO: make this work with IO::SEEK_CUR, SEEK_END, etc.
- rb_io_read_stream_set_offset(io_struct->readStream, NUM2LL(offset));
-
+ rb_io_read_stream_set_offset(io_struct->readStream, NUM2OFFT(offset));
+
return INT2FIX(0); // is this right?
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090522/1b88e5dd/attachment.html>
More information about the macruby-changes
mailing list