static void oci8_bfile_get_name(VALUE self, VALUE *dir_alias_p, VALUE *filename_p) { int need_get = 0; if (dir_alias_p != NULL) { *dir_alias_p = rb_ivar_get(self, id_dir_alias); if (NIL_P(*dir_alias_p)) need_get = 1; } if (filename_p != NULL) { *filename_p = rb_ivar_get(self, id_filename); if (NIL_P(*filename_p)) need_get = 1; } if (need_get) { oci8_lob_t *lob = DATA_PTR(self); char d_buf[31]; ub2 d_length = sizeof(d_buf); char f_buf[256]; ub2 f_length = sizeof(f_buf); VALUE dir_alias; VALUE filename; oci_lc(OCILobFileGetName(oci8_envhp, oci8_errhp, lob->base.hp.lob, TO_ORATEXT(d_buf), &d_length, TO_ORATEXT(f_buf), &f_length)); dir_alias = rb_external_str_new_with_enc(d_buf, d_length, oci8_encoding); filename = rb_external_str_new_with_enc(f_buf, f_length, oci8_encoding); rb_ivar_set(self, id_dir_alias, dir_alias); rb_ivar_set(self, id_filename, filename); if (dir_alias_p != NULL) { *dir_alias_p = dir_alias; } if (filename_p != NULL) { *filename_p = filename; } } }
void ConvertorForRead::Fire(const BindParCFile &BP, SqlClob &CL) { CL._ind = BP.indp[_row]; if(CL.is_not_null()) { sword res = OCICALL(OCILobAssign(BP._env, BP._env._errh, ((OCILobLocator**)BP.valuep)[_row], &CL._loc)); oci_check_error(__TROTL_HERE__, BP._env._errh, res); char dirname[33], filename[256]; ub2 dirnamelen = sizeof(dirname); ub2 filenamelen = sizeof(filename); res = OCICALL(OCILobFileGetName(BP._env, BP._env._errh, ((OCILobLocator**)BP.valuep)[_row], (OraText*)dirname, &dirnamelen, (OraText*)filename, &filenamelen )); oci_check_error(__TROTL_HERE__, BP._env._errh, res); CL._dirname = tstring(dirname, dirnamelen); CL._filename = tstring(filename, filenamelen); } };
boolean OCI_FileGetInfo ( OCI_File *file ) { boolean res = TRUE; OCI_CHECK_PTR(OCI_IPC_FILE, file, FALSE); /* directory name */ if (file->dir == NULL) { if (res == TRUE) { file->dir = (mtext *) OCI_MemAlloc(OCI_IPC_STRING, sizeof(mtext), (size_t) (OCI_SIZE_DIRECTORY + 1), TRUE); res = (file->dir != NULL); } } else { file->dir[0] = 0; } /* file name */ if (file->name == NULL) { if (res == TRUE) { file->name = (mtext *) OCI_MemAlloc(OCI_IPC_STRING, sizeof(mtext), (size_t)( OCI_SIZE_FILENAME + 1), TRUE); res = (file->name != NULL); } } else { file->name[0] = 0; } /* retrieve name */ if (res == TRUE) { void *ostr1 = NULL; void *ostr2 = NULL; int osize1 = 0; int osize2 = 0; ub2 usize1 = 0; ub2 usize2 = 0; osize1 = (int ) OCI_SIZE_DIRECTORY * (int) sizeof(mtext); ostr1 = (void *) OCI_GetInputMetaString(file->dir, &osize1); osize2 = (int ) OCI_SIZE_FILENAME * (int) sizeof(mtext); ostr2 = (void *) OCI_GetInputMetaString(file->name, &osize1); usize1 = (ub2) osize1; usize2 = (ub2) osize2; OCI_CALL2 ( res, file->con, OCILobFileGetName(file->con->env, file->con->err, file->handle, (OraText *) ostr1, (ub2*) &usize1, (OraText *) ostr2, (ub2*) &usize2) ) osize1 = (int) usize1; osize2 = (int) usize2; OCI_GetOutputMetaString(ostr1, file->dir, &osize1); OCI_GetOutputMetaString(ostr2, file->name, &osize2); OCI_ReleaseMetaString(ostr1); OCI_ReleaseMetaString(ostr2); } return res; }