--- parser3/src/main/pa_common.C 2001/04/23 10:19:02 1.50 +++ parser3/src/main/pa_common.C 2001/04/26 14:55:28 1.52 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_common.C,v 1.50 2001/04/23 10:19:02 paf Exp $ + $Id: pa_common.C,v 1.52 2001/04/26 14:55:28 paf Exp $ */ #include "pa_config_includes.h" @@ -163,8 +163,21 @@ void file_delete(Pool& pool, const Strin rmdir(file_spec, 1); } + +static bool entry_readable(const String& file_spec, bool need_dir) { + const char *fname=file_spec.cstr(String::UL_FILE_NAME); + struct stat finfo; + if(access(fname, R_OK)==0 && stat(fname, &finfo)==0) { + bool is_dir=(bool)(finfo.st_mode&S_IFDIR); + return is_dir==need_dir; + } + return false; +} bool file_readable(const String& file_spec) { - return access(file_spec.cstr(String::UL_FILE_NAME), R_OK)==0; + return entry_readable(file_spec, false); +} +bool dir_readable(const String& file_spec) { + return entry_readable(file_spec, true); } bool file_executable(const String& file_spec) { return access(file_spec.cstr(String::UL_FILE_NAME), X_OK)==0; @@ -293,9 +306,10 @@ const char *unescape_chars(Pool& pool, c return s; } +/// used by attributed_meaning_to_string / append_attribute_subattribute struct Attributed_meaning_info { - String::Untaint_lang lang; - String *header; + String *header; // header line being constructed + String::Untaint_lang lang; // language in which to append to that line }; static void append_attribute_subattribute(const Hash::Key& akey, Hash::Val *avalue, void *info) { @@ -319,8 +333,8 @@ const String& attributed_meaning_to_stri result.append(value->as_string(), lang, true); Attributed_meaning_info attributed_meaning_info={ - lang, - &result + &result, + lang }; hash->for_each(append_attribute_subattribute, &attributed_meaning_info); } else // result value