Ticket #424: file-creation-mode.diff

File file-creation-mode.diff, 3.1 KB (added by felix winkelmann, 13 years ago)

implementation of `file-creation-mode' (untested)

  • manual/Unit

    diff --git a/manual/Unit posix b/manual/Unit posix
    index 59861be..1a550c3 100644
    a b the user- and group-ids {{UID}} and {{GID}} (which should be 
    529529exact integers) using the {{chown()}} system call.
    530530
    531531
     532==== file-creation-mode
     533
     534<procedure>(file-creation-mode MODE)</procedure>
     535
     536Returns the initial file permissions used for newly created files
     537(as with {{umask(2)}}. You can set the mode by executing
     538
     539  (set! (file-creation-mode) MODE)
     540
     541where {{MODE}} is a bitwise combination of one or more of
     542the {{perm/...}} flags.
     543
     544
    532545=== Processes
    533546
    534547==== current-process-id
    always returns {{0}}, {{0}}. 
    12121225; {{file-close}} : {{close}}
    12131226; {{file-access-time}} : {{stat}}
    12141227; {{file-change-time}} : {{stat}}
     1228; {{file-creation-mode}} : {{umask}}
    12151229; {{file-modification-time}} : {{stat}}
    12161230; {{file-execute-access?}} : {{access}}
    12171231; {{file-open}} : {{open}}
  • posix-common.scm

    diff --git a/posix-common.scm b/posix-common.scm
    index 8961768..bd188fc 100644
    a b EOF 
    361361                         (follow-symlinks #t))
    362362            (##sys#find-files dir test action seed limit follow-symlinks dotfiles 'find-files))
    363363          args))))
     364
     365
     366;;; umask
     367
     368(define file-creation-mode
     369  (getter-with-setter
     370   (lambda ()
     371     (let ((um (##core#inline "C_umask" 0)))
     372       (##core#inline "C_umask" um)
     373       um))
     374   (lambda (um)
     375     (##core#inline "C_umask" um))
     376   "(file-creation-mode mode)"))
  • posix.import.scm

    diff --git a/posix.import.scm b/posix.import.scm
    index 2118ccb..3414b79 100644
    a b  
    9999   fifo?
    100100   file-access-time
    101101   file-change-time
     102   file-creation-mode
    102103   file-close
    103104   file-control
    104105   file-execute-access?
  • posixunix.scm

    diff --git a/posixunix.scm b/posixunix.scm
    index 847394f..a9fa2f8 100644
    a b static C_TLS struct stat C_statbuf; 
    199199#define C_test_access(fn, m)     C_fix(access((char *)C_data_pointer(fn), C_unfix(m)))
    200200#define C_close(fd)         C_fix(close(C_unfix(fd)))
    201201#define C_sleep             sleep
     202#define C_umask(m)          C_fix(umask(C_unfix(m)))
    202203
    203204#define C_lstat(fn)         C_fix(lstat((char *)C_data_pointer(fn), &C_statbuf))
    204205
  • posixwin.scm

    diff --git a/posixwin.scm b/posixwin.scm
    index 0d012da..f4de4ad 100644
    a b C_free_arg_string(char **where) { 
    304304
    305305#define C_flushall()        C_fix(_flushall())
    306306
     307#define C_umask(m)          C_fix(_umask(C_unfix(m)))
     308
    307309#define C_ctime(n)          (C_secs = (n), ctime(&C_secs))
    308310
    309311#define C_tm_set_08(v) \
  • types.db

    diff --git a/types.db b/types.db
    index fc10fbc..9bfff61 100644
    a b  
    776776(file-change-time (procedure file-change-time ((or string fixnum)) number))
    777777(file-close (procedure file-close (fixnum) undefined))
    778778(file-control (procedure file-control (fixnum fixnum #!optional fixnum) fixnum))
     779(file-creation-mode (procedure file-creation-mode () fixnum))
    779780(file-execute-access? (procedure file-execute-access? (string) boolean))
    780781(file-link (procedure file-link (string string) undefined))
    781782(file-lock (procedure file-lock (port #!optional fixnum *) (struct lock)))