usb: getting string descriptors, minor improvements
[quarnos.git] / resources / file.h
blob7c8a5a7e811c8b679e62f2de0f6602e8f0996289
1 /* Quarn OS
3 * File class
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef _FILE_H_
24 #define _FILE_H_
26 #include "libs/date.h"
27 #include "libs/string.h"
28 #include "libs/pointer.h"
29 #include "libs/list.h"
30 #include "libs/buffer.h"
31 #include "manes/cds/component.h"
33 #include "prvl.h"
35 namespace resources {
36 class fs;
37 class file : public manes::cds::component {
38 public:
39 typedef enum {
40 attr_hidden = 1,
41 attr_system = 2
42 } attrib;
43 typedef struct {
44 date creation_d;
45 time creation_t;
47 prvl access;
48 attrib attributes;
49 bool directory;
51 int size;
52 } file_meta;
54 protected:
55 p<fs> filesystem;
57 string file_name;
59 file_meta metadata;
61 /* Data loaded on demand */
62 mutable p<buffer> buf;
64 list<p<file> > children;
65 public:
66 void set(string, p<fs>);
68 string get_name() const { return file_name; }
69 unsigned int get_size() const { return metadata.size; }
70 buffer get_buffer();
72 void seek(int);
73 void read(buffer &);
74 void write(const buffer &);
76 operator const string();
78 void save() const;
79 void remove();
80 p<file> copy(string) const;
82 static void register_type();
86 #endif