editing works basically
[phorkie.git] / src / Phorkie / Repository.php
index aeccc72f826107a2465a4a9d4023490bc6b83175..5273b60a99d5105dab3f1eb22e319304f915b7ed 100644 (file)
@@ -82,6 +82,9 @@ class Repository
         if ($base != $name) {
             throw new Exception('No directories supported for now');
         }
+        if ($name == '') {
+            throw new Exception_Input('Empty file name given');
+        }
         $path = $this->repoDir . '/' . $base;
         if (!is_readable($path)) {
             throw new Exception_Input('File does not exist');
@@ -89,6 +92,16 @@ class Repository
         return new File($path, $this);
     }
 
+    public function hasFile($name)
+    {
+        try {
+            $this->getFileByName($name);
+        } catch (Exception $e) {
+            return false;
+        }
+        return true;
+    }
+
     public function getDescription()
     {
         if (!is_readable($this->repoDir . '/.git/description')) {
@@ -97,6 +110,11 @@ class Repository
         return file_get_contents($this->repoDir . '/.git/description');
     }
 
+    public function setDescription($description)
+    {
+        file_put_contents($this->repoDir . '/.git/description', $description);
+    }
+
     /**
      * Get a link to the repository
      *