"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/CCache/debian/patches/07_cachedirtag.diff" (30 Nov 2022, 1928 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 Index: ccache.c
    2 ===================================================================
    3 --- ccache.c    (révision 7695)
    4 +++ ccache.c    (copie de travail)
    5 @@ -1029,6 +1029,14 @@
    6         exit(1);
    7     }
    8  
    9 +   if (!getenv("CCACHE_READONLY")) {
   10 +       if (create_cachedirtag(cache_dir) != 0) {
   11 +           fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n",
   12 +               cache_dir, strerror(errno));
   13 +           exit(1);
   14 +       }
   15 +   }
   16 +
   17     ccache(argc, argv);
   18     return 1;
   19  }
   20 Index: ccache.h
   21 ===================================================================
   22 --- ccache.h    (révision 7695)
   23 +++ ccache.h    (copie de travail)
   24 @@ -81,6 +81,7 @@
   25  int copy_file(const char *src, const char *dest);
   26  
   27  int create_dir(const char *dir);
   28 +int create_cachedirtag(const char *dir);
   29  void x_asprintf(char **ptr, const char *format, ...);
   30  char *x_strdup(const char *s);
   31  void *x_realloc(void *ptr, size_t size);
   32 Index: util.c
   33 ===================================================================
   34 --- util.c  (révision 7695)
   35 +++ util.c  (copie de travail)
   36 @@ -138,6 +138,39 @@
   37     return 0;
   38  }
   39  
   40 +char const CACHEDIR_TAG[] =
   41 +   "Signature: 8a477f597d28d172789f06886806bc55\n"
   42 +   "# This file is a cache directory tag created by ccache.\n"
   43 +   "# For information about cache directory tags, see:\n"
   44 +   "#  http://www.brynosaurus.com/cachedir/\n";
   45 +
   46 +int create_cachedirtag(const char *dir)
   47 +{
   48 +   char *filename;
   49 +   struct stat st;
   50 +   FILE *f;
   51 +   x_asprintf(&filename, "%s/CACHEDIR.TAG", dir);
   52 +   if (stat(filename, &st) == 0) {
   53 +       if (S_ISREG(st.st_mode)) {
   54 +           goto success;
   55 +       }
   56 +       errno = EEXIST;
   57 +       goto error;
   58 +   }
   59 +   f = fopen(filename, "w");
   60 +   if (!f) goto error;
   61 +   if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
   62 +       goto error;
   63 +   }
   64 +   if (fclose(f)) goto error;
   65 +success:
   66 +   free(filename);
   67 +   return 0;
   68 +error:
   69 +   free(filename);
   70 +   return 1;
   71 +}
   72 +
   73  /*
   74    this is like asprintf() but dies if the malloc fails
   75    note that we use vsnprintf in a rather poor way to make this more portable