~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to tads/tads3/lib/file.t

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#charset "us-ascii"
 
2
 
 
3
/*
 
4
 *   Copyright (c) 2001, 2006 Michael J. Roberts
 
5
 *   
 
6
 *   This file is part of TADS 3.
 
7
 *   
 
8
 *   This module defines classes and constants related to the File
 
9
 *   intrinsic class.  In particular, this module defines the Exception
 
10
 *   subclasses thrown by File methods.  
 
11
 */
 
12
 
 
13
#include <tads.h>
 
14
#include <file.h>
 
15
 
 
16
 
 
17
/* ------------------------------------------------------------------------ */
 
18
/*
 
19
 *   File Exception classes.  All File exceptions derive from FileException,
 
20
 *   to allow for generic 'catch' clauses which catch any file-related
 
21
 *   error.  
 
22
 */
 
23
class FileException: Exception
 
24
    displayException() { "file error"; }
 
25
;
 
26
 
 
27
/*
 
28
 *   File not found - this is thrown when attempting to open a file for
 
29
 *   reading and the file doesn't exist or can't be opened (because the user
 
30
 *   doesn't have privileges to read the file, or the file is already being
 
31
 *   used by another user, for example).
 
32
 */
 
33
class FileNotFoundException: FileException
 
34
    displayException() { "file not found"; }
 
35
;
 
36
 
 
37
/*
 
38
 *   File creation error - this is thrown when attempting to open a file for
 
39
 *   writing and the file can't be created; this can happen because the disk
 
40
 *   or the directory is full, due to privilege failures, or due to sharing
 
41
 *   violations, among other reasons.  
 
42
 */
 
43
class FileCreationException: FileException
 
44
    displayException() { "cannot create file"; }
 
45
;
 
46
 
 
47
/*
 
48
 *   File cannot be opened - this is thrown when attempting to open a file
 
49
 *   for reading and writing but the file can't be opened.  This can happen
 
50
 *   for numerous reasons: sharing violations, privilege failures, lack of
 
51
 *   space on the disk or in the directory. 
 
52
 */
 
53
class FileOpenException: FileException
 
54
    displayException() { "cannot open file"; }
 
55
;
 
56
 
 
57
/*
 
58
 *   File synchronization exception.  This is thrown when an operation
 
59
 *   (such as a read or write) is attempted during normal execution on a
 
60
 *   file object that was originally opened during pre-initialization.  A
 
61
 *   file object created during pre-initialization can't be used to access
 
62
 *   the file during ordinary execution, since the state of the external
 
63
 *   file might have changed since the pre-init session ended.  In such
 
64
 *   cases, a new file object must be created instead.  
 
65
 */
 
66
class FileSyncException: FileException
 
67
    displayException() { "file synchronization error"; }
 
68
;
 
69
 
 
70
/*
 
71
 *   File closed - this is thrown when an operation is attempted on a file
 
72
 *   that has already been explicitly closed. 
 
73
 */
 
74
class FileClosedException: FileException
 
75
    displayException() { "operation attempted on closed file"; }
 
76
;
 
77
 
 
78
/*
 
79
 *   File I/O exception - this is thrown when a read or write operation on a
 
80
 *   file fails.  This can indicate, for example, that the device containing
 
81
 *   the file is full, or that a physical media error occurred.  
 
82
 */
 
83
class FileIOException: FileException
 
84
    displayException() { "file I/O error"; }
 
85
;
 
86
 
 
87
/*
 
88
 *   File mode error - this is thrown when an attempted operation is
 
89
 *   incompatible with the file's mode.  This is thrown under these
 
90
 *   conditions:
 
91
 *   
 
92
 *   - writing to a file opened for read-only access
 
93
 *.  - reading from a file opened for write-only access
 
94
 *.  - calling readFile or writeFile on a raw-mode file
 
95
 *.  - calling readBytes or writeBytes on a non-raw-mode file 
 
96
 */
 
97
class FileModeException: FileException
 
98
    displayException() { "invalid file mode"; }
 
99
;
 
100
 
 
101
/*
 
102
 *   File safety error - this is thrown when an attempted "open" operation
 
103
 *   is prohibited by the current file safety level set by the user. 
 
104
 */
 
105
class FileSafetyException: FileException
 
106
    displayException()
 
107
    {
 
108
        "file operation prohibited by user-specified file safety level";
 
109
    }
 
110
;
 
111
 
 
112
 
 
113
/* export the file exceptions for use by the intrinsic class */
 
114
export FileNotFoundException 'File.FileNotFoundException';
 
115
export FileCreationException 'File.FileCreationException';
 
116
export FileOpenException 'File.FileOpenException';
 
117
export FileIOException 'File.FileIOException';
 
118
export FileSyncException 'File.FileSyncException';
 
119
export FileClosedException 'File.FileClosedException';
 
120
export FileModeException 'File.FileModeException';
 
121
export FileSafetyException 'File.FileSafetyException';
 
122