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.
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 396 397 398 399 400 401 402 |
# File 'ext/informixc.c', line 344
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 297 "informixc.ec"
#line 298 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 299 "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 309 "informixc.ec"
{
#line 309 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 309 "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.
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'ext/informixc.c', line 411
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.
438 439 440 441 442 443 444 445 |
# File 'ext/informixc.c', line 438
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.
453 454 455 456 457 458 459 460 |
# File 'ext/informixc.c', line 453
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.
468 469 470 471 472 473 474 475 |
# File 'ext/informixc.c', line 468
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
483 484 485 486 487 488 489 490 |
# File 'ext/informixc.c', line 483
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
498 499 500 501 502 503 504 505 506 507 508 |
# File 'ext/informixc.c', line 498
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;
}
|