xref: /haiku/headers/build/os/storage/Statable.h (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //---------------------------------------------------------------------
5 /*!
6 	\file Statable.h
7 	BStatable interface declaration.
8 */
9 
10 #ifndef _STATABLE_H
11 #define _STATABLE_H
12 
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <SupportDefs.h>
16 
17 #ifdef USE_OPENBEOS_NAMESPACE
18 namespace OpenBeOS {
19 #endif // USE_OPENBEOS_NAMESPACE
20 
21   struct node_ref;
22   class BVolume;
23 
24 
25 	//! BStatable - A nice C++ wrapper to <code>stat()</code>
26 	/*! A purly abstract class which provieds an expenive, but convenet
27 	 * C++ wrapper to the posix <code>\sa stat()</code> command.
28 	 *
29 	 * @see <a href="http://www.opensource.org/licenses/mit-license.html">MIT</a>
30 	 * @author <a href="mailto:mrmlk@users.sf.net"> Michael Lloyd Lee </a>
31 	 * @author Be Inc
32 	 * @version 0
33 	 */
34 class BStatable {
35 public:
36 	virtual status_t GetStat(struct stat *st) const = 0;
37 
38 	bool IsFile() const;
39 	bool IsDirectory() const;
40 	bool IsSymLink() const;
41 
42 	status_t GetNodeRef(node_ref *ref) const;
43 
44 	status_t GetOwner(uid_t *owner) const;
45 	status_t SetOwner(uid_t owner);
46 
47 	status_t GetGroup(gid_t *group) const;
48 	status_t SetGroup(gid_t group);
49 
50 	status_t GetPermissions(mode_t *perms) const;
51 	status_t SetPermissions(mode_t perms);
52 
53 	status_t GetSize(off_t *size) const;
54 
55 	status_t GetModificationTime(time_t *mtime) const;
56 	status_t SetModificationTime(time_t mtime);
57 
58 	status_t GetAccessTime(time_t *atime) const;
59 	status_t SetAccessTime(time_t atime);
60 
61 	status_t GetVolume(BVolume *vol) const;
62 
63   private:
64 
65 	friend class BEntry;
66 	friend class BNode;
67 
68 	virtual	void _OhSoStatable1(); 	//< FBC
69 	virtual	void _OhSoStatable2(); 	//< FBC
70 	virtual	void _OhSoStatable3(); 	//< FBC
71 	uint32 _ohSoData[4]; 			//< FBC
72 
73 	virtual	status_t set_stat(struct stat &st, uint32 what) = 0;
74 };
75 
76 #ifdef USE_OPENBEOS_NAMESPACE
77 }
78 #endif // USE_OPENBEOS_NAMESPACE
79 
80 #endif // _STATABLE_H
81 
82 
83