--- parser3/src/include/pa_common.h 2002/08/15 12:05:36 1.80 +++ parser3/src/include/pa_common.h 2002/11/25 14:10:52 1.85 @@ -8,12 +8,12 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char* IDENT_COMMON_H="$Date: 2002/08/15 12:05:36 $"; +static const char* IDENT_COMMON_H="$Date: 2002/11/25 14:10:52 $"; #include "pa_pool.h" #include "pa_string.h" -class Value; +class Hash; // replace system s*nprintf with our versions #undef vsnprintf @@ -89,23 +89,47 @@ void fix_line_breaks( size_t& size ///< may change! used to speedup next actions ); +typedef void (*File_read_action)(Pool& pool, + struct stat& finfo, + int f, + const String& file_spec, const char *fname, bool as_text, + void *context); + +/** + shared-lock specified file, + do actions under lock. + if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK +*/ +bool file_read_action_under_lock(Pool& pool, const String& file_spec, + const char *action_name, File_read_action action, void *context, + bool as_text=false, + bool fail_on_read_problem=true); /** read specified text file using pool, if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK */ char *file_read_text(Pool& pool, const String& file_spec, - bool fail_on_read_problem=true); + bool fail_on_read_problem=true, + Hash *params=0, Hash** out_fields=0); /** read specified file using pool, if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK */ bool file_read(Pool& pool, const String& file_spec, void*& data, size_t& size, bool as_text, - bool fail_on_read_problem=true, - size_t offset=0, size_t limit=0); + Hash *params=0, Hash** out_fields=0, + bool fail_on_read_problem=true); + +typedef void (*File_write_action)(int f, void *context); /** lock specified file exclusively, @@ -117,7 +141,7 @@ bool file_read(Pool& pool, const String& */ bool file_write_action_under_lock( const String& file_spec, - const char *action_name, void (*action)(int, void *), void *context=0, + const char *action_name, File_write_action action, void *context, bool as_text=false, bool do_append=false, bool do_block=true, @@ -144,6 +168,8 @@ bool file_delete(const String& file_spec */ void file_move(const String& old_spec, const String& new_spec); +bool entry_exists(const char *fname, struct stat *afinfo=0); +bool entry_exists(const String& file_spec); bool file_readable(const String& file_spec); bool dir_readable(const String& file_spec); String *file_readable(const String& path, const String& name);