2 /* $Log: CheckAccess.c $
3 * Revision 1.1 1996/01/03 10:18:38 Michiel
10 #include "disk_protos.h"
11 #include "allocation_protos.h"
12 #include "volume_protos.h"
13 #include "directory_protos.h"
14 #include "anodes_protos.h"
15 #include "update_protos.h"
16 #include "checkaccess_protos.h"
18 /* fileaccess that changes a file but doesn't write to it
20 BOOL
CheckChangeAccess(fileentry_t
*file
, SIPTR
*error
, globaldata
*g
)
23 /* delfiles cannot be altered */
24 if (IsDelFile (file
->le
.info
))
26 *error
= ERROR_WRITE_PROTECTED
;
32 if (!IsFile(file
->le
.info
))
34 *error
= ERROR_OBJECT_WRONG_TYPE
;
38 /* volume must be or become currentvolume */
39 if (!CheckVolume(file
->le
.volume
, 1, error
, g
))
42 /* check reserved area lock */
43 if (ReservedAreaIsLocked
)
45 *error
= ERROR_DISK_FULL
;
53 /* fileaccess that writes to a file
55 BOOL
CheckWriteAccess(fileentry_t
*file
, SIPTR
*error
, globaldata
*g
)
58 if (!CheckChangeAccess(file
, error
, g
))
61 if (file
->le
.info
.file
.direntry
->protection
& FIBF_WRITE
)
63 *error
= ERROR_WRITE_PROTECTED
;
71 /* fileaccess that reads from a file
73 BOOL
CheckReadAccess(fileentry_t
*file
, SIPTR
*error
, globaldata
*g
)
77 /* Test on read-protection, type and volume */
79 if (!IsDelFile(file
->le
.info
))
82 if (!IsFile(file
->le
.info
))
84 *error
= ERROR_OBJECT_WRONG_TYPE
;
88 if (file
->le
.info
.file
.direntry
->protection
& FIBF_READ
)
90 *error
= ERROR_READ_PROTECTED
;
97 if (!CheckVolume(file
->le
.volume
, 0, error
, g
))
103 /* check on operate access (like Seek)
105 BOOL
CheckOperateFile(fileentry_t
*file
, SIPTR
*error
, globaldata
*g
)
111 if (!IsDelFile(file
->le
.info
) && !IsFile(file
->le
.info
))
113 if (!IsFile(file
->le
.info
))
116 *error
= ERROR_OBJECT_WRONG_TYPE
;
120 /* volume must be or become currentvolume */
121 if (!CheckVolume(file
->le
.volume
, 0, error
, g
))