[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Mar 19 19:56:28 2000 
Subject:sys_create_directory 
From:Aaron Sloman see text for reply 
Volume-ID:1000319.06 

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]

In a reply to Andrew Sayers, Steve Leave mentioned that a serious gap in
the mechanisms available (described in REF SYSUTIL) is the lack of a
pop11 procedure to create a directory.

Unix users can do something like this, which uses a mode of sysobey
that does not have to spawn a shell though it invokes sys_fork and
sysexecute:

    define sys_create_directory(name) -> succeeded;
        ;;; Attempt to create directory and return boolean success flag

        ;;; Convert file name, e.g. if it includes "~"
        lvars file = sysfileok(name);

        ;;; Check whether the file already exists, and mishap

        if sys_file_exists(file) then
            mishap('Cannot create directory', [^name 'exists'])
        endif;

        ;;; command to create directory
        lconstant mkdir = '/bin/mkdir';

        ;;; Run the mkdir command with appropriate args.
        ;;; See HELP SYSOBEY, REF SYSOBEY
        sysobey(mkdir, [^mkdir ^file]);
        sysisdirectory(file) -> succeeded;

    enddefine;

    sys_create_directory('~/new_directory')=>
    ** <true>

    sys_create_directory('~/new_directory')=>
    ;;; MISHAP - Cannot create directory
    ;;; INVOLVING:  '~/new_directory' 'exists'

C programmers could instead use external_load to invoke a
C program which creates the directory instead of calling
sysobey.

Note that sysfilemode can be used to change the protection of
the directory after you've created it. E.g. to make the above
directory unreadable by others:

    8:700 -> sysfilemode('new_directory');

Otherwise it will presumaly use your current value of umask.

Aaron
===
-- 
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (NB: Anti Spam address)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/