Added a test for MUIA_Listview_SelectChange.
[AROS.git] / rom / filesys / pfs3 / fs / CheckAccess.c
blobd0236201f84b212b0d2cb2c287b08e6f4a9f1ad2
1 /* $Id$ */
2 /* $Log: CheckAccess.c $
3 * Revision 1.1 1996/01/03 10:18:38 Michiel
4 * Initial revision
5 * */
7 // own includes
8 #include "blocks.h"
9 #include "struct.h"
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)
22 #if DELDIR
23 /* delfiles cannot be altered */
24 if (IsDelFile (file->le.info))
26 *error = ERROR_WRITE_PROTECTED;
27 return FALSE;
29 #endif
31 /* test on type */
32 if (!IsFile(file->le.info))
34 *error = ERROR_OBJECT_WRONG_TYPE;
35 return FALSE;
38 /* volume must be or become currentvolume */
39 if (!CheckVolume(file->le.volume, 1, error, g))
40 return FALSE;
42 /* check reserved area lock */
43 if (ReservedAreaIsLocked)
45 *error = ERROR_DISK_FULL;
46 return FALSE;
49 return TRUE;
53 /* fileaccess that writes to a file
55 BOOL CheckWriteAccess(fileentry_t *file, SIPTR *error, globaldata *g)
58 if (!CheckChangeAccess(file, error, g))
59 return FALSE;
61 if (file->le.info.file.direntry->protection & FIBF_WRITE)
63 *error = ERROR_WRITE_PROTECTED;
64 return FALSE;
67 return TRUE;
71 /* fileaccess that reads from a file
73 BOOL CheckReadAccess(fileentry_t *file, SIPTR *error, globaldata *g)
75 *error = 0;
77 /* Test on read-protection, type and volume */
78 #if DELDIR
79 if (!IsDelFile(file->le.info))
81 #endif
82 if (!IsFile(file->le.info))
84 *error = ERROR_OBJECT_WRONG_TYPE;
85 return FALSE;
88 if (file->le.info.file.direntry->protection & FIBF_READ)
90 *error = ERROR_READ_PROTECTED;
91 return FALSE;
93 #if DELDIR
95 #endif
97 if (!CheckVolume(file->le.volume, 0, error, g))
98 return FALSE;
100 return TRUE;
103 /* check on operate access (like Seek)
105 BOOL CheckOperateFile(fileentry_t *file, SIPTR *error, globaldata *g)
107 *error = 0;
109 /* test on type */
110 #if DELDIR
111 if (!IsDelFile(file->le.info) && !IsFile(file->le.info))
112 #else
113 if (!IsFile(file->le.info))
114 #endif
116 *error = ERROR_OBJECT_WRONG_TYPE;
117 return FALSE;
120 /* volume must be or become currentvolume */
121 if (!CheckVolume(file->le.volume, 0, error, g))
122 return FALSE;
124 return TRUE;