Autor Tema: The DUPER v 1.4.01 , utilidad de KPS  (Leído 2692 veces)

Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9623
The DUPER v 1.4.01 , utilidad de KPS
« en: 28 de Marzo de 2017, 11:24:25 am »
Continuamos la labor de liberar nuestros programas y los que se han utilizado, en este caso os traemos uno que se creó en 2007.

Seguramente muchas veces habeis visto en las instalaciones un mensaje como "CREADO por ADFS* bla blabla" y un fichero dupe.bat en la instalación, el programa lo que hace es buscar ficheros duplicados y crea los ficheros dupe.bat y remove_dupe.bat.

*ADFS es acrónimo de Advanced Dupe File System

Modo de uso:

1-Descomprime el zip donde quieras buscar ficheros duplicados
2-Ejecuta duper.exe
3-Cuando haya acabado verás que hay 4 ficheros de más, dupe.bat, remove_dupe.bat, y dos txt temporales
4-Borra los ejecutables del duper y los txt temporales
5-Ejecuta remove_dupe.bat para liberar espacio

Ahora que ya ha eliminado los datos duplicados hazte tu propia instalación copiando, y después que ejecute el fichero dupe.bat

Esperemos que os sea de utilidad, llevamos más de 10 años usándoloa, previamente (en 2007 creo) se liberó en el forum opgforum para su testeo

Es solo para Windows, funciona con Wine, no hay binario para Linux porqué se perdió el código fuente
Siempre que pasa igual sucede lo mismo



paddddd

  • Usuario Héroe
  • *****
  • Mensajes: 1775
Re:The DUPER v 1.4.01 , utilidad de KPS
« Respuesta #1 en: 29 de Marzo de 2017, 01:45:59 am »
Gracias Fl0ppy.

Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9623
Re:The DUPER v 1.4.01 , utilidad de KPS
« Respuesta #2 en: 21 de Enero de 2023, 02:08:52 pm »
He encontrado el código fuente del programa, lo adjunto en un .7z que aparte de incluirlo lleva dos binarios (estáticos) para GNU/Linux x86_64 y x86 (64 y 32 bits)

Spoiler for Hiden:
Quote (selected)
/* CREADO POR KAPITAL SIN 2007-2023*/
/*CODIGO BAJO LICENCIA DE DOMNIO PUBLICO*/

/* Compara ficheros iguales en un arbol de subdirectorios */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/*************/
/* Constants */
/*************/
#define SIZE_MINIMUM        "512"
#define BATFILE             "dupe.bat"
#define BATREMOVE           "remove_dupe.bat"
#define LIST_FILENAME       "list_tmp.txt"
#define REFERENCES_FILENAME "ref_tmp.txt"

#define MAX_PATH 2048


/*************/
/* Functions */
/*************/

#if __unix__
/* OS is unix */
int generate_file_list(void)
{
   system("find -size +" SIZE_MINIMUM "c -type f -printf \"\%s \%p\\n\" | sort -g > " LIST_FILENAME);
}
#else
/* Should be MSDOS, don't know how to do it */
#error OS NOT SUPPORTED
#endif

void error_file_open(unsigned char *path)
{
   printf("Error opening file %s\n", path);
   exit -1;
}
void warning_file_open(unsigned char *path)
{
   printf("Ignoring file %s\n", path);
}

void format_filename(char *filename)
{
   int i, len;
   char *fin;
   char *fout;

   /* Remove trailing new line */
   if (filename[strlen(filename)-1] == '\n')
      filename[strlen(filename)-1] =  '\0';

   /* Remove leading blanks */
   fout = fin = filename;
   while (*fin == ' ' ) fin++;
   while (*fin != '\0') *fout++ = *fin++;
   *fout = '\0';

   /* Remove trailing blanks */

}

void get_stats(long *num_files, long *total_size)
{
   FILE *flist;
   long counter;
   long size;
   char line[MAX_PATH];

   flist = fopen(LIST_FILENAME, "rt");
   if(flist == NULL) error_file_open(LIST_FILENAME);
   counter = 0;
   size = 0;
   while(!feof(flist))
   {
      if(fgets(line, sizeof(line), flist) == NULL) break;
      size += strtol(line, NULL, 10);
      counter++;
   }

   *num_files = counter;
   *total_size = size;
   fclose(flist);
}
#if 0
int compare(FILE* fa, FILE* fb)
{
  int equal = 1;

  while(!feof(fa) && !feof(fb) && equal == 1)
  {
    equal = fgetc(fa) == fgetc(fb);
  }
  if (feof(fa) != feof(fb))
    return 0; /* Different lenght - treat as different */
  else
    return equal;
}
#else
int compare(FILE* fa, FILE* fb)
{
  int equal = 1;
  int a,b;

  while((a!=EOF) && (b!=EOF) && equal == 1)
  {
   a = fgetc(fa);
   b = fgetc(fb);
    equal = (a == b);
  }
  return equal;
}
#endif

int cmp_reference(char *filename, char *fileequal)
{
   FILE *fref;
   FILE *fin1;
   FILE *fin2;

   int status = 0;

   /* Open binary file to compare */
   fin1 = fopen(filename, "rb");
   if(fin1 == NULL) error_file_open(filename);

   fref = fopen(REFERENCES_FILENAME, "rt");
   while(!feof(fref) && status == 0)
   {
      fgets(fileequal, MAX_PATH, fref);
      format_filename(fileequal);

      /* Open binary reference file */
      fin2 = fopen(fileequal, "rb");
      if(fin2 == NULL){warning_file_open(fileequal); continue;}

      /* Compare binary files */
      status = compare(fin1, fin2);

      /* Close fin2, rewind fin1 to be used again with next reference file */
      fclose(fin2);
      rewind(fin1);
   }

   fclose(fin1);
   fclose(fref);

   return status;
}

void path2dos(char *filename)
{
   /* Change forwardslash to backslash */
   while(*filename != '\0')
   {
      if (*filename == '/')
         *filename = '\\';
      filename++;
   }
   
}

int main(int argc, char *argv[])
{
   /* Initialize */
   FILE *batfile;
   FILE *batremove;
   FILE *flist;
   FILE *freferences;
   char line[MAX_PATH];
   char *filename;
   char fileequal[MAX_PATH];
   long int fsize = -1;
   long int last_size = -1;
   long num_files;
   long total_size;
   long count;

   /* Print program info */
   printf("+===========[ADFS V.1.4.01]===========+\n");
   printf("|:_____: _____ __________  ·_________ |\n");
   printf("||__   |/    /\\______    \\ / _______/ |\n");
   printf("|  / __/ ___/ · | ²__/   / \\_____   \\_|\n");
   printf("| /  \\   \\_  ·  |  \\_____/ \\  \\_|    /|\n");
   printf("| \\   \\    \\_·  |    : · :  \\_______/ |\n");
   printf("|  \\___\\____\\  ·:____|   :            |\n");
   printf("|    K·a·P·i·T·a·L·  S i N ' 07       |\n");
   printf("+-------------------------------------|\n");
   printf("|-KPS-                           -'07-|\n");
   printf("|    · AUTOMATIC DUPE FILE SYSTEM ·   |\n");
   printf("|        · por KAPITAL SIN ·          |\n");
   printf("+[W95/98/XP/Linux/UTIL]---------------+\n\n\n");

   printf("This tool is FREEWARE\n");
   printf("Compares binary files from current dir tree.\n");

   /* Get sorted dir tree with sizes */
   printf("[Generating file list]\n");
   generate_file_list();

   /* Open output files */
   batfile = fopen(BATFILE, "wb");
   if(batfile == NULL) error_file_open(BATFILE);
   batremove = fopen(BATREMOVE, "wb");
   if(batremove == NULL) error_file_open(BATREMOVE);
   freferences = fopen(REFERENCES_FILENAME, "w+t");
   if(freferences == NULL) error_file_open(REFERENCES_FILENAME);
   flist = fopen(LIST_FILENAME, "rt");
   if(flist == NULL) error_file_open(LIST_FILENAME);

   fprintf(batfile, "rem Automatic dupe filesystem\n");
   fprintf(batremove, "rem Automatic remove filesystem\n");

   /* Get some stats data */
   get_stats(&num_files, &total_size);
   count = 0;

   printf("[Processing file list]\n");
   while(!feof(flist))
   {
      /* Get new size and filename from list */
      if(fgets(line, sizeof(line), flist) == NULL) break;
      fsize = strtol(line, &filename, 10);
      format_filename(filename);
      
      /* Display state info */
//      printf("%s\n", filename);
//      printf(".");fflush(stdout);
      printf("\r%d/%d", ++count, num_files);
      
      /* Check if it has new size */
      if(fsize != last_size)
      {
         /* New size, reinit reference list */
         last_size = fsize;
         fclose(freferences);
         freferences = fopen(REFERENCES_FILENAME, "w+t");
         
         /* Add path to reference file */
         fprintf(freferences, "%s\n", filename);
         fflush(freferences);
         
      }
      else
      {
         /* No new size, compare with reference list */
         /* Check if has equal file */
         if(cmp_reference(filename, fileequal))
         {
            /* format paths to be used on DOS systems */
            path2dos(fileequal);
            path2dos(filename);
            
            /* Has equal, update bat files */
            fprintf(batfile, "copy \"%s\" \"%s\" > NUL \n", fileequal, filename);
            fprintf(batremove, "del \"%s\" \n", filename);
         }
         else
         {
            /* No equal, add path to reference list */
            fprintf(freferences, "%s\n", filename);
            fflush(freferences);
         }
      }
   }

   /* Close output files */
   fclose(batfile);
   fclose(batremove);
   fclose(freferences);
   fclose(flist);

#if 1
   /* remove temporal files */
   unlink(LIST_FILENAME);
   unlink(REFERENCES_FILENAME);
#endif

   /* Print program exit info */
   printf("\nFinished!\n");
   printf("Output generated at " BATFILE " and " BATREMOVE "\n");

   return 0;
}

Siempre que pasa igual sucede lo mismo