2
* Copyright (c) 2002 Robert Collins.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* A copy of the GNU General Public License can be found at
12
* Written by Robert Collins <robertc@hotmail.com>
16
#include "FileSystemComposite.h"
17
#include "Directory.h"
19
#include <sys/types.h>
25
FileSystemComposite::CreateFromPath (string const &path)
29
int statrv = lstat(path.c_str(), &statBuf);
33
/* FIXME: feed metadata into the composite constructors */
34
if (S_ISDIR(statBuf.st_mode))
35
return new Directory (path, statBuf.st_mode);
37
if (S_ISREG(statBuf.st_mode))
38
return new File (path, false, statBuf.st_mode);
40
if (S_ISLNK(statBuf.st_mode))
41
/* TODO: examine having a symlink child of File */
42
return new File (path, true, statBuf.st_mode);
44
throw (string) "FileSystemComposite::CreateFromPath: unsupported file type encountered";
48
FileSystemComposite::Exists (string const &aPath)
52
int statrv = stat(aPath.c_str(), &statBuf);
55
throw (string) "Could not stat '" + aPath + "'.";