Class: Informix::Slob::Stat
- Inherits:
-
Object
- Object
- Informix::Slob::Stat
- Includes:
- Comparable
- Defined in:
- ext/informixc.c
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
stat <=> other_stat => -1, 0, 1.
-
#atime ⇒ Object
stat.atime => time.
-
#ctime ⇒ Object
stat.ctime => time.
-
#initialize(slob) ⇒ Object
constructor
Slob::Stat.new(slob) => stat.
-
#mtime ⇒ Object
stat.mtime => time.
-
#refcnt ⇒ Object
stat.refcnt => fixnum.
-
#size ⇒ Object
stat.size => fixnum or bignum.
Constructor Details
#initialize(slob) ⇒ Object
Slob::Stat.new(slob) => stat
Creates an Slob::Stat object with status information for the given Slob object.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'ext/informixc.c', line 337
static VALUE
rb_slobstat_initialize(VALUE self, VALUE slob)
{
mint ret;
slob_t *sb;
slobstat_t *stat;
ifx_lo_stat_t *st;
/*
* EXEC SQL begin declare section;
*/
#line 290 "informixc.ec"
#line 291 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 292 "informixc.ec"
Data_Get_Struct(slob, slob_t, sb);
Data_Get_Struct(self, slobstat_t, stat);
if (sb->fd == -1)
rb_raise(rb_eProgrammingError,
"Open the Slob object before getting its status");
did = sb->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 302 "informixc.ec"
{
#line 302 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 302 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
ret = ifx_lo_stat(sb->fd, &st);
if (ret < 0)
raise_ifx_extended();
stat->atime = ifx_lo_stat_atime(st);
stat->ctime = ifx_lo_stat_ctime(st);
stat->mtime = ifx_lo_stat_mtime_sec(st);
stat->refcnt = ifx_lo_stat_refcnt(st);
ret = ifx_lo_stat_size(st, &stat->size);
ifx_lo_stat_free(st);
if (stat->atime == -1 || stat->ctime == -1 || stat->mtime == -1 ||
stat->refcnt == -1 || ret == -1) {
rb_raise(rb_eOperationalError, "Unable to get status");
}
return self;
}
|
Instance Method Details
#<=>(other) ⇒ Object
stat <=> other_stat => -1, 0, 1
Compares with another Slob::Stat
object by comparing their modification times.
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'ext/informixc.c', line 404
static VALUE
rb_slobstat_cmp(VALUE self, VALUE other)
{
if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
slobstat_t *stat;
time_t t1, t2;
Data_Get_Struct(self, slobstat_t, stat); t1 = stat->mtime;
Data_Get_Struct(other, slobstat_t, stat); t2 = stat->mtime;
if (t1 == t2)
return INT2FIX(0);
else if (t1 < t2)
return INT2FIX(-1);
else
return INT2FIX(1);
}
return Qnil;
}
|
#atime ⇒ Object
stat.atime => time
Returns the time of last access as a Time object.
431 432 433 434 435 436 437 438 |
# File 'ext/informixc.c', line 431
static VALUE
rb_slobstat_atime(VALUE self)
{
slobstat_t *stat;
Data_Get_Struct(self, slobstat_t, stat);
return rb_time_new(stat->atime, 0);
}
|
#ctime ⇒ Object
stat.ctime => time
Returns the time of last change in status as a Time object.
446 447 448 449 450 451 452 453 |
# File 'ext/informixc.c', line 446
static VALUE
rb_slobstat_ctime(VALUE self)
{
slobstat_t *stat;
Data_Get_Struct(self, slobstat_t, stat);
return rb_time_new(stat->ctime, 0);
}
|
#mtime ⇒ Object
stat.mtime => time
Returns the time of last modification as a Time object.
461 462 463 464 465 466 467 468 |
# File 'ext/informixc.c', line 461
static VALUE
rb_slobstat_mtime(VALUE self)
{
slobstat_t *stat;
Data_Get_Struct(self, slobstat_t, stat);
return rb_time_new(stat->mtime, 0);
}
|
#refcnt ⇒ Object
stat.refcnt => fixnum
Returns the number of references
476 477 478 479 480 481 482 483 |
# File 'ext/informixc.c', line 476
static VALUE
rb_slobstat_refcnt(VALUE self)
{
slobstat_t *stat;
Data_Get_Struct(self, slobstat_t, stat);
return INT2FIX(stat->refcnt);
}
|
#size ⇒ Object
stat.size => fixnum or bignum
Returns the size in bytes
491 492 493 494 495 496 497 498 499 500 501 |
# File 'ext/informixc.c', line 491
static VALUE
rb_slobstat_size(VALUE self)
{
slobstat_t *stat;
VALUE size;
Data_Get_Struct(self, slobstat_t, stat);
INT82NUM(&stat->size, size);
return size;
}
|