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