get rid of MAX_PATH_CHARACTERS in T_Page and T_Selector_Settings
strdup() the dynammicaly allocated filename and directory strings
This commit is contained in:
		
							parent
							
								
									98811b6363
								
							
						
					
					
						commit
						79446a9c72
					
				
							
								
								
									
										110
									
								
								src/buttons.c
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								src/buttons.c
									
									
									
									
									
								
							@ -3176,35 +3176,23 @@ void Load_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
  byte  old_cursor_shape;
 | 
					  byte  old_cursor_shape;
 | 
				
			||||||
  int   new_mode;
 | 
					  int   new_mode;
 | 
				
			||||||
  T_IO_Context context;
 | 
					  T_IO_Context context;
 | 
				
			||||||
  static char filename [MAX_PATH_CHARACTERS];
 | 
					  word * filename_unicode = NULL;
 | 
				
			||||||
  static word filename_unicode[MAX_PATH_CHARACTERS];
 | 
					 | 
				
			||||||
  static char directory[MAX_PATH_CHARACTERS];
 | 
					 | 
				
			||||||
  T_Selector_settings * selector;
 | 
					  T_Selector_settings * selector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (type)
 | 
					  switch (type)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
  case CONTEXT_MAIN_IMAGE:
 | 
					  case CONTEXT_MAIN_IMAGE:
 | 
				
			||||||
    strcpy(filename, Main.backups->Pages->Filename);
 | 
					    filename_unicode = Main.backups->Pages->Filename_unicode;
 | 
				
			||||||
    Unicode_strlcpy(filename_unicode, Main.backups->Pages->Filename_unicode, MAX_PATH_CHARACTERS);
 | 
					    Init_context_layered_image(&context, Main.backups->Pages->Filename, Main.backups->Pages->File_directory);
 | 
				
			||||||
    strcpy(directory, Main.backups->Pages->File_directory);
 | 
					 | 
				
			||||||
    Init_context_layered_image(&context, filename, directory);
 | 
					 | 
				
			||||||
    selector = &Main.selector;
 | 
					    selector = &Main.selector;
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case CONTEXT_BRUSH:
 | 
					  case CONTEXT_BRUSH:
 | 
				
			||||||
    strcpy(filename, Brush_filename);
 | 
					    filename_unicode = Brush_filename_unicode;
 | 
				
			||||||
    if (Brush_filename_unicode != NULL)
 | 
					    Init_context_brush(&context, Brush_filename, Brush_file_directory);
 | 
				
			||||||
      Unicode_strlcpy(filename_unicode, Brush_filename_unicode, MAX_PATH_CHARACTERS);
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      filename_unicode[0] = 0;
 | 
					 | 
				
			||||||
    strcpy(directory, Brush_file_directory);
 | 
					 | 
				
			||||||
    Init_context_brush(&context, filename, directory);
 | 
					 | 
				
			||||||
    selector = &Brush_selector;
 | 
					    selector = &Brush_selector;
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case CONTEXT_PALETTE:
 | 
					  case CONTEXT_PALETTE:
 | 
				
			||||||
    strcpy(filename, "");
 | 
					    Init_context_layered_image(&context, "", Main.backups->Pages->File_directory);
 | 
				
			||||||
    filename_unicode[0] = 0;
 | 
					 | 
				
			||||||
    strcpy(directory, Main.backups->Pages->File_directory);
 | 
					 | 
				
			||||||
    Init_context_layered_image(&context, filename, directory);
 | 
					 | 
				
			||||||
    context.Type = CONTEXT_PALETTE;
 | 
					    context.Type = CONTEXT_PALETTE;
 | 
				
			||||||
    context.Format = FORMAT_PAL;
 | 
					    context.Format = FORMAT_PAL;
 | 
				
			||||||
    selector = &Palette_selector;
 | 
					    selector = &Palette_selector;
 | 
				
			||||||
@ -3212,8 +3200,8 @@ void Load_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
  default:
 | 
					  default:
 | 
				
			||||||
    return; // DO NOTHING
 | 
					    return; // DO NOTHING
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  context.File_name_unicode = filename_unicode;
 | 
					  context.File_name_unicode = Unicode_strdup(filename_unicode);
 | 
				
			||||||
  confirm=Button_Load_or_Save(selector, 1, &context);
 | 
					  confirm = Button_Load_or_Save(selector, 1, &context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (confirm)
 | 
					  if (confirm)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -3244,14 +3232,14 @@ void Load_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
    if (type==CONTEXT_BRUSH)
 | 
					    if (type==CONTEXT_BRUSH)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      free(Brush_filename);
 | 
					      free(Brush_filename);
 | 
				
			||||||
      Brush_filename = strdup(context.File_name);
 | 
					      Brush_filename = context.File_name; // "steal" heap string
 | 
				
			||||||
 | 
					      context.File_name = NULL;
 | 
				
			||||||
      free(Brush_filename_unicode);
 | 
					      free(Brush_filename_unicode);
 | 
				
			||||||
      if (context.File_name_unicode != NULL && context.File_name_unicode[0] != 0)
 | 
					      Brush_filename_unicode = context.File_name_unicode; // "steal" heap string
 | 
				
			||||||
        Brush_filename_unicode = Unicode_strdup(context.File_name_unicode);
 | 
					      context.File_name_unicode = NULL;
 | 
				
			||||||
      else
 | 
					 | 
				
			||||||
        Brush_filename_unicode = NULL;
 | 
					 | 
				
			||||||
      free(Brush_file_directory);
 | 
					      free(Brush_file_directory);
 | 
				
			||||||
      Brush_file_directory = strdup(context.File_directory);
 | 
					      Brush_file_directory = context.File_directory;  // "steal" heap string
 | 
				
			||||||
 | 
					      context.File_directory = NULL;
 | 
				
			||||||
      Brush_fileformat = context.Format;
 | 
					      Brush_fileformat = context.Format;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      Tiling_offset_X=0;
 | 
					      Tiling_offset_X=0;
 | 
				
			||||||
@ -3337,12 +3325,12 @@ void Load_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Destroy_context(&context);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Display_menu();
 | 
					    Display_menu();
 | 
				
			||||||
    Display_cursor();
 | 
					    Display_cursor();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Destroy_context(&context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Hide_cursor();
 | 
					  Hide_cursor();
 | 
				
			||||||
  Print_filename();
 | 
					  Print_filename();
 | 
				
			||||||
  Display_cursor();
 | 
					  Display_cursor();
 | 
				
			||||||
@ -3503,48 +3491,42 @@ void Save_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
  byte  confirm;
 | 
					  byte  confirm;
 | 
				
			||||||
  byte  old_cursor_shape;
 | 
					  byte  old_cursor_shape;
 | 
				
			||||||
  T_IO_Context save_context;
 | 
					  T_IO_Context save_context;
 | 
				
			||||||
  static char filename [MAX_PATH_CHARACTERS];
 | 
					  word * filename_unicode = NULL;
 | 
				
			||||||
  static word filename_unicode[MAX_PATH_CHARACTERS];
 | 
					 | 
				
			||||||
  static char directory[MAX_PATH_CHARACTERS];
 | 
					 | 
				
			||||||
  T_Selector_settings * selector;
 | 
					  T_Selector_settings * selector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (type == CONTEXT_MAIN_IMAGE)
 | 
					  if (type == CONTEXT_MAIN_IMAGE)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    strcpy(filename, Main.backups->Pages->Filename);
 | 
					    filename_unicode = Main.backups->Pages->Filename_unicode;
 | 
				
			||||||
    strcpy(directory, Main.backups->Pages->File_directory);
 | 
					    Init_context_layered_image(&save_context, Main.backups->Pages->Filename, Main.backups->Pages->File_directory);
 | 
				
			||||||
    Unicode_strlcpy(filename_unicode, Main.backups->Pages->Filename_unicode, MAX_PATH_CHARACTERS);
 | 
					 | 
				
			||||||
    Init_context_layered_image(&save_context, filename, directory);
 | 
					 | 
				
			||||||
    save_context.Format = Main.fileformat;
 | 
					    save_context.Format = Main.fileformat;
 | 
				
			||||||
    selector = &Main.selector;
 | 
					    selector = &Main.selector;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (type == CONTEXT_BRUSH)
 | 
					  else if (type == CONTEXT_BRUSH)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    strcpy(filename, Brush_filename);
 | 
					    filename_unicode = Brush_filename_unicode;
 | 
				
			||||||
    if (Brush_filename_unicode != NULL)
 | 
					    Init_context_brush(&save_context, Brush_filename, Brush_file_directory);
 | 
				
			||||||
      Unicode_strlcpy(filename_unicode, Brush_filename_unicode, MAX_PATH_CHARACTERS);
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      filename_unicode[0] = 0;
 | 
					 | 
				
			||||||
    strcpy(directory, Brush_file_directory);
 | 
					 | 
				
			||||||
    Init_context_brush(&save_context, filename, directory);
 | 
					 | 
				
			||||||
    save_context.Format = Brush_fileformat;
 | 
					    save_context.Format = Brush_fileformat;
 | 
				
			||||||
    selector = &Brush_selector;
 | 
					    selector = &Brush_selector;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (type == CONTEXT_PALETTE)
 | 
					  else if (type == CONTEXT_PALETTE)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    char* pal_filename;
 | 
				
			||||||
    char* dotpos;
 | 
					    char* dotpos;
 | 
				
			||||||
    strcpy(filename, Main.backups->Pages->Filename);
 | 
					    size_t len = strlen(Main.backups->Pages->Filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pal_filename = malloc(len + 4 + 1); // reserve space for ".pal"
 | 
				
			||||||
 | 
					    memcpy(pal_filename, Main.backups->Pages->Filename, len + 1);
 | 
				
			||||||
    // Replace extension with PAL
 | 
					    // Replace extension with PAL
 | 
				
			||||||
    dotpos = strrchr(filename, '.');
 | 
					    dotpos = strrchr(pal_filename, '.');
 | 
				
			||||||
    if (dotpos == NULL)
 | 
					    if (dotpos == NULL)
 | 
				
			||||||
      dotpos = filename + strlen(filename);
 | 
					      dotpos = pal_filename + len;
 | 
				
			||||||
    strcpy(dotpos, ".pal");
 | 
					    strcpy(dotpos, ".pal");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    filename_unicode[0] = 0;
 | 
					    Init_context_layered_image(&save_context, pal_filename, Main.backups->Pages->File_directory);
 | 
				
			||||||
    strcpy(directory, Main.backups->Pages->File_directory);
 | 
					 | 
				
			||||||
    Init_context_layered_image(&save_context, filename, directory);
 | 
					 | 
				
			||||||
    save_context.Type = CONTEXT_PALETTE;
 | 
					    save_context.Type = CONTEXT_PALETTE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    free(pal_filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set format to PAL
 | 
					    // Set format to PAL
 | 
				
			||||||
    save_context.Format = FORMAT_PAL;
 | 
					    save_context.Format = FORMAT_PAL;
 | 
				
			||||||
    selector = &Palette_selector;
 | 
					    selector = &Palette_selector;
 | 
				
			||||||
@ -3552,7 +3534,7 @@ void Save_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
  else
 | 
					  else
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  save_context.File_name_unicode = filename_unicode;
 | 
					  save_context.File_name_unicode = Unicode_strdup(filename_unicode);
 | 
				
			||||||
  confirm=Button_Load_or_Save(selector, 0, &save_context);
 | 
					  confirm=Button_Load_or_Save(selector, 0, &save_context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (confirm && File_exists(save_context.File_name))
 | 
					  if (confirm && File_exists(save_context.File_name))
 | 
				
			||||||
@ -3560,7 +3542,7 @@ void Save_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
    confirm=Confirmation_box("Erase old file ?");
 | 
					    confirm=Confirmation_box("Erase old file ?");
 | 
				
			||||||
    if (confirm && (Config.Backup))
 | 
					    if (confirm && (Config.Backup))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      char * full_filename = Filepath_append_to_dir(directory, filename);
 | 
					      char * full_filename = Filepath_append_to_dir(save_context.File_directory, save_context.File_name);
 | 
				
			||||||
      Backup_existing_file(full_filename);
 | 
					      Backup_existing_file(full_filename);
 | 
				
			||||||
      free(full_filename);
 | 
					      free(full_filename);
 | 
				
			||||||
      if (File_error)
 | 
					      if (File_error)
 | 
				
			||||||
@ -3585,24 +3567,30 @@ void Save_picture(enum CONTEXT_TYPE type)
 | 
				
			|||||||
    format=Get_fileformat(save_context.Format);
 | 
					    format=Get_fileformat(save_context.Format);
 | 
				
			||||||
    if (!File_error && type == CONTEXT_MAIN_IMAGE && !format->Palette_only && (Main.backups->Pages->Nb_layers==1 || format->Supports_layers))
 | 
					    if (!File_error && type == CONTEXT_MAIN_IMAGE && !format->Palette_only && (Main.backups->Pages->Nb_layers==1 || format->Supports_layers))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      Main.image_is_modified=0;
 | 
					      Main.image_is_modified = 0;
 | 
				
			||||||
      Main.fileformat=save_context.Format;
 | 
					      Main.fileformat = save_context.Format;
 | 
				
			||||||
      strcpy(Main.backups->Pages->Filename, save_context.File_name);
 | 
					      free(Main.backups->Pages->Filename);
 | 
				
			||||||
      Unicode_strlcpy(Main.backups->Pages->Filename_unicode, save_context.File_name_unicode, MAX_PATH_CHARACTERS);
 | 
					      Main.backups->Pages->Filename = save_context.File_name; // "steal" string from heap
 | 
				
			||||||
      strcpy(Main.backups->Pages->File_directory, save_context.File_directory);
 | 
					      save_context.File_name = NULL;
 | 
				
			||||||
 | 
					      free(Main.backups->Pages->Filename_unicode);
 | 
				
			||||||
 | 
					      Main.backups->Pages->Filename_unicode = save_context.File_name_unicode; // "steal" string
 | 
				
			||||||
 | 
					      save_context.File_name_unicode = NULL;
 | 
				
			||||||
 | 
					      free(Main.backups->Pages->File_directory);
 | 
				
			||||||
 | 
					      Main.backups->Pages->File_directory = save_context.File_directory;
 | 
				
			||||||
 | 
					      save_context.File_directory = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (type == CONTEXT_BRUSH)
 | 
					    if (type == CONTEXT_BRUSH)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      Brush_fileformat = save_context.Format;
 | 
					      Brush_fileformat = save_context.Format;
 | 
				
			||||||
      free(Brush_filename);
 | 
					      free(Brush_filename);
 | 
				
			||||||
      Brush_filename = strdup(save_context.File_name);
 | 
					      Brush_filename = save_context.File_name;
 | 
				
			||||||
 | 
					      save_context.File_name = NULL;
 | 
				
			||||||
      free(Brush_filename_unicode);
 | 
					      free(Brush_filename_unicode);
 | 
				
			||||||
      if (save_context.File_name_unicode != NULL && save_context.File_name_unicode[0] != 0)
 | 
					      Brush_filename_unicode = save_context.File_name_unicode;
 | 
				
			||||||
        Brush_filename_unicode = Unicode_strdup(save_context.File_name_unicode);
 | 
					      save_context.File_name_unicode = NULL;
 | 
				
			||||||
      else
 | 
					 | 
				
			||||||
        Brush_filename_unicode = NULL;
 | 
					 | 
				
			||||||
      free(Brush_file_directory);
 | 
					      free(Brush_file_directory);
 | 
				
			||||||
      Brush_file_directory = strdup(save_context.File_directory);
 | 
					      Brush_file_directory = save_context.File_directory;
 | 
				
			||||||
 | 
					      save_context.File_directory = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    Hide_cursor();
 | 
					    Hide_cursor();
 | 
				
			||||||
    Cursor_shape=old_cursor_shape;
 | 
					    Cursor_shape=old_cursor_shape;
 | 
				
			||||||
 | 
				
			|||||||
@ -548,8 +548,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
 | 
				
			|||||||
// correspond au format demandé.
 | 
					// correspond au format demandé.
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  struct Read_dir_pdata callback_data;
 | 
					  struct Read_dir_pdata callback_data;
 | 
				
			||||||
  const char * current_path = NULL;
 | 
					  char * current_path;
 | 
				
			||||||
  char curdir[MAX_PATH_CHARACTERS];
 | 
					 | 
				
			||||||
#if defined (__MINT__)
 | 
					#if defined (__MINT__)
 | 
				
			||||||
  T_Fileselector_item *item=0;
 | 
					  T_Fileselector_item *item=0;
 | 
				
			||||||
  bool bFound=false;
 | 
					  bool bFound=false;
 | 
				
			||||||
@ -564,7 +563,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
 | 
				
			|||||||
  // Après effacement, il ne reste ni fichier ni répertoire dans la liste
 | 
					  // Après effacement, il ne reste ni fichier ni répertoire dans la liste
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On lit tous les répertoires:
 | 
					  // On lit tous les répertoires:
 | 
				
			||||||
  current_path = Get_current_directory(curdir, NULL, MAX_PATH_CHARACTERS);
 | 
					  current_path = Get_current_directory(NULL, NULL, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  For_each_directory_entry(current_path, &callback_data, Read_dir_callback);
 | 
					  For_each_directory_entry(current_path, &callback_data, Read_dir_callback);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -619,7 +618,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  current_path = NULL;
 | 
					  free(current_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (list->Nb_files==0 && list->Nb_directories==0)
 | 
					  if (list->Nb_files==0 && list->Nb_directories==0)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -1788,7 +1787,9 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Change_directory(context->File_directory);
 | 
					  Change_directory(context->File_directory);
 | 
				
			||||||
  Get_current_directory(Selector->Directory, Selector->Directory_unicode, MAX_PATH_CHARACTERS);
 | 
					  free(Selector->Directory);
 | 
				
			||||||
 | 
					  free(Selector->Directory_unicode);
 | 
				
			||||||
 | 
					  Selector->Directory = Get_current_directory(NULL, &Selector->Directory_unicode, 0);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Affichage des premiers fichiers visibles:
 | 
					  // Affichage des premiers fichiers visibles:
 | 
				
			||||||
  Reload_list_of_files(Selector->Format_filter,file_scroller);
 | 
					  Reload_list_of_files(Selector->Format_filter,file_scroller);
 | 
				
			||||||
@ -1802,8 +1803,11 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // On initialise le nom de fichier à celui en cours et non pas celui sous
 | 
					    // On initialise le nom de fichier à celui en cours et non pas celui sous
 | 
				
			||||||
    // la barre de sélection
 | 
					    // la barre de sélection
 | 
				
			||||||
    strcpy(Selector_filename,context->File_name);
 | 
					    strcpy(Selector_filename, context->File_name);
 | 
				
			||||||
 | 
					    if (context->File_name_unicode != NULL)
 | 
				
			||||||
      Unicode_strlcpy(Selector_filename_unicode, context->File_name_unicode, 256);
 | 
					      Unicode_strlcpy(Selector_filename_unicode, context->File_name_unicode, 256);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      Selector_filename_unicode[0] = 0;
 | 
				
			||||||
    // On affiche le nouveau nom de fichier
 | 
					    // On affiche le nouveau nom de fichier
 | 
				
			||||||
    Print_filename_in_fileselector();
 | 
					    Print_filename_in_fileselector();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -2424,7 +2428,9 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
            Extract_filename(previous_directory, Selector->Directory);
 | 
					            Extract_filename(previous_directory, Selector->Directory);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          Get_current_directory(Selector->Directory, Selector->Directory_unicode, MAX_PATH_CHARACTERS);
 | 
					          free(Selector->Directory);
 | 
				
			||||||
 | 
					          free(Selector->Directory_unicode);
 | 
				
			||||||
 | 
					          Selector->Directory = Get_current_directory(NULL, &Selector->Directory_unicode, 0);
 | 
				
			||||||
          // read the new directory
 | 
					          // read the new directory
 | 
				
			||||||
          Read_list_of_files(&Filelist, Selector->Format_filter);
 | 
					          Read_list_of_files(&Filelist, Selector->Format_filter);
 | 
				
			||||||
          Sort_list_of_files(&Filelist);
 | 
					          Sort_list_of_files(&Filelist);
 | 
				
			||||||
@ -2456,7 +2462,8 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      else  // Sinon on essaye de charger ou sauver le fichier
 | 
					      else  // Sinon on essaye de charger ou sauver le fichier
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        strcpy(context->File_directory,Selector->Directory);
 | 
					        free(context->File_directory);
 | 
				
			||||||
 | 
					        context->File_directory = strdup(Selector->Directory);
 | 
				
			||||||
        context->Format = Selector->Format_filter;
 | 
					        context->Format = Selector->Format_filter;
 | 
				
			||||||
        save_or_load_image=1;
 | 
					        save_or_load_image=1;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -2516,7 +2523,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
          Init_context_preview(&preview_context, Selector_filename, Selector->Directory);
 | 
					          Init_context_preview(&preview_context, Selector_filename, Selector->Directory);
 | 
				
			||||||
          preview_context.Format = Selector->Format_filter;
 | 
					          preview_context.Format = Selector->Format_filter;
 | 
				
			||||||
          preview_context.File_name_unicode = Selector_filename_unicode;
 | 
					          preview_context.File_name_unicode = Unicode_strdup(Selector_filename_unicode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Hide_cursor();
 | 
					        Hide_cursor();
 | 
				
			||||||
        if (context->Type == CONTEXT_PALETTE)
 | 
					        if (context->Type == CONTEXT_PALETTE)
 | 
				
			||||||
@ -2536,18 +2543,20 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (has_clicked_ok)
 | 
					  if (has_clicked_ok)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    free(context->File_name);
 | 
				
			||||||
 | 
					    free(context->File_name_unicode);
 | 
				
			||||||
    if (load_from_clipboard)
 | 
					    if (load_from_clipboard)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      strcpy(context->File_name, "CLIPBOARD.GIF");
 | 
					      context->File_name = strdup("CLIPBOARD.GIF");
 | 
				
			||||||
      context->File_name_unicode[0] = 0;
 | 
					      context->File_name_unicode = NULL;
 | 
				
			||||||
      context->Format = FORMAT_CLIPBOARD;
 | 
					      context->Format = FORMAT_CLIPBOARD;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      strcpy(context->File_name, Selector_filename);
 | 
					      context->File_name = strdup(Selector_filename);
 | 
				
			||||||
      if (context->File_name_unicode)
 | 
					      context->File_name_unicode = Unicode_strdup(Selector_filename_unicode);
 | 
				
			||||||
        Unicode_strlcpy(context->File_name_unicode, Selector_filename_unicode, MAX_PATH_CHARACTERS);
 | 
					      free(context->File_directory);
 | 
				
			||||||
      strcpy(context->File_directory, Selector->Directory);
 | 
					      context->File_directory = strdup(Selector->Directory);
 | 
				
			||||||
      if (!load)
 | 
					      if (!load)
 | 
				
			||||||
        context->Format = Selector->Format_filter;
 | 
					        context->Format = Selector->Format_filter;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										73
									
								
								src/io.c
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								src/io.c
									
									
									
									
									
								
							@ -321,26 +321,52 @@ char * Filepath_append_to_dir(const char * dir, const char * filename)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Récupère la partie "nom de file seul" d'un chemin
 | 
					// Récupère la partie "nom de file seul" d'un chemin
 | 
				
			||||||
void Extract_filename(char *dest, const char *source)
 | 
					char * Extract_filename(char *dest, const char *source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const char * position = Find_last_separator(source);
 | 
					  const char * position = Find_last_separator(source);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (dest != NULL)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
    if (position)
 | 
					    if (position)
 | 
				
			||||||
      strcpy(dest,position+1);
 | 
					      strcpy(dest,position+1);
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      strcpy(dest,source);
 | 
					      strcpy(dest,source);
 | 
				
			||||||
}
 | 
					    return dest;
 | 
				
			||||||
// Récupère la partie "répertoire+/" d'un chemin.
 | 
					  }
 | 
				
			||||||
void Extract_path(char *dest, const char *source)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  char * position=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Realpath(source,dest);
 | 
					 | 
				
			||||||
  position = Find_last_separator(dest);
 | 
					 | 
				
			||||||
  if (position)
 | 
					 | 
				
			||||||
    *(position+1) = '\0';
 | 
					 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (position)
 | 
				
			||||||
 | 
					      return strdup(position + 1);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      return strdup(source);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Récupère la partie "répertoire+/" d'un chemin.
 | 
				
			||||||
 | 
					char * Extract_path(char *dest, const char *source)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  char * position;
 | 
				
			||||||
 | 
					  char * path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  path = Realpath(source, dest);
 | 
				
			||||||
 | 
					  position = Find_last_separator(path);
 | 
				
			||||||
 | 
					  if (position)
 | 
				
			||||||
 | 
					    position[1] = '\0';
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (dest != NULL)
 | 
				
			||||||
      strcat(dest, PATH_SEPARATOR);
 | 
					      strcat(dest, PATH_SEPARATOR);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      char * tmp = realloc(path, strlen(path) + strlen(PATH_SEPARATOR) + 1);
 | 
				
			||||||
 | 
					      if (tmp != NULL)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        path = tmp;
 | 
				
			||||||
 | 
					        strcat(path, PATH_SEPARATOR);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@ -899,9 +925,10 @@ void Release_lock_file(const char *file_directory)
 | 
				
			|||||||
  lock_filename = Filepath_append_to_dir(file_directory, GFX2_LOCK_FILENAME);
 | 
					  lock_filename = Filepath_append_to_dir(file_directory, GFX2_LOCK_FILENAME);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  Remove_path(lock_filename);
 | 
					  Remove_path(lock_filename);
 | 
				
			||||||
 | 
					  free(lock_filename);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char * Get_current_directory(char * buf, word * buf_unicode, size_t size)
 | 
					char * Get_current_directory(char * buf, word * * unicode, size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#if defined(__MINT__)
 | 
					#if defined(__MINT__)
 | 
				
			||||||
  if (buf == NULL)
 | 
					  if (buf == NULL)
 | 
				
			||||||
@ -912,8 +939,8 @@ char * Get_current_directory(char * buf, word * buf_unicode, size_t size)
 | 
				
			|||||||
  Dgetpath(buf+3,0);
 | 
					  Dgetpath(buf+3,0);
 | 
				
			||||||
  strcat(buf,PATH_SEPARATOR);
 | 
					  strcat(buf,PATH_SEPARATOR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (buf_unicode != NULL)
 | 
					  if (unicode != NULL)
 | 
				
			||||||
    buf_unicode[0] = 0; // no unicode support
 | 
					    *unicode = NULL; // no unicode support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return buf;
 | 
					  return buf;
 | 
				
			||||||
#elif defined(WIN32)
 | 
					#elif defined(WIN32)
 | 
				
			||||||
@ -948,25 +975,29 @@ char * Get_current_directory(char * buf, word * buf_unicode, size_t size)
 | 
				
			|||||||
  if (ret == NULL)
 | 
					  if (ret == NULL)
 | 
				
			||||||
    GFX2_Log(GFX2_ERROR, "getcwd(%p, %lu) failed !\n", buf, (unsigned long)size);
 | 
					    GFX2_Log(GFX2_ERROR, "getcwd(%p, %lu) failed !\n", buf, (unsigned long)size);
 | 
				
			||||||
#ifdef ENABLE_FILENAMES_ICONV
 | 
					#ifdef ENABLE_FILENAMES_ICONV
 | 
				
			||||||
  if (ret != NULL && buf_unicode != NULL)
 | 
					  if (ret != NULL && unicode != NULL)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    char * input = buf;
 | 
					    char * input = ret;
 | 
				
			||||||
    size_t inbytesleft = strlen(buf);
 | 
					    size_t inbytesleft = strlen(ret);
 | 
				
			||||||
 | 
					    word * buf_unicode = malloc((inbytesleft + 1) * 2);
 | 
				
			||||||
    char * output = (char *)buf_unicode;
 | 
					    char * output = (char *)buf_unicode;
 | 
				
			||||||
    size_t outbytesleft = 2 * (size - 1);
 | 
					    size_t outbytesleft = 2 * inbytesleft;
 | 
				
			||||||
    if (cd_utf16 != (iconv_t)-1)
 | 
					    if (cd_utf16 != (iconv_t)-1 && buf_unicode != NULL)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      size_t r = iconv(cd_utf16, &input, &inbytesleft, &output, &outbytesleft);
 | 
					      size_t r = iconv(cd_utf16, &input, &inbytesleft, &output, &outbytesleft);
 | 
				
			||||||
      if (r != (size_t)-1)
 | 
					      if (r != (size_t)-1)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        output[0] = '\0';
 | 
					        output[0] = '\0';
 | 
				
			||||||
        output[1] = '\0';
 | 
					        output[1] = '\0';
 | 
				
			||||||
 | 
					        *unicode = buf_unicode;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        free(buf_unicode);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  if (buf_unicode != NULL)
 | 
					  if (unicode != NULL)
 | 
				
			||||||
    buf_unicode[0] = 0; // no unicode support
 | 
					    *unicode = NULL; // no unicode support
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								src/io.h
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								src/io.h
									
									
									
									
									
								
							@ -93,9 +93,9 @@ unsigned long File_length_file(FILE * file);
 | 
				
			|||||||
/// Construct full file path
 | 
					/// Construct full file path
 | 
				
			||||||
char * Filepath_append_to_dir(const char * dir, const char * filename);
 | 
					char * Filepath_append_to_dir(const char * dir, const char * filename);
 | 
				
			||||||
/// Extracts the filename part from a full file name.
 | 
					/// Extracts the filename part from a full file name.
 | 
				
			||||||
void Extract_filename(char *dest, const char *source);
 | 
					char * Extract_filename(char *dest, const char *source);
 | 
				
			||||||
/// Extracts the directory from a full file name.
 | 
					/// Extracts the directory from a full file name.
 | 
				
			||||||
void Extract_path(char *dest, const char *source);
 | 
					char * Extract_path(char *dest, const char *source);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Finds the rightmost path separator in a full filename. Used to separate directory from file.
 | 
					/// Finds the rightmost path separator in a full filename. Used to separate directory from file.
 | 
				
			||||||
char * Find_last_separator(const char * str);
 | 
					char * Find_last_separator(const char * str);
 | 
				
			||||||
@ -180,10 +180,10 @@ void Release_lock_file(const char *file_directory);
 | 
				
			|||||||
///
 | 
					///
 | 
				
			||||||
/// Return the current directory, equivalent to getcwd()
 | 
					/// Return the current directory, equivalent to getcwd()
 | 
				
			||||||
/// @param buf destination buffer. can be NULL
 | 
					/// @param buf destination buffer. can be NULL
 | 
				
			||||||
/// @param buf_unicode destination buffer for the unicode version of the path
 | 
					/// @param unicode destination pointer for the unicode version of the path
 | 
				
			||||||
/// @param size destination buffer size, ignored if buf is NULL
 | 
					/// @param size destination buffer size, ignored if buf is NULL
 | 
				
			||||||
/// @return NULL for error, buf or a malloc'ed buffer
 | 
					/// @return NULL for error, buf or a malloc'ed buffer
 | 
				
			||||||
char * Get_current_directory(char * buf, word * buf_unicode, size_t size);
 | 
					char * Get_current_directory(char * buf, word ** unicode, size_t size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// Change current directory. return 0 for success, -1 in case of error
 | 
					/// Change current directory. return 0 for success, -1 in case of error
 | 
				
			||||||
 | 
				
			|||||||
@ -823,21 +823,22 @@ void Load_image(T_IO_Context *context)
 | 
				
			|||||||
      // Transfer the data to main image.
 | 
					      // Transfer the data to main image.
 | 
				
			||||||
      if (!format->Palette_only)
 | 
					      if (!format->Palette_only)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 | 
					        free(Main.backups->Pages->Filename);
 | 
				
			||||||
 | 
					        free(Main.backups->Pages->File_directory);
 | 
				
			||||||
 | 
					        free(Main.backups->Pages->Filename_unicode);
 | 
				
			||||||
 | 
					        Main.backups->Pages->Filename_unicode = NULL;
 | 
				
			||||||
        if (context->Original_file_name && context->Original_file_name[0]
 | 
					        if (context->Original_file_name && context->Original_file_name[0]
 | 
				
			||||||
          && context->Original_file_directory && context->Original_file_directory[0])
 | 
					          && context->Original_file_directory && context->Original_file_directory[0])
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          strcpy(Main.backups->Pages->Filename,context->Original_file_name);
 | 
					          Main.backups->Pages->Filename = strdup(context->Original_file_name);  /// @todo steal buffer !
 | 
				
			||||||
          strcpy(Main.backups->Pages->File_directory,context->Original_file_directory);
 | 
					          Main.backups->Pages->File_directory = strdup(context->Original_file_directory);
 | 
				
			||||||
          Main.backups->Pages->Filename_unicode[0] = 0;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          strcpy(Main.backups->Pages->Filename,context->File_name);
 | 
					          Main.backups->Pages->Filename = strdup(context->File_name);
 | 
				
			||||||
          strcpy(Main.backups->Pages->File_directory,context->File_directory);
 | 
					          Main.backups->Pages->File_directory = strdup(context->File_directory);
 | 
				
			||||||
          if (context->File_name_unicode)
 | 
					          if (context->File_name_unicode)
 | 
				
			||||||
            Unicode_strlcpy(Main.backups->Pages->Filename_unicode, context->File_name_unicode, MAX_PATH_CHARACTERS);
 | 
					            Main.backups->Pages->Filename_unicode = Unicode_strdup(context->File_name_unicode);
 | 
				
			||||||
          else
 | 
					 | 
				
			||||||
            Main.backups->Pages->Filename_unicode[0] = 0;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // On considère que l'image chargée n'est plus modifiée
 | 
					        // On considère que l'image chargée n'est plus modifiée
 | 
				
			||||||
@ -1732,6 +1733,9 @@ void Destroy_context(T_IO_Context *context)
 | 
				
			|||||||
  free(context->Buffer_image_24b);
 | 
					  free(context->Buffer_image_24b);
 | 
				
			||||||
  free(context->Buffer_image);
 | 
					  free(context->Buffer_image);
 | 
				
			||||||
  free(context->Preview_bitmap);
 | 
					  free(context->Preview_bitmap);
 | 
				
			||||||
 | 
					  free(context->File_name);
 | 
				
			||||||
 | 
					  free(context->File_name_unicode);
 | 
				
			||||||
 | 
					  free(context->File_directory);
 | 
				
			||||||
  memset(context, 0, sizeof(T_IO_Context));
 | 
					  memset(context, 0, sizeof(T_IO_Context));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1741,8 +1745,8 @@ void Init_context_preview(T_IO_Context * context, char *file_name, char *file_di
 | 
				
			|||||||
  memset(context, 0, sizeof(T_IO_Context));
 | 
					  memset(context, 0, sizeof(T_IO_Context));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  context->Type = CONTEXT_PREVIEW;
 | 
					  context->Type = CONTEXT_PREVIEW;
 | 
				
			||||||
  context->File_name = file_name;
 | 
					  context->File_name = file_name != NULL ? strdup(file_name) : NULL;
 | 
				
			||||||
  context->File_directory = file_directory;
 | 
					  context->File_directory = file_directory != NULL ? strdup(file_directory) : NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Setup for loading/saving an intermediate backup
 | 
					// Setup for loading/saving an intermediate backup
 | 
				
			||||||
@ -1759,8 +1763,8 @@ void Init_context_layered_image(T_IO_Context * context, char *file_name, char *f
 | 
				
			|||||||
  memset(context, 0, sizeof(T_IO_Context));
 | 
					  memset(context, 0, sizeof(T_IO_Context));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  context->Type = CONTEXT_MAIN_IMAGE;
 | 
					  context->Type = CONTEXT_MAIN_IMAGE;
 | 
				
			||||||
  context->File_name = file_name;
 | 
					  context->File_name = file_name != NULL ? strdup(file_name) : NULL;
 | 
				
			||||||
  context->File_directory = file_directory;
 | 
					  context->File_directory = file_directory != NULL ? strdup(file_directory) : NULL;
 | 
				
			||||||
  context->Format = Main.fileformat;
 | 
					  context->Format = Main.fileformat;
 | 
				
			||||||
  memcpy(context->Palette, Main.palette, sizeof(T_Palette));
 | 
					  memcpy(context->Palette, Main.palette, sizeof(T_Palette));
 | 
				
			||||||
  context->Width = Main.image_width;
 | 
					  context->Width = Main.image_width;
 | 
				
			||||||
@ -1799,8 +1803,8 @@ void Init_context_brush(T_IO_Context * context, char *file_name, char *file_dire
 | 
				
			|||||||
  memset(context, 0, sizeof(T_IO_Context));
 | 
					  memset(context, 0, sizeof(T_IO_Context));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  context->Type = CONTEXT_BRUSH;
 | 
					  context->Type = CONTEXT_BRUSH;
 | 
				
			||||||
  context->File_name = file_name;
 | 
					  context->File_name = file_name != NULL ? strdup(file_name) : NULL;
 | 
				
			||||||
  context->File_directory = file_directory;
 | 
					  context->File_directory = file_directory != NULL ? strdup(file_directory) : NULL;
 | 
				
			||||||
  context->Format = Brush_fileformat;
 | 
					  context->Format = Brush_fileformat;
 | 
				
			||||||
  // Use main screen's palette
 | 
					  // Use main screen's palette
 | 
				
			||||||
  memcpy(context->Palette, Main.palette, sizeof(T_Palette));
 | 
					  memcpy(context->Palette, Main.palette, sizeof(T_Palette));
 | 
				
			||||||
@ -1821,8 +1825,8 @@ void Init_context_surface(T_IO_Context * context, char *file_name, char *file_di
 | 
				
			|||||||
  memset(context, 0, sizeof(T_IO_Context));
 | 
					  memset(context, 0, sizeof(T_IO_Context));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  context->Type = CONTEXT_SURFACE;
 | 
					  context->Type = CONTEXT_SURFACE;
 | 
				
			||||||
  context->File_name = file_name;
 | 
					  context->File_name = file_name != NULL ? strdup(file_name) : NULL;
 | 
				
			||||||
  context->File_directory = file_directory;
 | 
					  context->File_directory = file_directory != NULL ? strdup(file_directory) : NULL;
 | 
				
			||||||
  context->Format = DEFAULT_FILEFORMAT;
 | 
					  context->Format = DEFAULT_FILEFORMAT;
 | 
				
			||||||
  // context->Palette
 | 
					  // context->Palette
 | 
				
			||||||
  // context->Width
 | 
					  // context->Width
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/main.c
									
									
									
									
									
								
							@ -123,9 +123,11 @@
 | 
				
			|||||||
#include "brush.h"
 | 
					#include "brush.h"
 | 
				
			||||||
#include "palette.h"
 | 
					#include "palette.h"
 | 
				
			||||||
#include "realpath.h"
 | 
					#include "realpath.h"
 | 
				
			||||||
 | 
					#include "unicode.h"
 | 
				
			||||||
#include "input.h"
 | 
					#include "input.h"
 | 
				
			||||||
#include "help.h"
 | 
					#include "help.h"
 | 
				
			||||||
#include "filesel.h"
 | 
					#include "filesel.h"
 | 
				
			||||||
 | 
					#include "factory.h"
 | 
				
			||||||
#if defined(WIN32) && !(defined(USE_SDL) || defined(USE_SDL2))
 | 
					#if defined(WIN32) && !(defined(USE_SDL) || defined(USE_SDL2))
 | 
				
			||||||
#include "win32screen.h"
 | 
					#include "win32screen.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -619,7 +621,6 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  T_Gradient_array initial_gradients;
 | 
					  T_Gradient_array initial_gradients;
 | 
				
			||||||
  char * filenames[2] = {NULL, NULL};
 | 
					  char * filenames[2] = {NULL, NULL};
 | 
				
			||||||
  char * directories[2] = {NULL, NULL};
 | 
					  char * directories[2] = {NULL, NULL};
 | 
				
			||||||
  word * filename_unicode;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if defined(__MINT__)
 | 
					  #if defined(__MINT__)
 | 
				
			||||||
  printf("===============================\n");
 | 
					  printf("===============================\n");
 | 
				
			||||||
@ -658,7 +659,7 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  // Choose directory for settings (read/write)
 | 
					  // Choose directory for settings (read/write)
 | 
				
			||||||
  Config_directory = Get_config_directory(program_directory);
 | 
					  Config_directory = Get_config_directory(program_directory);
 | 
				
			||||||
  // Get current directory
 | 
					  // Get current directory
 | 
				
			||||||
  Get_current_directory(Main.selector.Directory,Main.selector.Directory_unicode,MAX_PATH_CHARACTERS);
 | 
					  Main.selector.Directory = Get_current_directory(NULL, &Main.selector.Directory_unicode, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  free(program_directory);
 | 
					  free(program_directory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -666,18 +667,21 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  Initial_directory = strdup(Main.selector.Directory);
 | 
					  Initial_directory = strdup(Main.selector.Directory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On initialise les données sur le nom de fichier de l'image de brouillon:
 | 
					  // On initialise les données sur le nom de fichier de l'image de brouillon:
 | 
				
			||||||
  strcpy(Spare.selector.Directory,Main.selector.Directory);
 | 
					  Spare.selector.Directory = strdup(Main.selector.Directory);
 | 
				
			||||||
 | 
					  Spare.selector.Directory_unicode = Unicode_strdup(Main.selector.Directory_unicode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Main.fileformat=DEFAULT_FILEFORMAT;
 | 
					  Main.fileformat  = DEFAULT_FILEFORMAT;
 | 
				
			||||||
  Spare.fileformat    =DEFAULT_FILEFORMAT;
 | 
					  Spare.fileformat = DEFAULT_FILEFORMAT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  strcpy(Brush_selector.Directory, Main.selector.Directory);
 | 
					  Brush_selector.Directory = strdup(Main.selector.Directory);
 | 
				
			||||||
 | 
					  Brush_selector.Directory_unicode = Unicode_strdup(Main.selector.Directory_unicode);
 | 
				
			||||||
  Brush_file_directory = strdup(Main.selector.Directory);
 | 
					  Brush_file_directory = strdup(Main.selector.Directory);
 | 
				
			||||||
  Brush_filename = strdup("NO_NAME.GIF");
 | 
					  Brush_filename = strdup("NO_NAME.GIF");
 | 
				
			||||||
  Brush_filename_unicode = NULL;
 | 
					  Brush_filename_unicode = NULL;
 | 
				
			||||||
  Brush_fileformat = DEFAULT_FILEFORMAT;
 | 
					  Brush_fileformat = DEFAULT_FILEFORMAT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  strcpy(Palette_selector.Directory,Main.selector.Directory);
 | 
					  Palette_selector.Directory = strdup(Main.selector.Directory);
 | 
				
			||||||
 | 
					  Palette_selector.Directory_unicode = Unicode_strdup(Main.selector.Directory_unicode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On initialise ce qu'il faut pour que les fileselects ne plantent pas:
 | 
					  // On initialise ce qu'il faut pour que les fileselects ne plantent pas:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1134,11 +1138,9 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
        case 2:
 | 
					        case 2:
 | 
				
			||||||
          // Load this file
 | 
					          // Load this file
 | 
				
			||||||
          Init_context_layered_image(&context, filenames[1], directories[1]);
 | 
					          Init_context_layered_image(&context, filenames[1], directories[1]);
 | 
				
			||||||
          filename_unicode = Get_Unicode_Filename(NULL, filenames[1], directories[1]);
 | 
					          context.File_name_unicode = Get_Unicode_Filename(NULL, filenames[1], directories[1]);
 | 
				
			||||||
          context.File_name_unicode = filename_unicode;
 | 
					 | 
				
			||||||
          Load_image(&context);
 | 
					          Load_image(&context);
 | 
				
			||||||
          Destroy_context(&context);
 | 
					          Destroy_context(&context);
 | 
				
			||||||
          free(filename_unicode);
 | 
					 | 
				
			||||||
          Redraw_layered_image();
 | 
					          Redraw_layered_image();
 | 
				
			||||||
          End_of_modification();
 | 
					          End_of_modification();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1149,11 +1151,9 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
        case 1:
 | 
					        case 1:
 | 
				
			||||||
          Init_context_layered_image(&context, filenames[0], directories[0]);
 | 
					          Init_context_layered_image(&context, filenames[0], directories[0]);
 | 
				
			||||||
          filename_unicode = Get_Unicode_Filename(NULL, filenames[0], directories[0]);
 | 
					          context.File_name_unicode = Get_Unicode_Filename(NULL, filenames[0], directories[0]);
 | 
				
			||||||
          context.File_name_unicode = filename_unicode;
 | 
					 | 
				
			||||||
          Load_image(&context);
 | 
					          Load_image(&context);
 | 
				
			||||||
          Destroy_context(&context);
 | 
					          Destroy_context(&context);
 | 
				
			||||||
          free(filename_unicode);
 | 
					 | 
				
			||||||
          Redraw_layered_image();
 | 
					          Redraw_layered_image();
 | 
				
			||||||
          End_of_modification();
 | 
					          End_of_modification();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1291,6 +1291,15 @@ void Program_shutdown(void)
 | 
				
			|||||||
  FREE_POINTER(Config_directory);
 | 
					  FREE_POINTER(Config_directory);
 | 
				
			||||||
  FREE_POINTER(Data_directory);
 | 
					  FREE_POINTER(Data_directory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  FREE_POINTER(Main.selector.Directory);
 | 
				
			||||||
 | 
					  FREE_POINTER(Main.selector.Directory_unicode);
 | 
				
			||||||
 | 
					  FREE_POINTER(Spare.selector.Directory);
 | 
				
			||||||
 | 
					  FREE_POINTER(Spare.selector.Directory_unicode);
 | 
				
			||||||
 | 
					  FREE_POINTER(Brush_selector.Directory);
 | 
				
			||||||
 | 
					  FREE_POINTER(Brush_selector.Directory_unicode);
 | 
				
			||||||
 | 
					  FREE_POINTER(Palette_selector.Directory);
 | 
				
			||||||
 | 
					  FREE_POINTER(Palette_selector.Directory_unicode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Free Config
 | 
					  // Free Config
 | 
				
			||||||
  FREE_POINTER(Config.Skin_file);
 | 
					  FREE_POINTER(Config.Skin_file);
 | 
				
			||||||
  FREE_POINTER(Config.Font_file);
 | 
					  FREE_POINTER(Config.Font_file);
 | 
				
			||||||
@ -1300,6 +1309,11 @@ void Program_shutdown(void)
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  FREE_POINTER(Config.Scripts_directory);
 | 
					  FREE_POINTER(Config.Scripts_directory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0; i < 10; i++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    FREE_POINTER(Bound_script[i]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Uninit_text();
 | 
					  Uninit_text();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ENABLE_FILENAMES_ICONV
 | 
					#ifdef ENABLE_FILENAMES_ICONV
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										82
									
								
								src/pages.c
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								src/pages.c
									
									
									
									
									
								
							@ -36,6 +36,7 @@
 | 
				
			|||||||
#include "tiles.h"
 | 
					#include "tiles.h"
 | 
				
			||||||
#include "graph.h"
 | 
					#include "graph.h"
 | 
				
			||||||
#include "layers.h"
 | 
					#include "layers.h"
 | 
				
			||||||
 | 
					#include "unicode.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// -- Layers data
 | 
					// -- Layers data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,22 +69,22 @@ T_Page * New_page(int nb_layers)
 | 
				
			|||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
    for (i=0; i<nb_layers; i++)
 | 
					    for (i=0; i<nb_layers; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      page->Image[i].Pixels=NULL;
 | 
					      page->Image[i].Pixels = NULL;
 | 
				
			||||||
      page->Image[i].Duration=100;
 | 
					      page->Image[i].Duration = 100;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    page->Width=0;
 | 
					    page->Width=0;
 | 
				
			||||||
    page->Height=0;
 | 
					    page->Height=0;
 | 
				
			||||||
    page->Image_mode = IMAGE_MODE_LAYERED;
 | 
					    page->Image_mode = IMAGE_MODE_LAYERED;
 | 
				
			||||||
    memset(page->Palette,0,sizeof(T_Palette));
 | 
					    memset(page->Palette, 0, sizeof(T_Palette));
 | 
				
			||||||
    page->Comment[0]='\0';
 | 
					    page->Comment[0] = '\0';
 | 
				
			||||||
    page->File_directory[0]='\0';
 | 
					    page->File_directory = NULL;
 | 
				
			||||||
    page->Filename[0]='\0';
 | 
					    page->Filename = NULL;
 | 
				
			||||||
    page->Filename_unicode[0]=0;
 | 
					    page->Filename_unicode = NULL;
 | 
				
			||||||
    page->File_format=DEFAULT_FILEFORMAT;
 | 
					    page->File_format = DEFAULT_FILEFORMAT;
 | 
				
			||||||
    page->Nb_layers=nb_layers;
 | 
					    page->Nb_layers = nb_layers;
 | 
				
			||||||
    page->Gradients=NULL;
 | 
					    page->Gradients = NULL;
 | 
				
			||||||
    page->Transparent_color=0; // Default transparent color
 | 
					    page->Transparent_color = 0; // Default transparent color
 | 
				
			||||||
    page->Background_transparent=0;
 | 
					    page->Background_transparent = 0;
 | 
				
			||||||
    page->Next = page->Prev = NULL;
 | 
					    page->Next = page->Prev = NULL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return page;
 | 
					  return page;
 | 
				
			||||||
@ -454,10 +455,16 @@ void Clear_page(T_Page * page)
 | 
				
			|||||||
  // On ne se préoccupe pas de ce que deviens le reste des infos de l'image.
 | 
					  // On ne se préoccupe pas de ce que deviens le reste des infos de l'image.
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Copy_S_page(T_Page * dest,T_Page * source)
 | 
					void Copy_S_page(T_Page * dest, T_Page * source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  *dest=*source;
 | 
					  *dest = *source;
 | 
				
			||||||
  dest->Gradients=NULL;
 | 
					  dest->Gradients = Dup_gradient(source);
 | 
				
			||||||
 | 
					  if (source->File_directory != NULL)
 | 
				
			||||||
 | 
					    dest->File_directory = strdup(source->File_directory);
 | 
				
			||||||
 | 
					  if (source->Filename != NULL)
 | 
				
			||||||
 | 
					    dest->Filename = strdup(source->Filename);
 | 
				
			||||||
 | 
					  if (source->Filename_unicode != NULL)
 | 
				
			||||||
 | 
					    dest->Filename_unicode = Unicode_strdup(source->Filename_unicode);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -492,7 +499,7 @@ int Allocate_list_of_pages(T_List_of_pages * list)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  list->List_size=1;
 | 
					  list->List_size=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  page->Gradients=Dup_gradient(NULL);
 | 
					  page->Gradients = Dup_gradient(NULL);
 | 
				
			||||||
  if (!page->Gradients)
 | 
					  if (!page->Gradients)
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -592,6 +599,9 @@ void Free_last_page_of_list(T_List_of_pages * list)
 | 
				
			|||||||
        page->Next->Prev = page->Prev;
 | 
					        page->Next->Prev = page->Prev;
 | 
				
			||||||
        page->Prev->Next = page->Next;
 | 
					        page->Prev->Next = page->Next;
 | 
				
			||||||
        Clear_page(page);
 | 
					        Clear_page(page);
 | 
				
			||||||
 | 
					        free(page->File_directory);
 | 
				
			||||||
 | 
					        free(page->Filename);
 | 
				
			||||||
 | 
					        free(page->Filename_unicode);
 | 
				
			||||||
        free(page);
 | 
					        free(page);
 | 
				
			||||||
        page = NULL;
 | 
					        page = NULL;
 | 
				
			||||||
        list->List_size--;
 | 
					        list->List_size--;
 | 
				
			||||||
@ -773,11 +783,11 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height)
 | 
				
			|||||||
  // On crée un descripteur de page correspondant à la page principale
 | 
					  // On crée un descripteur de page correspondant à la page principale
 | 
				
			||||||
  Upload_infos_page(&Main);
 | 
					  Upload_infos_page(&Main);
 | 
				
			||||||
  // On y met les infos sur la dimension de démarrage
 | 
					  // On y met les infos sur la dimension de démarrage
 | 
				
			||||||
  Main.backups->Pages->Width=width;
 | 
					  Main.backups->Pages->Width = width;
 | 
				
			||||||
  Main.backups->Pages->Height=height;
 | 
					  Main.backups->Pages->Height = height;
 | 
				
			||||||
  strcpy(Main.backups->Pages->File_directory,Main.selector.Directory);
 | 
					  Main.backups->Pages->File_directory = strdup(Main.selector.Directory);
 | 
				
			||||||
  strcpy(Main.backups->Pages->Filename,"NO_NAME.GIF");
 | 
					  Main.backups->Pages->Filename = strdup("NO_NAME.GIF");
 | 
				
			||||||
  Main.backups->Pages->Filename_unicode[0] = 0;
 | 
					  Main.backups->Pages->Filename_unicode = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (i=0; i<Main.backups->Pages->Nb_layers; i++)
 | 
					  for (i=0; i<Main.backups->Pages->Nb_layers; i++)
 | 
				
			||||||
@ -821,9 +831,9 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height)
 | 
				
			|||||||
  Spare.backups->Pages->Height = height;
 | 
					  Spare.backups->Pages->Height = height;
 | 
				
			||||||
  memcpy(Spare.backups->Pages->Palette,Main.palette,sizeof(T_Palette));
 | 
					  memcpy(Spare.backups->Pages->Palette,Main.palette,sizeof(T_Palette));
 | 
				
			||||||
  strcpy(Spare.backups->Pages->Comment,"");
 | 
					  strcpy(Spare.backups->Pages->Comment,"");
 | 
				
			||||||
  strcpy(Spare.backups->Pages->File_directory,Main.selector.Directory);
 | 
					  Spare.backups->Pages->File_directory = strdup(Main.selector.Directory);
 | 
				
			||||||
  strcpy(Spare.backups->Pages->Filename,"NO_NAME2.GIF");
 | 
					  Spare.backups->Pages->Filename = strdup("NO_NAME2.GIF");
 | 
				
			||||||
  Spare.backups->Pages->Filename_unicode[0] = 0;
 | 
					  Spare.backups->Pages->Filename_unicode = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Spare.backups->Pages->File_format=DEFAULT_FILEFORMAT;
 | 
					  Spare.backups->Pages->File_format=DEFAULT_FILEFORMAT;
 | 
				
			||||||
  // Copy this informations in the global Spare_ variables
 | 
					  // Copy this informations in the global Spare_ variables
 | 
				
			||||||
@ -872,7 +882,7 @@ int Backup_new_image(int layers,int width,int height)
 | 
				
			|||||||
  new_page->Width=width;
 | 
					  new_page->Width=width;
 | 
				
			||||||
  new_page->Height=height;
 | 
					  new_page->Height=height;
 | 
				
			||||||
  new_page->Transparent_color=0;
 | 
					  new_page->Transparent_color=0;
 | 
				
			||||||
  new_page->Gradients=Dup_gradient(NULL);
 | 
					  new_page->Gradients = Dup_gradient(NULL);
 | 
				
			||||||
  if (!Create_new_page(new_page,Main.backups,LAYER_ALL))
 | 
					  if (!Create_new_page(new_page,Main.backups,LAYER_ALL))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    Error(0);
 | 
					    Error(0);
 | 
				
			||||||
@ -913,15 +923,16 @@ int Backup_with_new_dimensions(int width,int height)
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Copy data from previous history step
 | 
					  // Copy data from previous history step
 | 
				
			||||||
  memcpy(Main.backups->Pages->Palette,Main.backups->Pages->Next->Palette,sizeof(T_Palette));
 | 
					  memcpy(Main.backups->Pages->Palette, Main.backups->Pages->Next->Palette, sizeof(T_Palette));
 | 
				
			||||||
  strcpy(Main.backups->Pages->Comment,Main.backups->Pages->Next->Comment);
 | 
					  strcpy(Main.backups->Pages->Comment ,Main.backups->Pages->Next->Comment);
 | 
				
			||||||
  Main.backups->Pages->File_format=Main.backups->Pages->Next->File_format;
 | 
					  Main.backups->Pages->File_format = Main.backups->Pages->Next->File_format;
 | 
				
			||||||
  strcpy(Main.backups->Pages->Filename, Main.backups->Pages->Next->Filename);
 | 
					  Main.backups->Pages->Filename = strdup(Main.backups->Pages->Next->Filename);
 | 
				
			||||||
  strcpy(Main.backups->Pages->File_directory, Main.backups->Pages->Next->File_directory);
 | 
					  Main.backups->Pages->Filename_unicode = Unicode_strdup(Main.backups->Pages->Next->Filename_unicode);
 | 
				
			||||||
  Main.backups->Pages->Gradients=Dup_gradient(Main.backups->Pages->Next);
 | 
					  Main.backups->Pages->File_directory = strdup(Main.backups->Pages->Next->File_directory);
 | 
				
			||||||
  Main.backups->Pages->Background_transparent=Main.backups->Pages->Next->Background_transparent;
 | 
					  Main.backups->Pages->Gradients = Dup_gradient(Main.backups->Pages->Next);
 | 
				
			||||||
  Main.backups->Pages->Transparent_color=Main.backups->Pages->Next->Transparent_color;
 | 
					  Main.backups->Pages->Background_transparent = Main.backups->Pages->Next->Background_transparent;
 | 
				
			||||||
  Main.backups->Pages->Image_mode=Main.backups->Pages->Next->Image_mode;
 | 
					  Main.backups->Pages->Transparent_color = Main.backups->Pages->Next->Transparent_color;
 | 
				
			||||||
 | 
					  Main.backups->Pages->Image_mode = Main.backups->Pages->Next->Image_mode;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Fill with transparent color
 | 
					  // Fill with transparent color
 | 
				
			||||||
  for (i=0; i<Main.backups->Pages->Nb_layers;i++)
 | 
					  for (i=0; i<Main.backups->Pages->Nb_layers;i++)
 | 
				
			||||||
@ -1052,7 +1063,6 @@ int Backup_and_resize_the_spare(int width,int height)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  // Fill it with a copy of the latest history
 | 
					  // Fill it with a copy of the latest history
 | 
				
			||||||
  Copy_S_page(new_page,Spare.backups->Pages);
 | 
					  Copy_S_page(new_page,Spare.backups->Pages);
 | 
				
			||||||
  new_page->Gradients=Dup_gradient(Spare.backups->Pages);
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  new_page->Width=width;
 | 
					  new_page->Width=width;
 | 
				
			||||||
  new_page->Height=height;
 | 
					  new_page->Height=height;
 | 
				
			||||||
@ -1108,7 +1118,6 @@ void Backup_layers(int layer)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  // Fill it with a copy of the latest history
 | 
					  // Fill it with a copy of the latest history
 | 
				
			||||||
  Copy_S_page(new_page,Main.backups->Pages);
 | 
					  Copy_S_page(new_page,Main.backups->Pages);
 | 
				
			||||||
  new_page->Gradients=Dup_gradient(Main.backups->Pages);
 | 
					 | 
				
			||||||
  Create_new_page(new_page,Main.backups,layer);
 | 
					  Create_new_page(new_page,Main.backups,layer);
 | 
				
			||||||
  Download_infos_page_main(new_page);
 | 
					  Download_infos_page_main(new_page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1168,7 +1177,6 @@ void Backup_the_spare(int layer)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  // Fill it with a copy of the latest history
 | 
					  // Fill it with a copy of the latest history
 | 
				
			||||||
  Copy_S_page(new_page,Spare.backups->Pages);
 | 
					  Copy_S_page(new_page,Spare.backups->Pages);
 | 
				
			||||||
  new_page->Gradients=Dup_gradient(Spare.backups->Pages);
 | 
					 | 
				
			||||||
  Create_new_page(new_page,Spare.backups,layer);
 | 
					  Create_new_page(new_page,Spare.backups,layer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Copy the actual pixels from the backup to the latest page
 | 
					  // Copy the actual pixels from the backup to the latest page
 | 
				
			||||||
 | 
				
			|||||||
@ -64,13 +64,6 @@ int Dup_layer_if_shared(T_Page * page, int layer);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Upload_infos_page(T_Document * doc);
 | 
					void Upload_infos_page(T_Document * doc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// private
 | 
					 | 
				
			||||||
T_Page * New_page(int nb_layers);
 | 
					 | 
				
			||||||
void Download_infos_page_spare(T_Page * page);
 | 
					 | 
				
			||||||
void Clear_page(T_Page * page);
 | 
					 | 
				
			||||||
void Copy_S_page(T_Page * dest,T_Page * source);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// LISTS OF PAGES
 | 
					/// LISTS OF PAGES
 | 
				
			||||||
 | 
				
			|||||||
@ -116,20 +116,17 @@ char * Get_program_directory(const char * argv0)
 | 
				
			|||||||
    char path[PATH_MAX];
 | 
					    char path[PATH_MAX];
 | 
				
			||||||
    if (readlink("/proc/self/exe", path, sizeof(path)) >= 0)
 | 
					    if (readlink("/proc/self/exe", path, sizeof(path)) >= 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      program_dir = malloc(strlen(path) + 1);
 | 
					      program_dir = Extract_path(NULL, path);
 | 
				
			||||||
      Extract_path(program_dir, path);
 | 
					 | 
				
			||||||
      return program_dir;
 | 
					      return program_dir;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  program_dir = malloc(strlen(argv0) + 1);
 | 
					  program_dir = Extract_path(NULL, argv0);
 | 
				
			||||||
  Extract_path(program_dir, argv0);
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Others: The part of argv[0] before the executable name.    
 | 
					  // Others: The part of argv[0] before the executable name.    
 | 
				
			||||||
  // Keep the last \ or /.
 | 
					  // Keep the last \ or /.
 | 
				
			||||||
  // On Windows, Mingw32 already provides the full path in all cases.
 | 
					  // On Windows, Mingw32 already provides the full path in all cases.
 | 
				
			||||||
  #else
 | 
					  #else
 | 
				
			||||||
    program_dir = malloc(strlen(argv0) + 1);
 | 
					  program_dir = Extract_path(NULL, argv0);
 | 
				
			||||||
    Extract_path(program_dir, argv0);
 | 
					 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  return program_dir;
 | 
					  return program_dir;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/struct.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/struct.h
									
									
									
									
									
								
							@ -413,10 +413,10 @@ typedef struct T_Page
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  char      Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
 | 
					  char      Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  char      File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
 | 
					  char      * File_directory;     ///< Directory that contains the file.
 | 
				
			||||||
  char      Filename[MAX_PATH_CHARACTERS];      ///< Filename without directory.
 | 
					  char      * Filename;           ///< Filename without directory.
 | 
				
			||||||
  word      Filename_unicode[MAX_PATH_CHARACTERS]; ///< Filename without directory.
 | 
					  word      * Filename_unicode;   ///< Filename without directory.
 | 
				
			||||||
  byte      File_format;                        ///< File format, in enum ::FILE_FORMATS
 | 
					  enum FILE_FORMATS File_format;  ///< File format, in enum ::FILE_FORMATS
 | 
				
			||||||
  struct T_Page *Next; ///< Pointer to the next backup
 | 
					  struct T_Page *Next; ///< Pointer to the next backup
 | 
				
			||||||
  struct T_Page *Prev; ///< Pointer to the previous backup
 | 
					  struct T_Page *Prev; ///< Pointer to the previous backup
 | 
				
			||||||
  T_Gradient_array *Gradients; ///< Pointer to the gradients used by the image.
 | 
					  T_Gradient_array *Gradients; ///< Pointer to the gradients used by the image.
 | 
				
			||||||
@ -555,8 +555,8 @@ typedef struct T_Selector_settings
 | 
				
			|||||||
  byte Format_filter; ///< 0 for "*.*", or a value of enum ::FILE_FORMATS
 | 
					  byte Format_filter; ///< 0 for "*.*", or a value of enum ::FILE_FORMATS
 | 
				
			||||||
  short Position; ///< Index of the first file/entry to display in list
 | 
					  short Position; ///< Index of the first file/entry to display in list
 | 
				
			||||||
  short Offset; ///< Position of the "highlight" bar in the file list
 | 
					  short Offset; ///< Position of the "highlight" bar in the file list
 | 
				
			||||||
  char  Directory[MAX_PATH_CHARACTERS]; ///< Directory currently browsed
 | 
					  char  * Directory; ///< Directory currently browsed
 | 
				
			||||||
  word  Directory_unicode[MAX_PATH_CHARACTERS]; ///< Directory currently browsed
 | 
					  word  * Directory_unicode; ///< Directory currently browsed
 | 
				
			||||||
} T_Selector_settings;
 | 
					} T_Selector_settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// structure for Main or Spare page global data
 | 
					/// structure for Main or Spare page global data
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,8 @@ word * Unicode_strdup(const word * str)
 | 
				
			|||||||
  size_t byte_size;
 | 
					  size_t byte_size;
 | 
				
			||||||
  word * new_str;
 | 
					  word * new_str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (str == NULL)
 | 
				
			||||||
 | 
					    return NULL;
 | 
				
			||||||
  byte_size = Unicode_strlen(str) * 2 + 2;
 | 
					  byte_size = Unicode_strlen(str) * 2 + 2;
 | 
				
			||||||
  new_str = malloc(byte_size);
 | 
					  new_str = malloc(byte_size);
 | 
				
			||||||
  if (new_str != NULL)
 | 
					  if (new_str != NULL)
 | 
				
			||||||
 | 
				
			|||||||
@ -1103,7 +1103,7 @@ void Print_filename(void)
 | 
				
			|||||||
    Menu_status_Y,Menu_factor_X*max_size*8,Menu_factor_Y<<3,MC_Light);
 | 
					    Menu_status_Y,Menu_factor_X*max_size*8,Menu_factor_Y<<3,MC_Light);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Partial copy of the name
 | 
					  // Partial copy of the name
 | 
				
			||||||
  if (Main.backups->Pages->Filename_unicode[0] != 0)
 | 
					  if (Main.backups->Pages->Filename_unicode != NULL)
 | 
				
			||||||
    Unicode_strlcpy(display_string, Main.backups->Pages->Filename_unicode, 256);
 | 
					    Unicode_strlcpy(display_string, Main.backups->Pages->Filename_unicode, 256);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -1124,7 +1124,7 @@ void Print_filename(void)
 | 
				
			|||||||
  if (string_size > max_size)
 | 
					  if (string_size > max_size)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    // check if the begining of the Spare file name is the same
 | 
					    // check if the begining of the Spare file name is the same
 | 
				
			||||||
    if (Spare.backups->Pages->Filename_unicode[0] != 0
 | 
					    if (Spare.backups->Pages->Filename_unicode != NULL
 | 
				
			||||||
        && 0 == memcmp(display_string, Spare.backups->Pages->Filename_unicode, (max_size - 1) * sizeof(word)))
 | 
					        && 0 == memcmp(display_string, Spare.backups->Pages->Filename_unicode, (max_size - 1) * sizeof(word)))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      // display : "...end_of_filename.ext"
 | 
					      // display : "...end_of_filename.ext"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user