Mercurial > hg > octave-lyh
changeset 8689:ddbe87599331
base_file_stat::is_XXX: return false if object is not initialized
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 05 Feb 2009 17:38:24 -0500 |
parents | d7306ecd077a |
children | 6e9887f9cf9f |
files | liboctave/ChangeLog liboctave/file-stat.cc liboctave/file-stat.h |
diffstat | 3 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2009-02-05 John W. Eaton <jwe@octave.org> + + * file-stat.cc (base_file_stat::is_blk, base_file_stat::is_chr, + base_file_stat::is_dir, base_file_stat::is_fifo, + base_file_stat::is_lnk, base_file_stat::is_reg, + base_file_stat::is_sock): Return false if object is not initialized. + From Rafael Laboissiere <rafael@debian.org>. + 2009-02-05 Jaroslav Hajek <highegg@gmail.com> * idx-vector.h (idx_vector::idx_colon_rep,
--- a/liboctave/file-stat.cc +++ b/liboctave/file-stat.cc @@ -54,43 +54,43 @@ bool base_file_stat::is_blk (void) const { - return is_blk (fs_mode); + return ok () && is_blk (fs_mode); } bool base_file_stat::is_chr (void) const { - return is_chr (fs_mode); + return ok () && is_chr (fs_mode); } bool base_file_stat::is_dir (void) const { - return is_dir (fs_mode); + return ok () && is_dir (fs_mode); } bool base_file_stat::is_fifo (void) const { - return is_fifo (fs_mode); + return ok () && is_fifo (fs_mode); } bool base_file_stat::is_lnk (void) const { - return is_lnk (fs_mode); + return ok () && is_lnk (fs_mode); } bool base_file_stat::is_reg (void) const { - return is_reg (fs_mode); + return ok () && is_reg (fs_mode); } bool base_file_stat::is_sock (void) const { - return is_sock (fs_mode); + return ok () && is_sock (fs_mode); } bool
--- a/liboctave/file-stat.h +++ b/liboctave/file-stat.h @@ -79,8 +79,10 @@ ~base_file_stat (void) { } - // File status and info. These should only be called for objects - // that are already properly initialized. + // File status and info. The is_XXX functions will return false for + // file_stat objects that are not properly initialized. The others + // should all return 0 (or the equivalent, for the given object) + // which is likely not meaningful. bool is_blk (void) const; bool is_chr (void) const;