@@ -17,9 +17,6 @@ static int copy_file(const char *fromfile, const char *tofile, bool force);
17
17
#ifdef WIN32
18
18
static int win32_pghardlink (const char * src , const char * dst );
19
19
#endif
20
- #ifdef NOT_USED
21
- static int copy_dir (const char * from , const char * to , bool force );
22
- #endif
23
20
24
21
#ifndef HAVE_SCANDIR
25
22
static int pg_scandir_internal (const char * dirname ,
@@ -381,97 +378,3 @@ win32_pghardlink(const char *src, const char *dst)
381
378
return 0 ;
382
379
}
383
380
#endif
384
-
385
-
386
- #ifdef NOT_USED
387
- /*
388
- * copy_dir()
389
- *
390
- * Copies either a directory or a single file within a directory. If the
391
- * source argument names a directory, we recursively copy that directory,
392
- * otherwise we copy a single file.
393
- */
394
- static int
395
- copy_dir (const char * src , const char * dst , bool force )
396
- {
397
- DIR * srcdir ;
398
- struct dirent * de = NULL ;
399
- struct stat fst ;
400
-
401
- if (src == NULL || dst == NULL )
402
- return -1 ;
403
-
404
- /*
405
- * Try to open the source directory - if it turns out not to be a
406
- * directory, assume that it's a file and copy that instead.
407
- */
408
- if ((srcdir = opendir (src )) == NULL )
409
- {
410
- if (errno == ENOTDIR )
411
- return copy_file (src , dst , true);
412
- return -1 ;
413
- }
414
-
415
- if (mkdir (dst , S_IRWXU ) != 0 )
416
- {
417
- /*
418
- * ignore directory already exist error
419
- */
420
- if (errno != EEXIST )
421
- return -1 ;
422
- }
423
-
424
- while ((de = readdir (srcdir )) != NULL )
425
- {
426
- char src_file [MAXPGPATH ];
427
- char dest_file [MAXPGPATH ];
428
-
429
- if (strcmp (de -> d_name , "." ) == 0 || strcmp (de -> d_name , ".." ) == 0 )
430
- continue ;
431
-
432
- memset (src_file , 0 , sizeof (src_file ));
433
- memset (dest_file , 0 , sizeof (dest_file ));
434
-
435
- snprintf (src_file , sizeof (src_file ), "%s/%s" , src , de -> d_name );
436
- snprintf (dest_file , sizeof (dest_file ), "%s/%s" , dst , de -> d_name );
437
-
438
- if (stat (src_file , & fst ) < 0 )
439
- {
440
- if (srcdir != NULL )
441
- {
442
- closedir (srcdir );
443
- srcdir = NULL ;
444
- }
445
-
446
- return -1 ;
447
- }
448
-
449
- if (S_ISDIR (fst .st_mode ))
450
- {
451
- /* recurse to handle subdirectories */
452
- if (force )
453
- copy_dir (src_file , dest_file , true);
454
- }
455
- else if (S_ISREG (fst .st_mode ))
456
- {
457
- if ((copy_file (src_file , dest_file , 1 )) == -1 )
458
- {
459
- if (srcdir != NULL )
460
- {
461
- closedir (srcdir );
462
- srcdir = NULL ;
463
- }
464
- return -1 ;
465
- }
466
- }
467
- }
468
-
469
- if (srcdir != NULL )
470
- {
471
- closedir (srcdir );
472
- srcdir = NULL ;
473
- }
474
- return 1 ;
475
- }
476
-
477
- #endif
0 commit comments