Add routine to get file length.

Fix bug in retrieving dirent for root.
Reduce overhead in udf_get_link_count()
This commit is contained in:
rocky
2005-11-02 03:42:49 +00:00
parent e9851bf3a3
commit 78883887df
5 changed files with 26 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: udf1.c,v 1.16 2005/11/01 13:07:01 rocky Exp $ $Id: udf1.c,v 1.17 2005/11/02 03:42:49 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -62,6 +62,7 @@ print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_dirname)
printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_dirent), printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_dirent),
psz_mode)); psz_mode));
printf("%4d ", udf_get_link_count(p_udf_dirent)); printf("%4d ", udf_get_link_count(p_udf_dirent));
printf("%lu ", (long unsigned int) udf_get_file_length(p_udf_dirent));
printf("%s %s", *psz_fname ? psz_fname : "/", ctime(&mod_time)); printf("%s %s", *psz_fname ? psz_fname : "/", ctime(&mod_time));
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: udf_file.h,v 1.3 2005/11/01 03:21:04 rocky Exp $ $Id: udf_file.h,v 1.4 2005/11/02 03:42:49 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
@@ -53,6 +53,11 @@ extern "C" {
*/ */
uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent); uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent);
/*!
Return the Length of the file/directory.
*/
uint64_t udf_get_file_length(const udf_dirent_t *p_udf_dirent);
/*! /*!
Returns a POSIX mode for a given p_udf_dirent. Returns a POSIX mode for a given p_udf_dirent.
*/ */

View File

@@ -14,6 +14,7 @@ VSD_STD_ID_TEA01
udf_close udf_close
udf_dirent_free udf_dirent_free
udf_get_file_entry udf_get_file_entry
udf_get_file_length
udf_get_fileid_descriptor udf_get_fileid_descriptor
udf_get_filename udf_get_filename
udf_get_link_count udf_get_link_count

View File

@@ -1,5 +1,5 @@
/* /*
$Id: udf_file.c,v 1.3 2005/11/01 13:07:01 rocky Exp $ $Id: udf_file.c,v 1.4 2005/11/02 03:42:50 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -66,10 +66,18 @@ bool udf_get_fileid_descriptor(const udf_dirent_t *p_udf_dirent,
uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent) uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent)
{ {
if (p_udf_dirent) { if (p_udf_dirent) {
udf_file_entry_t udf_fe; return uint16_from_le(p_udf_dirent->fe.link_count);
if (udf_get_file_entry(p_udf_dirent, &udf_fe)) {
return uint16_from_le(udf_fe.link_count);
} }
return 0; /* Error. Non-error case handled above. */
}
/*!
Return the number of hard links of the file. Return 0 if error.
*/
uint64_t udf_get_file_length(const udf_dirent_t *p_udf_dirent)
{
if (p_udf_dirent) {
return uint64_from_le(p_udf_dirent->fe.info_len);
} }
return 0; /* Error. Non-error case handled above. */ return 0; /* Error. Non-error case handled above. */
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: udf_fs.c,v 1.12 2005/11/01 13:07:01 rocky Exp $ $Id: udf_fs.c,v 1.13 2005/11/02 03:42:50 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -235,11 +235,9 @@ udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name)
if (psz_token) if (psz_token)
p_udf_file = udf_ff_traverse(p_udf_root, psz_token); p_udf_file = udf_ff_traverse(p_udf_root, psz_token);
else if ( 0 == strncmp("/", psz_name, sizeof("/")) ) { else if ( 0 == strncmp("/", psz_name, sizeof("/")) ) {
p_udf_file = calloc(1, sizeof(udf_dirent_t)); return udf_new_dirent(&p_udf_root->fe, p_udf_root->p_udf,
udf_new_dirent(&p_udf_root->fe, p_udf_root->p_udf,
p_udf_root->psz_name, p_udf_root->b_dir, p_udf_root->psz_name, p_udf_root->b_dir,
p_udf_root->b_parent); p_udf_root->b_parent);
return p_udf_file;
} }
} }
return p_udf_file; return p_udf_file;