mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed cdmake on linux, if D_TYPE is not supported.
svn path=/trunk/; revision=4936
This commit is contained in:
parent
58b09f3345
commit
a9b7d71462
1 changed files with 138 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cdmake.c,v 1.3 2003/04/12 14:53:56 chorns Exp $ */
|
/* $Id: cdmake.c,v 1.4 2003/06/21 09:11:24 guido Exp $ */
|
||||||
/* CD-ROM Maker
|
/* CD-ROM Maker
|
||||||
by Philip J. Erdelsky
|
by Philip J. Erdelsky
|
||||||
pje@acm.org
|
pje@acm.org
|
||||||
|
@ -545,7 +545,11 @@ new_directory_record (struct dirent *entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_date_and_time(&d->date_and_time, &stbuf->st_mtime);
|
convert_date_and_time(&d->date_and_time, &stbuf->st_mtime);
|
||||||
|
#ifdef HAVE_D_TYPE
|
||||||
if (entry->d_type == DT_DIR)
|
if (entry->d_type == DT_DIR)
|
||||||
|
#else
|
||||||
|
if (S_ISDIR(stbuf->st_mode))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (d->extension[0] != 0)
|
if (d->extension[0] != 0)
|
||||||
error_exit("Directory with extension %s", entry->d_name);
|
error_exit("Directory with extension %s", entry->d_name);
|
||||||
|
@ -710,17 +714,17 @@ make_directory_records (PDIR_RECORD d)
|
||||||
|
|
||||||
d->first_record = NULL;
|
d->first_record = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_D_TYPE
|
||||||
dirp = opendir(source);
|
dirp = opendir(source);
|
||||||
|
|
||||||
if (dirp != NULL)
|
if (dirp != NULL)
|
||||||
{
|
{
|
||||||
while ((entry = readdir (dirp)) != NULL)
|
while ((entry = readdir (dirp)) != NULL)
|
||||||
{
|
{
|
||||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||||
continue; // skip self and parent
|
continue; // skip self and parent
|
||||||
|
|
||||||
if (entry->d_type == DT_REG) // normal file
|
if (entry->d_type == DT_REG) // normal file
|
||||||
{
|
{
|
||||||
// Check for an absolute path
|
// Check for an absolute path
|
||||||
if (source[0] == DIR_SEPARATOR_CHAR)
|
if (source[0] == DIR_SEPARATOR_CHAR)
|
||||||
{
|
{
|
||||||
|
@ -735,26 +739,27 @@ make_directory_records (PDIR_RECORD d)
|
||||||
strcat(buf, source);
|
strcat(buf, source);
|
||||||
strcat(buf, entry->d_name);
|
strcat(buf, entry->d_name);
|
||||||
}
|
}
|
||||||
if (stat(buf, &stbuf) == -1)
|
|
||||||
|
if (stat(buf, &stbuf) == -1)
|
||||||
{
|
{
|
||||||
error_exit("Can't access '%s' (%s)\n", buf, strerror(errno));
|
error_exit("Can't access '%s' (%s)\n", buf, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(entry->d_name, DIRECTORY_TIMESTAMP) == 0)
|
if (strcmp(entry->d_name, DIRECTORY_TIMESTAMP) == 0)
|
||||||
{
|
{
|
||||||
convert_date_and_time(&d->date_and_time, &stbuf.st_size);
|
convert_date_and_time(&d->date_and_time, &stbuf.st_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verbosity == VERBOSE)
|
if (verbosity == VERBOSE)
|
||||||
{
|
{
|
||||||
printf("%d: file %s\n", d->level, buf);
|
printf("%d: file %s\n", d->level, buf);
|
||||||
}
|
}
|
||||||
(void) new_directory_record(entry, &stbuf, d);
|
(void) new_directory_record(entry, &stbuf, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir (dirp);
|
closedir (dirp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -776,29 +781,30 @@ make_directory_records (PDIR_RECORD d)
|
||||||
old_end_source = end_source;
|
old_end_source = end_source;
|
||||||
append_string_to_source(entry->d_name);
|
append_string_to_source(entry->d_name);
|
||||||
*end_source++ = DIR_SEPARATOR_CHAR;
|
*end_source++ = DIR_SEPARATOR_CHAR;
|
||||||
|
*end_source = 0;
|
||||||
if (verbosity == VERBOSE)
|
if (verbosity == VERBOSE)
|
||||||
{
|
{
|
||||||
*end_source = 0;
|
|
||||||
printf("%d: directory %s\n", d->level + 1, source);
|
printf("%d: directory %s\n", d->level + 1, source);
|
||||||
}
|
}
|
||||||
if (d->level < MAX_LEVEL)
|
if (d->level < MAX_LEVEL)
|
||||||
{
|
{
|
||||||
// Check for an absolute path
|
// Check for an absolute path
|
||||||
if (source[0] == DIR_SEPARATOR_CHAR)
|
if (source[0] == DIR_SEPARATOR_CHAR)
|
||||||
{
|
{
|
||||||
strcpy(buf, source);
|
strcpy(buf, source);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getcwd(buf, sizeof(buf));
|
getcwd(buf, sizeof(buf));
|
||||||
strcat(buf, DIR_SEPARATOR_STRING);
|
strcat(buf, DIR_SEPARATOR_STRING);
|
||||||
strcat(buf, source);
|
strcat(buf, source);
|
||||||
}
|
}
|
||||||
if (stat(buf, &stbuf) == -1)
|
|
||||||
{
|
if (stat(buf, &stbuf) == -1)
|
||||||
error_exit("Can't access '%s' (%s)\n", buf, strerror(errno));
|
{
|
||||||
return;
|
error_exit("Can't access '%s' (%s)\n", buf, strerror(errno));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
new_d = new_directory_record(entry, &stbuf, d);
|
new_d = new_directory_record(entry, &stbuf, d);
|
||||||
new_d->next_in_path_table = root.next_in_path_table;
|
new_d->next_in_path_table = root.next_in_path_table;
|
||||||
root.next_in_path_table = new_d;
|
root.next_in_path_table = new_d;
|
||||||
|
@ -810,10 +816,100 @@ make_directory_records (PDIR_RECORD d)
|
||||||
error_exit("Directory is nested too deep");
|
error_exit("Directory is nested too deep");
|
||||||
}
|
}
|
||||||
end_source = old_end_source;
|
end_source = old_end_source;
|
||||||
|
*end_source = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir (dirp);
|
closedir (dirp);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_exit("Can't open %s\n", source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
dirp = opendir(source);
|
||||||
|
if (dirp != NULL)
|
||||||
|
{
|
||||||
|
while ((entry = readdir (dirp)) != NULL)
|
||||||
|
{
|
||||||
|
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||||
|
continue; // skip self and parent
|
||||||
|
|
||||||
|
// Check for an absolute path
|
||||||
|
if (source[0] == DIR_SEPARATOR_CHAR)
|
||||||
|
{
|
||||||
|
strcpy(buf, source);
|
||||||
|
strcat(buf, DIR_SEPARATOR_STRING);
|
||||||
|
strcat(buf, entry->d_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getcwd(buf, sizeof(buf));
|
||||||
|
strcat(buf, DIR_SEPARATOR_STRING);
|
||||||
|
strcat(buf, source);
|
||||||
|
strcat(buf, entry->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat(buf, &stbuf) == -1)
|
||||||
|
{
|
||||||
|
error_exit("Can't access '%s' (%s)\n", buf, strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S_ISDIR(stbuf.st_mode))
|
||||||
|
{
|
||||||
|
old_end_source = end_source;
|
||||||
|
append_string_to_source(entry->d_name);
|
||||||
|
*end_source++ = DIR_SEPARATOR_CHAR;
|
||||||
|
*end_source = 0;
|
||||||
|
if (verbosity == VERBOSE)
|
||||||
|
{
|
||||||
|
printf("%d: directory %s\n", d->level + 1, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->level < MAX_LEVEL)
|
||||||
|
{
|
||||||
|
new_d = new_directory_record(entry, &stbuf, d);
|
||||||
|
new_d->next_in_path_table = root.next_in_path_table;
|
||||||
|
root.next_in_path_table = new_d;
|
||||||
|
new_d->level = d->level + 1;
|
||||||
|
make_directory_records(new_d);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_exit("Directory is nested too deep");
|
||||||
|
}
|
||||||
|
|
||||||
|
end_source = old_end_source;
|
||||||
|
*end_source = 0;
|
||||||
|
}
|
||||||
|
else if (S_ISREG(stbuf.st_mode))
|
||||||
|
{
|
||||||
|
if (strcmp(entry->d_name, DIRECTORY_TIMESTAMP) == 0)
|
||||||
|
{
|
||||||
|
convert_date_and_time(&d->date_and_time, &stbuf.st_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (verbosity == VERBOSE)
|
||||||
|
{
|
||||||
|
printf("%d: file %s\n", d->level, buf);
|
||||||
|
}
|
||||||
|
(void) new_directory_record(entry, &stbuf, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir (dirp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_exit("Can't open %s\n", source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// sort directory
|
// sort directory
|
||||||
d->first_record = sort_linked_list(d->first_record, 0, compare_directory_order);
|
d->first_record = sort_linked_list(d->first_record, 0, compare_directory_order);
|
||||||
|
@ -916,15 +1012,11 @@ static void pass(void)
|
||||||
fill_sector();
|
fill_sector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Volume Descriptor Set Terminator
|
// Volume Descriptor Set Terminator
|
||||||
|
|
||||||
write_string("\377CD001\1");
|
write_string("\377CD001\1");
|
||||||
fill_sector();
|
fill_sector();
|
||||||
|
|
||||||
|
|
||||||
// Boot Catalog
|
// Boot Catalog
|
||||||
|
|
||||||
if (eltorito == TRUE)
|
if (eltorito == TRUE)
|
||||||
{
|
{
|
||||||
boot_catalog_sector = cd.sector;
|
boot_catalog_sector = cd.sector;
|
||||||
|
@ -950,9 +1042,7 @@ static void pass(void)
|
||||||
fill_sector();
|
fill_sector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Boot Image
|
// Boot Image
|
||||||
|
|
||||||
if (eltorito == TRUE)
|
if (eltorito == TRUE)
|
||||||
{
|
{
|
||||||
boot_image_sector = cd.sector;
|
boot_image_sector = cd.sector;
|
||||||
|
@ -984,9 +1074,7 @@ static void pass(void)
|
||||||
// fill_sector();
|
// fill_sector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Little Endian Path Table
|
// Little Endian Path Table
|
||||||
|
|
||||||
little_endian_path_table_sector = cd.sector;
|
little_endian_path_table_sector = cd.sector;
|
||||||
write_byte(1);
|
write_byte(1);
|
||||||
write_byte(0); // number of sectors in extended attribute record
|
write_byte(0); // number of sectors in extended attribute record
|
||||||
|
@ -1037,13 +1125,10 @@ static void pass(void)
|
||||||
}
|
}
|
||||||
fill_sector();
|
fill_sector();
|
||||||
|
|
||||||
|
|
||||||
// directories and files
|
// directories and files
|
||||||
|
|
||||||
for (d = &root; d != NULL; d = d->next_in_path_table)
|
for (d = &root; d != NULL; d = d->next_in_path_table)
|
||||||
{
|
{
|
||||||
// write directory
|
// write directory
|
||||||
|
|
||||||
d->sector = cd.sector;
|
d->sector = cd.sector;
|
||||||
write_directory_record(d, DOT_RECORD);
|
write_directory_record(d, DOT_RECORD);
|
||||||
write_directory_record(d == &root ? d : d->parent, DOT_DOT_RECORD);
|
write_directory_record(d == &root ? d : d->parent, DOT_DOT_RECORD);
|
||||||
|
@ -1058,7 +1143,6 @@ static void pass(void)
|
||||||
bytes_in_directories += d->size;
|
bytes_in_directories += d->size;
|
||||||
|
|
||||||
// write file data
|
// write file data
|
||||||
|
|
||||||
for (q = d->first_record; q != NULL; q = q->next_in_directory)
|
for (q = d->first_record; q != NULL; q = q->next_in_directory)
|
||||||
{
|
{
|
||||||
if ((q->flags & DIRECTORY_FLAG) == 0)
|
if ((q->flags & DIRECTORY_FLAG) == 0)
|
||||||
|
|
Loading…
Reference in a new issue