582 lo_mode = INV_READ|INV_WRITE; |
582 lo_mode = INV_READ|INV_WRITE; |
583 } else if((oflags & O_WRONLY) == O_WRONLY) { |
583 } else if((oflags & O_WRONLY) == O_WRONLY) { |
584 lo_mode = INV_WRITE; |
584 lo_mode = INV_WRITE; |
585 } |
585 } |
586 fd = lo_open(pg->connection, oid, lo_mode); |
586 fd = lo_open(pg->connection, oid, lo_mode); |
|
587 int err = 0; |
|
588 if(fd < 0) { |
|
589 err = 1; |
|
590 } else if((oflags & O_TRUNC) == O_TRUNC) { |
|
591 if(lo_truncate(pg->connection, fd, 0)) { |
|
592 lo_close(pg->connection, fd); |
|
593 err = 1; |
|
594 } |
|
595 } |
|
596 |
|
597 if(err) { |
|
598 pool_free(ctx->pool, file); |
|
599 pool_free(ctx->pool, pgfile); |
|
600 return NULL; |
|
601 } |
587 } |
602 } |
588 |
603 |
589 pgfile->iscollection = iscollection; |
604 pgfile->iscollection = iscollection; |
590 pgfile->resource_id = resource_id; |
605 pgfile->resource_id = resource_id; |
591 pgfile->parent_id = parent_id; |
606 pgfile->parent_id = parent_id; |