static int clist_fopen(char fname[gp_file_name_sizeof], const char *fmode, clist_file_ptr * pcf, gs_memory_t * mem, gs_memory_t *data_mem, bool ok_to_compress) { if (*fname == 0) { if (fmode[0] == 'r') return_error(gs_error_invalidfileaccess); *pcf = (clist_file_ptr)gp_open_scratch_file_64(mem, gp_scratch_file_name_prefix, fname, fmode); } else *pcf = gp_fopen(fname, fmode); if (*pcf == NULL) { emprintf1(mem, "Could not open the scratch file %s.\n", fname); return_error(gs_error_invalidfileaccess); } return 0; }
static int clist_fopen(char fname[gp_file_name_sizeof], const char *fmode, clist_file_ptr * pcf, gs_memory_t * mem, gs_memory_t *data_mem, bool ok_to_compress) { if (*fname == 0) { if (fmode[0] == 'r') return_error(gs_error_invalidfileaccess); if (gp_can_share_fdesc()) { *pcf = (clist_file_ptr)wrap_file(mem, gp_open_scratch_file_rm(mem, gp_scratch_file_name_prefix, fname, fmode), fmode); /* If the platform supports FILE duplication then we overwrite the * file name with an encoded form of the FILE pointer */ file_to_fake_path(*pcf, fname); } else { *pcf = (clist_file_ptr)wrap_file(mem, gp_open_scratch_file_64(mem, gp_scratch_file_name_prefix, fname, fmode), fmode); } } else { // Check if a special path is passed in. If so, clone the FILE handle clist_file_ptr ocf = fake_path_to_file(fname); if (ocf) { *pcf = wrap_file(mem, gp_fdup(((IFILE *)ocf)->f, fmode), fmode); } else { *pcf = wrap_file(mem, gp_fopen(fname, fmode), fmode); } } if (*pcf == NULL) { emprintf1(mem, "Could not open the scratch file %s.\n", fname); return_error(gs_error_invalidfileaccess); } return 0; }