/* worker function for changing to a relative filename */ static int do_change_relative(DATAFILE *dat, int *param, int param2) { AL_CONST char *orig = get_datafile_property(dat, DAT_ORIG); char relative[FILENAME_LENGTH]; if (!orig[0] || is_relative_filename(orig)) { (*param)++; return D_O_K; } make_relative_filename(relative, grabber_data_file, orig, FILENAME_LENGTH); datedit_set_property(dat, DAT_ORIG, relative); return D_REDRAW; }
static gchar *mh_item_get_path(Folder *folder, FolderItem *item) { gchar *folder_path, *path; gchar *real_path; cm_return_val_if_fail(folder != NULL, NULL); cm_return_val_if_fail(item != NULL, NULL); folder_path = g_strdup(LOCAL_FOLDER(folder)->rootpath); cm_return_val_if_fail(folder_path != NULL, NULL); /* FIXME: [W32] The code below does not correctly merge relative filenames; there should be a function to handle this. */ if ( !is_relative_filename (folder_path) ) { if (item->path) path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, item->path, NULL); else path = g_strdup(folder_path); } else { if (item->path) path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, folder_path, G_DIR_SEPARATOR_S, item->path, NULL); else path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, folder_path, NULL); } g_free(folder_path); real_path = mh_filename_from_utf8(path); if (!is_dir_exist(real_path) && is_dir_exist(path)) { /* mmh, older version did put utf8 filenames instead of * the correct encoding */ if (g_rename(path, real_path) == 0) folder_item_scan(item); } g_free(path); return real_path; }
/* load_txt_font: * Loads a scripted font. */ FONT *load_txt_font(AL_CONST char *filename, RGB *pal, void *param) { char buf[1024], *font_str, *start_str = 0, *end_str = 0; char font_filename[1024]; FONT *f, *f2, *f3, *f4; PACKFILE *pack; int begin, end, glyph_pos=32; pack = pack_fopen(filename, F_READ); if (!pack) return NULL; f = f2 = f3 = f4 = NULL; while(pack_fgets(buf, sizeof(buf)-1, pack)) { font_str = strtok(buf, " \t"); if (font_str) start_str = strtok(0, " \t"); if (start_str) end_str = strtok(0, " \t"); if (!font_str || !start_str) { if (f) destroy_font(f); if (f2) destroy_font(f2); pack_fclose(pack); return NULL; } if(font_str[0] == '-') font_str[0] = '\0'; begin = strtol(start_str, 0, 0); if (end_str) end = strtol(end_str, 0, 0); else end = -1; if(begin <= 0 || (end > 0 && end < begin)) { if (f) destroy_font(f); if (f2) destroy_font(f2); pack_fclose(pack); return NULL; } /* Load the font that needs to be merged with the current font */ if (font_str[0]) { if (f2) destroy_font(f2); if (exists(font_str)) { f2 = load_font(font_str, pal, param); } else if (is_relative_filename(font_str)) { replace_filename(font_filename, filename, font_str, sizeof(font_filename)); f2 = load_font(font_filename, pal, param); } else { f2 = NULL; } if (f2) glyph_pos=get_font_range_begin(f2, -1); } if (!f2) { if (f) destroy_font(f); pack_fclose(pack); return NULL; } if (end == -1) end = begin + get_font_range_end(f2,-1) - glyph_pos; /* transpose the font to the range given in the .txt file */ f4=extract_font_range(f2,glyph_pos,glyph_pos + (end - begin)); if (f4 && (begin != glyph_pos)) { transpose_font(f4, begin - glyph_pos); } glyph_pos += (end - begin) + 1; /* FIXME: More efficient way than to repeatedely merge into a new font? */ if (f && f4) { f3 = f; f = merge_fonts(f4, f3); destroy_font(f4); destroy_font(f3); } else { f = f4; } f3=f4=NULL; } if (f2) destroy_font(f2); pack_fclose(pack); return f; }