Annotation of parser3/src/classes/file.C, revision 1.7

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.7     ! paf         6:        $Id: file.C,v 1.6 2001/03/24 15:57:57 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: 
1.7     ! paf        19: /// @test mkdirs
1.1       paf        20: static void _save(Request& r, const String& method_name, Array *params) {
1.4       paf        21:        Pool& pool=r.pool();
1.1       paf        22:        Value *vfile_name=static_cast<Value *>(params->get(0));
                     23:        // forcing
1.4       paf        24:        // ^save[this body type]
                     25:        r.fail_if_junction_(true, *vfile_name, 
                     26:                method_name, "file name must not be junction");
                     27: 
                     28:        // forcing untaint language
                     29:        String lfile_name(pool);
                     30:        lfile_name.append(vfile_name->as_string(),
1.5       paf        31:                String::UL_FILE_NAME, true);
1.7     ! paf        32: 
        !            33:        // save
        !            34:        static_cast<VFile *>(r.self)->save(r.absolute(lfile_name));
        !            35: }
        !            36: 
        !            37: static void _delete(Request& r, const String& method_name, Array *params) {
        !            38:        Pool& pool=r.pool();
        !            39:        Value *vfile_name=static_cast<Value *>(params->get(0));
        !            40:        // forcing
        !            41:        // ^delete[this body type]
        !            42:        r.fail_if_junction_(true, *vfile_name, 
        !            43:                method_name, "file name must not be junction");
        !            44: 
        !            45:        // forcing untaint language
        !            46:        String lfile_name(pool);
        !            47:        lfile_name.append(vfile_name->as_string(),
        !            48:                String::UL_FILE_NAME, true);
1.4       paf        49:                
1.7     ! paf        50:        // unlink
        !            51:        file_delete(pool, r.absolute(lfile_name));
1.1       paf        52: }
                     53: 
                     54: // initialize
                     55: 
1.3       paf        56: void initialize_file_class(Pool& pool, VStateless_class& vclass) {
1.1       paf        57:        // ^save[file-name]
                     58:        vclass.add_native_method("save", _save, 1, 1);
1.7     ! paf        59: 
        !            60:        // ^delete[file-name]
        !            61:        vclass.add_native_method("delete", _delete, 1, 1);
1.1       paf        62: }

E-mail: