MTrack/SCM/WorkingCopy.php
[web.mtrack] / MTrack / SCM / WorkingCopy.php
1 <?php
2 require_once 'MTrack/Changeset.php';
3
4 abstract class MTrack_SCM_WorkingCopy {
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             require_once 'System.php';
37             echo "rmdir {$this->dir}";
38             
39             //System::rmdir($this->dir, '-r');
40         }
41     }
42     function generateTempDir()
43     {
44         $tn = tempnam(ini_get('session.save_path'),'mtrackworkingdir');
45         unlink($tn);
46         return $tn;
47         
48         
49     }
50     
51     
52 }