Diff
Not logged in

Differences From Artifact [3708769da6]:

To Artifact [2199964263]:


347
348
349
350
351
352
353
















354
355
356
357
358
359
360
361
362
363





364
365
366
367
368
369
370
  const char *zTail = z;
  while( z[0] ){
    if( z[0]=='/' ) zTail = &z[1];
    z++;
  }
  return zTail;
}

















/*
** Copy the content of a file from one place to another.
*/
void file_copy(const char *zFrom, const char *zTo){
  FILE *in, *out;
  int got;
  char zBuf[8192];
  in = fossil_fopen(zFrom, "rb");
  if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);





  out = fossil_fopen(zTo, "wb");
  if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
  while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
    fwrite(zBuf, 1, got, out);
  }
  fclose(in);
  fclose(out);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>
>
>







347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
  const char *zTail = z;
  while( z[0] ){
    if( z[0]=='/' ) zTail = &z[1];
    z++;
  }
  return zTail;
}

/*
** Return the head of a file pathname.  The head is everything leading up
** to the last component of the path.  For example, the head of "/a/b/c.d" is "/a/b".
** The trailing slash is removed.
*/
void file_head(const char *z, char *h){
  int i = file_tail(z)-z;
  if( !i ){
    memmove(h, z, strlen(z));
    return;
  }
  if( '/' == z[i-1] ) i--;
  memmove(h, z, i);
  h[i] = '\0';
}

/*
** Copy the content of a file from one place to another.
*/
void file_copy(const char *zFrom, const char *zTo){
  FILE *in, *out;
  int got;
  char zBuf[8192];
  in = fossil_fopen(zFrom, "rb");
  if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);
  file_head(zTo, zBuf);
  if( !file_isdir(zBuf) )
  {
    file_mkdir(zBuf, 0);
  }
  out = fossil_fopen(zTo, "wb");
  if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
  while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
    fwrite(zBuf, 1, got, out);
  }
  fclose(in);
  fclose(out);