@@ -1514,6 +1514,17 @@ int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
1514
1514
return 1 /* success */ ;
1515
1515
}
1516
1516
1517
+ static void create_dir (const char * dir_name ) {
1518
+ // Create output directory. We can ignore the error output since it will
1519
+ // only delay the failure to the first attempt of creating a file in the
1520
+ // (not) newly created directory.
1521
+ #ifdef _WIN32
1522
+ (void )CreateDirectory (dir_name , NULL );
1523
+ #else
1524
+ (void )mkdir (dir_name , 0755 );
1525
+ #endif
1526
+ }
1527
+
1517
1528
static int read_data (void * data , size_t size , ZInfo * z_info , FILE * in_fd ) {
1518
1529
// We want to fill 'data' with 'size' bytes.
1519
1530
z_info -> strm .next_out = data ;
@@ -1593,12 +1604,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
1593
1604
return 0 ;
1594
1605
}
1595
1606
1596
- // Create output directory (ignore any errors).
1597
- #ifdef _WIN32
1598
- CreateDirectory (full_name , NULL );
1599
- #else
1600
- mkdir (full_name , 0755 );
1601
- #endif
1607
+ create_dir (full_name );
1602
1608
full_name [out_dir_length ] = '/' ;
1603
1609
1604
1610
// Process the file until we hit the PACK_END record (or finish the
@@ -1644,11 +1650,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
1644
1650
full_name [FULL_NAME_LEN - 1 ] = '\0' ;
1645
1651
1646
1652
if (info .kind == PACK_DIR ) {
1647
- #ifdef _WIN32
1648
- CreateDirectory (full_name , NULL );
1649
- #else
1650
- mkdir (full_name , 0755 );
1651
- #endif
1653
+ create_dir (full_name );
1652
1654
} else {
1653
1655
// Read file contents
1654
1656
FILE * out_file = fopen (full_name , "wb" );
0 commit comments