|
|
| version 1.67, 2001/12/15 21:28:17 | version 1.73, 2002/03/25 11:55:26 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b file parser class. | Parser: @b file parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| Line 61 static void _save(Request& r, const Stri | Line 61 static void _save(Request& r, const Stri |
| } | } |
| static void _delete(Request& r, const String&, MethodParams *params) { | static void _delete(Request& r, const String&, MethodParams *params) { |
| Pool& pool=r.pool(); | |
| Value& vfile_name=params->as_no_junction(0, "file name must not be code"); | Value& vfile_name=params->as_no_junction(0, "file name must not be code"); |
| // unlink | // unlink |
| file_delete(pool, r.absolute(vfile_name.as_string())); | file_delete(r.absolute(vfile_name.as_string())); |
| } | } |
| static void _move(Request& r, const String&, MethodParams *params) { | static void _move(Request& r, const String&, MethodParams *params) { |
| Pool& pool=r.pool(); | |
| Value& vfrom_file_name=params->as_no_junction(0, "from file name must not be code"); | Value& vfrom_file_name=params->as_no_junction(0, "from file name must not be code"); |
| Value& vto_file_name=params->as_no_junction(1, "to file name must not be code"); | Value& vto_file_name=params->as_no_junction(1, "to file name must not be code"); |
| // move | // move |
| file_move(pool, | file_move( |
| r.absolute(vfrom_file_name.as_string()), | r.absolute(vfrom_file_name.as_string()), |
| r.absolute(vto_file_name.as_string())); | r.absolute(vto_file_name.as_string())); |
| } | } |
| Line 238 static void _exec_cgi(Request& r, const | Line 236 static void _exec_cgi(Request& r, const |
| //out.APPEND_CONST("content-type:text/plain\nheader:test-header\n\ntest-body"); | //out.APPEND_CONST("content-type:text/plain\nheader:test-header\n\ntest-body"); |
| //out<<in; | //out<<in; |
| String& err=*new(pool) String(pool); | String& err=*new(pool) String(pool); |
| int status=pa_exec(script_name, &env, argv, in, out, err); | int status=pa_exec(false/*forced_allow*/, script_name, &env, argv, in, out, err); |
| VFile& self=*static_cast<VFile *>(r.self); | VFile& self=*static_cast<VFile *>(r.self); |
| Line 373 static void _list(Request& r, const Stri | Line 371 static void _list(Request& r, const Stri |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| #ifndef DOXYGEN | |
| struct Lock_execute_body_info { | |
| Request *r; | |
| Value *body_code; | |
| }; | |
| #endif | |
| static void lock_execute_body(int , void *context) { | |
| Lock_execute_body_info& info=*static_cast<Lock_execute_body_info *>(context); | |
| // execute body | |
| info.r->write_assign_lang(info.r->process(*info.body_code)); | |
| }; | |
| static void _lock(Request& r, const String& method_name, MethodParams *params) { | |
| const String& file_spec=r.absolute(params->as_string(0, "file name must be string")); | |
| Value& body_code=params->as_junction(1, "body must be code"); | |
| Lock_execute_body_info info={&r, &body_code}; | |
| file_write_action_under_lock(file_spec, "lock", lock_execute_body, &info); | |
| } | |
| // constructor | // constructor |
| MFile::MFile(Pool& apool) : Methoded(apool) { | MFile::MFile(Pool& apool) : Methoded(apool) { |
| Line 413 MFile::MFile(Pool& apool) : Methoded(apo | Line 431 MFile::MFile(Pool& apool) : Methoded(apo |
| // ^file:list[path][regexp] | // ^file:list[path][regexp] |
| add_native_method("list", Method::CT_STATIC, _list, 1, 2); | add_native_method("list", Method::CT_STATIC, _list, 1, 2); |
| // ^file:lock[path]{code} | |
| add_native_method("lock", Method::CT_STATIC, _lock, 2, 2); | |
| } | } |
| // global variable | // global variable |