;;; -*-Scheme-*-
;;;
-;;; $Id: imail-file.scm,v 1.12 2000/05/02 21:42:07 cph Exp $
+;;; $Id: imail-file.scm,v 1.13 2000/05/02 22:02:33 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
;;;; Folder
(define-class <file-folder> (<folder>)
- (messages define standard initial-value '())
+ (messages define standard
+ accessor %file-folder-messages
+ initial-value 'UNKNOWN)
(modification-time define standard initial-value #f))
+(define (file-folder-messages folder)
+ (if (eq? 'UNKNOWN (%file-folder-messages folder))
+ (%revert-folder folder))
+ (%file-folder-messages folder))
+
(define (file-folder-pathname folder)
(file-url-pathname (folder-url folder)))
(folder-not-modified! folder))
(define-method %close-folder ((folder <file-folder>))
- folder
- unspecific)
+ (without-interrupts
+ (lambda ()
+ (let ((messages (%file-folder-messages folder)))
+ (if (not (eq? 'UNKNOWN messages))
+ (begin
+ (set-file-folder-messages! folder 'UNKNOWN)
+ (for-each detach-message messages)))))))
(define-method %folder-valid? ((folder <file-folder>))
(file-exists? (file-folder-pathname folder)))
(set-message-index! message 0)
(list message)))))
(message-modified! message)))))
-
+\f
(define-method expunge-deleted-messages ((folder <file-folder>))
(without-interrupts
(lambda ()
(loop (cdr messages)
(fix:+ index 1)
(cons (car messages) messages*))))))))
-\f
+
(define-method search-folder ((folder <file-folder>) criteria)
(cond ((string? criteria)
(let ((n (folder-length folder)))
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-rmail.scm,v 1.19 2000/04/27 02:16:41 cph Exp $
+;;; $Id: imail-rmail.scm,v 1.20 2000/05/02 22:02:49 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
;;;; Server operations
(define-method %open-folder ((url <rmail-url>))
- (read-rmail-file (file-url-pathname url)))
+ (if (not (file-readable? (file-url-pathname url)))
+ (error:bad-range-argument url 'OPEN-FOLDER))
+ (make-rmail-folder url))
(define-method %new-folder ((url <rmail-url>))
+ (if (file-exists? (file-url-pathname url))
+ (error:bad-range-argument url 'NEW-FOLDER))
(let ((folder (make-rmail-folder url)))
+ (set-file-folder-messages! folder '())
(set-rmail-folder-header-fields!
folder
(compute-rmail-folder-header-fields folder))
\f
;;;; Read RMAIL file
-(define (read-rmail-file pathname)
- (let ((folder (make-rmail-folder (make-rmail-url pathname))))
- (%revert-folder folder)
- folder))
-
(define-method %revert-folder ((folder <rmail-folder>))
(call-with-binary-input-file (file-folder-pathname folder)
(lambda (port)
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-umail.scm,v 1.13 2000/05/02 21:09:08 cph Exp $
+;;; $Id: imail-umail.scm,v 1.14 2000/05/02 22:02:54 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
;;;; Server operations
(define-method %open-folder ((url <umail-url>))
- (read-umail-file (file-url-pathname url)))
+ (if (not (file-readable? (file-url-pathname url)))
+ (error:bad-range-argument url 'OPEN-FOLDER))
+ (make-umail-folder url))
(define-method %new-folder ((url <umail-url>))
+ (if (file-exists? (file-url-pathname url))
+ (error:bad-range-argument url 'NEW-FOLDER))
(let ((folder (make-umail-folder url)))
+ (set-file-folder-messages! folder '())
(save-folder folder)
folder))
+(define (read-umail-file pathname)
+ (make-umail-folder (make-umail-url pathname)))
+
;;;; Folder
(define-class (<umail-folder> (constructor (url))) (<file-folder>))
\f
;;;; Read unix mail file
-(define (read-umail-file pathname)
- (let ((folder (make-umail-folder (make-umail-url pathname))))
- (%revert-folder folder)
- folder))
-
(define-method %revert-folder ((folder <umail-folder>))
(set-file-folder-messages!
folder