Annotation of parser3/src/classes/file.C, revision 1.4
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
5:
1.4 ! paf 6: $Id: file.C,v 1.3 2001/03/19 21:39:30 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_request.h"
10: #include "_file.h"
11: #include "pa_vfile.h"
12:
13: // global var
14:
1.3 paf 15: VStateless_class *file_class;
1.1 paf 16:
17: // methods
18:
19: static void _save(Request& r, const String& method_name, Array *params) {
1.4 ! paf 20: Pool& pool=r.pool();
1.1 paf 21: Value *vfile_name=static_cast<Value *>(params->get(0));
22: // forcing
1.4 ! paf 23: // ^save[this body type]
! 24: r.fail_if_junction_(true, *vfile_name,
! 25: method_name, "file name must not be junction");
! 26:
! 27: // forcing untaint language
! 28: String lfile_name(pool);
! 29: lfile_name.append(vfile_name->as_string(),
! 30: String::Untaint_lang::FILE_NAME, true);
! 31:
! 32: static_cast<VFile *>(r.self)->save(r.absolute(lfile_name.cstr()));
1.1 paf 33: }
34:
35: // initialize
36:
1.3 paf 37: void initialize_file_class(Pool& pool, VStateless_class& vclass) {
1.1 paf 38: // ^save[file-name]
39: vclass.add_native_method("save", _save, 1, 1);
40: }
E-mail: