udf_find_file -> udf_fopen and made closer to fopen(). It also
simplifies things a little bit. Start testing.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.am,v 1.27 2005/10/25 14:16:41 pjcreath Exp $
|
||||
# $Id: Makefile.am,v 1.28 2005/11/01 13:07:01 rocky Exp $
|
||||
#
|
||||
# Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
#
|
||||
@@ -28,7 +28,7 @@ paranoia_progs = paranoia paranoia2
|
||||
endif
|
||||
noinst_PROGRAMS = audio cdtext device drives iso1 iso2 iso3 isofuzzy \
|
||||
mmc1 mmc2 $(paranoia_progs) tracks \
|
||||
sample3 sample4 udf1
|
||||
sample3 sample4 udf1 udf2
|
||||
|
||||
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
|
||||
|
||||
@@ -61,6 +61,9 @@ tracks_LDADD = $(LIBCDIO_LIBS)
|
||||
udf1_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
|
||||
udf1_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS)
|
||||
|
||||
udf2_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
|
||||
udf2_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS)
|
||||
|
||||
|
||||
# iso programs create file "copying"
|
||||
MOSTLYCLEANFILES = copying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: udf1.c,v 1.15 2005/11/01 03:21:04 rocky Exp $
|
||||
$Id: udf1.c,v 1.16 2005/11/01 13:07:01 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -97,24 +97,24 @@ int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
udf_t *p_udf;
|
||||
char const *psz_fname;
|
||||
char const *psz_udf_image;
|
||||
|
||||
if (argc > 1)
|
||||
psz_fname = argv[1];
|
||||
psz_udf_image = argv[1];
|
||||
else
|
||||
psz_fname = UDF_IMAGE;
|
||||
psz_udf_image = UDF_IMAGE;
|
||||
|
||||
p_udf = udf_open (psz_fname);
|
||||
p_udf = udf_open (psz_udf_image);
|
||||
|
||||
if (NULL == p_udf) {
|
||||
fprintf(stderr, "Sorry, couldn't open %s as something using UDF\n",
|
||||
psz_fname);
|
||||
psz_udf_image);
|
||||
return 1;
|
||||
} else {
|
||||
udf_dirent_t *p_udf_dirent = udf_get_root(p_udf, true, 0);
|
||||
if (NULL == p_udf_dirent) {
|
||||
udf_dirent_t *p_udf_root = udf_get_root(p_udf, true, 0);
|
||||
if (NULL == p_udf_root) {
|
||||
fprintf(stderr, "Sorry, couldn't find / in %s\n",
|
||||
psz_fname);
|
||||
psz_udf_image);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
}
|
||||
|
||||
list_files(p_udf, p_udf_dirent, "");
|
||||
list_files(p_udf, p_udf_root, "");
|
||||
}
|
||||
|
||||
udf_close(p_udf);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: udf.h,v 1.16 2005/11/01 03:14:49 rocky Exp $
|
||||
$Id: udf.h,v 1.17 2005/11/01 13:07:01 rocky Exp $
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -124,12 +124,9 @@ extern "C" {
|
||||
unsigned int i_volsetid);
|
||||
|
||||
/*!
|
||||
Return a file pointer matching pzz_name. If b_any_partition is false then
|
||||
the root must be in the given partition.
|
||||
Return a file pointer matching pzz_name.
|
||||
*/
|
||||
udf_dirent_t *udf_find_file(udf_t *p_udf, const char *psz_name,
|
||||
bool b_any_partition,
|
||||
partition_num_t i_partition);
|
||||
udf_dirent_t *udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name);
|
||||
|
||||
/*! udf_mode_string - fill in string PSZ_STR with an ls-style ASCII
|
||||
representation of the i_mode. PSZ_STR is returned.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: udf_file.c,v 1.2 2005/11/01 03:14:50 rocky Exp $
|
||||
$Id: udf_file.c,v 1.3 2005/11/01 13:07:01 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -30,6 +30,7 @@ const char *
|
||||
udf_get_filename(const udf_dirent_t *p_udf_dirent)
|
||||
{
|
||||
if (!p_udf_dirent) return NULL;
|
||||
if (!p_udf_dirent->psz_name) return ".";
|
||||
return p_udf_dirent->psz_name;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: udf_fs.c,v 1.11 2005/11/01 03:21:04 rocky Exp $
|
||||
$Id: udf_fs.c,v 1.12 2005/11/01 13:07:01 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -113,6 +113,10 @@ const char VSD_STD_ID_TEA01[] = {'T', 'E', 'A', '0', '1'};
|
||||
* |-->File data
|
||||
*/
|
||||
|
||||
static udf_dirent_t *
|
||||
udf_new_dirent(udf_file_entry_t *p_udf_fe, udf_t *p_udf,
|
||||
const char *psz_name, bool b_dir, bool b_parent);
|
||||
|
||||
/**
|
||||
* Check the descriptor tag for both the correct id and correct checksum.
|
||||
* Return zero if all is good, -1 if not.
|
||||
@@ -190,7 +194,7 @@ udf_get_lba(const udf_file_entry_t *p_udf_fe,
|
||||
|
||||
static
|
||||
udf_dirent_t *
|
||||
udf_ff_traverse(udf_t *p_udf, udf_dirent_t *p_udf_dirent, char *psz_token)
|
||||
udf_ff_traverse(udf_dirent_t *p_udf_dirent, char *psz_token)
|
||||
{
|
||||
while (udf_readdir(p_udf_dirent)) {
|
||||
if (strcmp(psz_token, p_udf_dirent->psz_name) == 0) {
|
||||
@@ -203,7 +207,7 @@ udf_ff_traverse(udf_t *p_udf, udf_dirent_t *p_udf_dirent, char *psz_token)
|
||||
|
||||
if (p_udf_dirent2) {
|
||||
udf_dirent_t * p_udf_dirent3 =
|
||||
udf_ff_traverse(p_udf, p_udf_dirent2, next_tok);
|
||||
udf_ff_traverse(p_udf_dirent2, next_tok);
|
||||
|
||||
if (!p_udf_dirent3) udf_dirent_free(p_udf_dirent2);
|
||||
return p_udf_dirent3;
|
||||
@@ -218,24 +222,27 @@ udf_ff_traverse(udf_t *p_udf, udf_dirent_t *p_udf_dirent, char *psz_token)
|
||||
#define udf_MAX_PATHLEN 2048
|
||||
|
||||
udf_dirent_t *
|
||||
udf_find_file(udf_t *p_udf, const char *psz_name, bool b_any_partition,
|
||||
partition_num_t i_partition)
|
||||
udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name)
|
||||
{
|
||||
udf_dirent_t *p_udf_dirent =
|
||||
udf_get_root(p_udf, b_any_partition, i_partition);
|
||||
udf_dirent_t *p_udf_dirent2 = NULL;
|
||||
udf_dirent_t *p_udf_file = NULL;
|
||||
|
||||
if (p_udf_dirent) {
|
||||
if (p_udf_root) {
|
||||
char tokenline[udf_MAX_PATHLEN];
|
||||
char *psz_token;
|
||||
|
||||
strcpy(tokenline, psz_name);
|
||||
psz_token = strtok(tokenline, udf_PATH_DELIMITERS);
|
||||
if (psz_token)
|
||||
p_udf_dirent2 = udf_ff_traverse(p_udf, p_udf_dirent, psz_token);
|
||||
udf_dirent_free(p_udf_dirent);
|
||||
p_udf_file = udf_ff_traverse(p_udf_root, psz_token);
|
||||
else if ( 0 == strncmp("/", psz_name, sizeof("/")) ) {
|
||||
p_udf_file = calloc(1, sizeof(udf_dirent_t));
|
||||
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->b_parent);
|
||||
return p_udf_file;
|
||||
}
|
||||
return p_udf_dirent2;
|
||||
}
|
||||
return p_udf_file;
|
||||
}
|
||||
|
||||
/* Convert unicode16 to 8-bit char by dripping MSB.
|
||||
|
||||
Reference in New Issue
Block a user