--- parser3/src/main/pa_common.C 2001/03/28 13:21:30 1.35 +++ parser3/src/main/pa_common.C 2001/04/03 17:01:03 1.39 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_common.C,v 1.35 2001/03/28 13:21:30 paf Exp $ + $Id: pa_common.C,v 1.39 2001/04/03 17:01:03 paf Exp $ */ #include "pa_config_includes.h" @@ -53,7 +53,7 @@ char *file_read_text(Pool& pool, const S bool file_read(Pool& pool, const String& file_spec, void*& data, size_t& size, bool as_text, bool fail_on_read_problem) { - char *fname=file_spec.cstr(); + char *fname=file_spec.cstr(String::UL_FILE_NAME); int f; struct stat finfo; @@ -94,12 +94,13 @@ bool file_read(Pool& pool, const String& return false; } +/// @test mkdirs void file_write(Pool& pool, const String& file_spec, const void *data, size_t size, bool as_text/*, bool exclusive*/) { - char *fname=file_spec.cstr(); + char *fname=file_spec.cstr(String::UL_FILE_NAME); int f; if(access(fname, F_OK)!=0) {/*no*/ if((f=open(fname, O_WRONLY|O_CREAT|_O_BINARY, 0666))>0) @@ -131,14 +132,14 @@ void file_write(Pool& pool, } void file_delete(Pool& pool, const String& file_spec) { - if(unlink(file_spec.cstr())!=0) + if(unlink(file_spec.cstr(String::UL_FILE_NAME))!=0) PTHROW(0, 0, &file_spec, "unlink failed: %s (#%d)", strerror(errno), errno); } bool file_readable(const String& file_spec) { - return access(file_spec.cstr(), R_OK)==0; + return access(file_spec.cstr(String::UL_FILE_NAME), R_OK)==0; } char *getrow(char **row_ref, char delim) { @@ -182,6 +183,7 @@ char *rsplit(char *string, char delim) { return NULL; } +/// @todo less stupid type detection char *format(Pool& pool, double value, char *fmt) { char *result=(char *)pool.malloc(MAX_NUMBER); if(fmt) @@ -198,14 +200,14 @@ char *format(Pool& pool, double value, c return result; } -size_t stdout_write(const char *buf, size_t size) { +size_t stdout_write(const void *buf, size_t size) { #ifdef WIN32 do{ int chunk_written=fwrite(buf, 1, min(8*0x400, size), stdout); if(chunk_written<=0) break; size-=chunk_written; - buf+=chunk_written; + buf=((const char*)buf)+chunk_written; } while(size>0); return size; @@ -259,7 +261,8 @@ static void append_attribute_subattribut // ...; charset=windows1251 String *string=static_cast(info); - string->APPEND_CONST("; "); + if(string->size()) + string->APPEND_CONST("; "); string->append(akey, String::UL_HEADER, true); string->APPEND_CONST("="); string->append(static_cast(avalue)->as_string(),