~ubuntu-branches/ubuntu/quantal/config-manager/quantal

« back to all changes in this revision

Viewing changes to src/Directory.h

  • Committer: Bazaar Package Importer
  • Author(s): Anand Kumria
  • Date: 2004-07-19 22:27:50 UTC
  • mto: (3.1.1 dapper)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040719222750-sztqdj1aoj2r6frr
Tags: upstream-0.1p83
ImportĀ upstreamĀ versionĀ 0.1p83

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2002 Robert Collins.
 
3
 *
 
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.
 
8
 *
 
9
 *     A copy of the GNU General Public License can be found at
 
10
 *     http://www.gnu.org/
 
11
 *
 
12
 * Written by Robert Collins <robertc@hotmail.com>
 
13
 *
 
14
 */
 
15
 
 
16
#ifndef _DIRECTORY_H_
 
17
#define _DIRECTORY_H_
 
18
 
 
19
#include "FileSystemComposite.h"
 
20
#include "Path.h"
 
21
#include <string>
 
22
#include <sys/types.h>
 
23
#include <dirent.h>
 
24
 
 
25
using namespace std;
 
26
 
 
27
class Directory : public FileSystemComposite
 
28
{
 
29
public:
 
30
  /* True if aPath is the name of a directory.
 
31
     False if the path does not exist, or it is not a directory
 
32
     */
 
33
  static bool Exists(string const &aPath);
 
34
  static void Create(string const &aPath);
 
35
  static void RemoveRecursive(Path const &aPath);
 
36
  static string CurrentDirectory();
 
37
  
 
38
  Directory (string const &aPath, mode_t const &protection = mode_t());
 
39
  ~Directory();
 
40
 
 
41
  void visit (FileSystemVisitor &);
 
42
  Path const &path() const { return _path; }
 
43
 
 
44
  /* make private? */
 
45
  mode_t mode;
 
46
  
 
47
private:
 
48
  static void CreateFrom (string const &basePath, string const &aPath);
 
49
  static void StripSlash (string &aString);
 
50
  /* Don't allow copying */
 
51
  Directory &operator= (Directory const &);
 
52
  Directory (Directory const &);
 
53
 
 
54
  void visitEntry (struct dirent *entry, FileSystemVisitor &theVisitor);
 
55
 
 
56
  DIR *theDir;
 
57
  Path _path;
 
58
};
 
59
 
 
60
#endif // _DIRECTORY_H_