final move of files
[web.mtrack] / MTrack / SCMWorkingCopy.php
1 <?php
2 require_once 'MTrack/Changeset.php';
3
4 abstract class MTrackSCMWorkingCopy {
5   public $dir;
6
7   /** returns the root dir of the working copy */
8   function getDir() {
9     return $this->dir;
10   }
11
12   /** add a file to the working copy */
13   abstract function addFile($path);
14   /** removes a file from the working copy */
15   abstract function delFile($path);
16   /** commit changes that are pending in the working copy */
17   abstract function commit(MTrackChangeset $CS);
18   /** get an MTrackSCMFile representation of a file */
19   abstract function getFile($path);
20
21   /** enumerates files in a path in the working copy */
22   function enumFiles($path)
23   {
24     return scandir($this->dir . DIRECTORY_SEPARATOR . $path);
25   }
26
27   /** determines if a file exists in the working copy */
28   function file_exists($path)
29   {
30     return file_exists($this->dir . DIRECTORY_SEPARATOR . $path);
31   }
32
33   function __destruct()
34   {
35     if (strlen($this->dir) > 1) {
36       mtrack_rmdir($this->dir);
37     }
38   }
39 }