stk/Lib/win32.stk

41 lines
1.3 KiB
Plaintext

;;;; win32.stk -- Win32 File sytem operations
;;;;
;;;; Copyright © 1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;; Permission to use, copy, modify, distribute,and license this
;;;; software and its documentation for any purpose is hereby granted,
;;;; provided that existing copyright notices are retained in all
;;;; copies and that this notice is included verbatim in any
;;;; distributions. No written agreement, license, or royalty fee is
;;;; required for any of the authorized uses.
;;;; This software is provided ``AS IS'' without express or implied
;;;; warranty.
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 12-Aug-1999 19:35
;;;; Last file update: 3-Sep-1999 19:56 (eg)
(require "regexp")
(define (decompose-file-name str)
(let* ((str (regexp-replace-all "\\\\" str "/"))
(pat "^([A-Za-z]:|)(/|)(.*)")
(repl "\\2 \"\\1\"\"\\3\"")
(s (regexp-replace pat str repl))
(p (open-input-string s)))
(let ((abs (read-char p))
(drv (read p))
(rest (read p)))
(append (list (if (char=? abs #\space) "." "/"))
(if (string=? drv "") '() (list drv))
(split-string rest "/")))))
(define (dirname str)
(regexp-replace "^([A-Za-z]:|)?(.*)[/\\](.+)$" str "\\1\\2"))
(define (basename str)
(regexp-replace "^([A-Za-z]:|)?(.*)[/\\](.*)$" str "\\3"))
(provide "win32")