filesystem._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * $Id: filesystem.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit Filesystem.Base;
20 inherit "/modules/filepath";
21 #include <database.h>
22 //! Basic filesystem support. Uses environment/inventory relation in order
23 //! to find an object by a given URL.
24 class filesystem : public filepath{
25 public:
26 
27 
28 
29 
30 
31 
32 // filesystem stuff
33  object cwdCont = _ROOTROOM;
34 
35 object cd(string|object cont)
36 {
37  if ( stringp(cont) )
38  cont = path_to_object(cont);
39  if ( !objectp(cont) )
40  return 0;
41  cwdCont = cont;
42 }
43 
44 string cwd()
45 {
46  return object_to_filename(cwdCont);
47 }
48 
49 array get_dir(void|string directory, void|string|array glob)
50 {
51  object cont;
52  if ( stringp(directory) )
53  cont = path_to_object(directory);
54  else
55  cont = cwdCont;
56  array files = ({ });
57  foreach ( cont->get_inventory(), object obj )
58  files += ({ obj->get_identifier() });
59  return files;
60 }
61 
62 object open(string file)
63 {
64  object cont;
65  if ( file[0] != '/' )
66  cont = cwdCont;
67  else
68  cont = _ROOTROOM;
69 
70  object doc = resolve_path(cont, file);
71  if ( !objectp(doc) )
72  error("Unable to resolve " + file + "\nCWD="+cwd()+"\n");
73  Stdio.FakeFile f = Stdio.FakeFile(doc->get_content());
74  return f;
75 }
76 
77 
78 
79 
80 
81 };