udf1.c: Do better about dealing with recursive directories.

iso-info.c: small variable name change
This commit is contained in:
rocky
2005-10-30 15:58:37 +00:00
parent 788be22393
commit f91f3dd65c
2 changed files with 28 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
/* /*
$Id: udf1.c,v 1.11 2005/10/30 07:35:36 rocky Exp $ $Id: udf1.c,v 1.12 2005/10/30 15:58:37 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -51,44 +51,48 @@
#define udf_PATH_DELIMITERS "/\\" #define udf_PATH_DELIMITERS "/\\"
static void static void
print_file_info(const udf_file_t *p_udf_file) print_file_info(const udf_file_t *p_udf_file, const char* psz_dirname)
{ {
time_t mod_time = udf_get_modification_time(p_udf_file); time_t mod_time = udf_get_modification_time(p_udf_file);
char psz_mode[11]="invalid"; char psz_mode[11]="invalid";
const char *psz_fname= psz_dirname
? psz_dirname : udf_get_filename(p_udf_file);
if ('\0' == *psz_fname) psz_fname = strdup(".");
/* Print directory attributes*/ /* Print directory attributes*/
printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_file), printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_file),
psz_mode)); psz_mode));
printf("%4d ", udf_get_link_count(p_udf_file)); printf("%4d ", udf_get_link_count(p_udf_file));
printf("%s %s", udf_get_filename(p_udf_file), ctime(&mod_time)); printf("%s %s", psz_fname, ctime(&mod_time));
} }
static udf_file_t * static udf_file_t *
list_files(const udf_t *p_udf, udf_file_t *p_udf_file, char *psz_token) list_files(const udf_t *p_udf, udf_file_t *p_udf_file, const char *psz_path)
{ {
if (!p_udf_file) return NULL; if (!p_udf_file) return NULL;
if (psz_token) {
print_file_info(p_udf_file);
}
print_file_info(p_udf_file, psz_path);
while (udf_get_next(p_udf, p_udf_file)) { while (udf_get_next(p_udf, p_udf_file)) {
char *next_tok = strtok(psz_token, udf_PATH_DELIMITERS);
if (udf_is_dir(p_udf_file)) { if (udf_is_dir(p_udf_file)) {
udf_file_t * p_udf_file2 = udf_get_sub(p_udf, p_udf_file);
udf_file_t *p_udf_file2 = udf_get_sub(p_udf, p_udf_file);
if (p_udf_file2) { if (p_udf_file2) {
udf_file_t *p_udf_file3 = const char *psz_dirname = udf_get_filename(p_udf_file);
list_files(p_udf, p_udf_file2, next_tok); const unsigned int i_newlen=2 + strlen(psz_path) + strlen(psz_dirname);
char *psz_newpath = calloc(1, sizeof(char)*i_newlen);
if (!p_udf_file3) udf_file_free(p_udf_file2); snprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname);
udf_file_free(p_udf_file3); list_files(p_udf, p_udf_file2, psz_newpath);
free(psz_newpath);
udf_file_free(p_udf_file2);
} }
} else { } else {
print_file_info(p_udf_file); print_file_info(p_udf_file, NULL);
} }
} }
free(psz_token);
return p_udf_file; return p_udf_file;
} }
@@ -134,7 +138,7 @@ main(int argc, const char *argv[])
} }
list_files(p_udf, p_udf_file, strdup(udf_get_filename(p_udf_file))); list_files(p_udf, p_udf_file, "");
udf_file_free(p_udf_file); udf_file_free(p_udf_file);
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: iso-info.c,v 1.32 2005/10/06 09:37:11 rocky Exp $ $Id: iso-info.c,v 1.33 2005/10/30 15:58:37 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -198,17 +198,17 @@ _log_handler (cdio_log_level_t level, const char message[])
} }
static void static void
print_iso9660_recurse (iso9660_t *p_iso, const char pathname[]) print_iso9660_recurse (iso9660_t *p_iso, const char psz_path[])
{ {
CdioList_t *entlist; CdioList_t *entlist;
CdioList_t *dirlist = _cdio_list_new (); CdioList_t *dirlist = _cdio_list_new ();
CdioListNode_t *entnode; CdioListNode_t *entnode;
uint8_t i_joliet_level = iso9660_ifs_get_joliet_level(p_iso); uint8_t i_joliet_level = iso9660_ifs_get_joliet_level(p_iso);
entlist = iso9660_ifs_readdir (p_iso, pathname); entlist = iso9660_ifs_readdir (p_iso, psz_path);
if (opts.print_iso9660) { if (opts.print_iso9660) {
printf ("%s:\n", pathname); printf ("%s:\n", psz_path);
} }
if (NULL == entlist) { if (NULL == entlist) {
@@ -228,10 +228,10 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) { if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) {
iso9660_name_translate_ext(psz_iso_name, translated_name, iso9660_name_translate_ext(psz_iso_name, translated_name,
i_joliet_level); i_joliet_level);
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
translated_name); translated_name);
} else { } else {
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, snprintf (_fullname, sizeof (_fullname), "%s%s", psz_path,
psz_iso_name); psz_iso_name);
} }
@@ -249,7 +249,7 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
psz_iso_name, translated_name); psz_iso_name, translated_name);
} else } else
if ( strcmp (psz_iso_name, ".") && strcmp (psz_iso_name, "..")) if ( strcmp (psz_iso_name, ".") && strcmp (psz_iso_name, ".."))
printf("%9u %s%s\n", (unsigned int) p_statbuf->size, pathname, printf("%9u %s%s\n", (unsigned int) p_statbuf->size, psz_path,
yep == p_statbuf->rr.b3_rock yep == p_statbuf->rr.b3_rock
? psz_iso_name : translated_name); ? psz_iso_name : translated_name);
if (p_statbuf->rr.i_symlink) { if (p_statbuf->rr.i_symlink) {