Index: pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php
===================================================================
--- pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 10)
+++ pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 11)
@@ -9,11 +9,5 @@
 class PrivateContent extends MX_Controller 
 {
-	
-	public function __construct() {
-		parent::__construct();
-	}
-	
-	public function getContent () {
-		$aryDir = array(
+	/* private $_aryDir = array(
 				0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
 				1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
@@ -25,6 +19,6 @@
 				7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
 		);
-		
-		$aryFile = array(
+	
+	private $_aryFile = array(
 				0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
 				1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
@@ -34,17 +28,36 @@
 				5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
 				5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
-		);
-		
-		$aryData = array('DIRECTORIES' => $aryDir, 'FILES' => $aryFile);
-		
+		); */
+	
+	public function __construct() {
+		parent::__construct();
+		$this->load->model('Directory_model', 'objDirectory', TRUE);
+	}
+	
+	public function getContent () {
+		$aryData = array('DIRECTORIES' =>  $this->objDirectory->getAllDirectory() , 'FILES' => $this->objDirectory->getAllFile());
 		echo json_encode($aryData);
 	}
 
 	public function createDir () {
+		$parentDir =  $this->input->post('parentID',TRUE);
+		$name =  $this->input->post('name',TRUE);
 		
+		if (!is_null($parentDir) && !is_null($name)) {
+			
+			$maxID = $this->objDirectory->getMaxID (true);
+			$aryDir = array('id' => (int)$maxID + 1, 'name' => $name, 'parentID' => $parentDir, 'maxID' => $maxID);
+			
+			$result = $this->objDirectory->createDir($aryDir);
+			echo json_encode($aryDir);
+		}
 	}
 	
 	public function deleteDir () {
+		$dirID =  $this->input->post('id',TRUE);
+		$delAllChild = $this->input->post('delallchild',TRUE);
 		
+		$aryChild = $this->objDirectory->getAllChild($dirID);
+		echo json_encode($aryChild);
 	}
 
Index: pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php
===================================================================
--- pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php	(revision 10)
+++ pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php	(revision 11)
@@ -9,8 +9,166 @@
 {
 
-	function __construct()
+	public function __construct()
 	{
 		// Call the Model constructor
 		parent::__construct();
 	}
+	
+	public function getAllDirectory () {
+		$dbFile = 'directory.db';
+		$h = fopen($dbFile, 'r');
+		$line = '';
+		$aryDir = array();
+		$aryField = array ('id', 'name', 'parentID');
+		
+		while (($line = fgets($h, 4096)) !== false) {
+			$aryTmp = explode(',', trim($line));
+			$aryDir[] = array_combine($aryField, $aryTmp);
+		}
+		if (!feof($h)) {
+			echo "Error: unexpected fgets() fail\n";
+		}
+		fclose($h);
+		
+		return $aryDir;
+	}
+	
+	public function getAllFile () {
+		$dbFile = 'file.db';
+		$h = fopen($dbFile, 'r');
+		$line = '';
+		$aryFile = array();
+		$aryField = array ('id', 'name', 'minetype', 'size', 'parentID');
+	
+		while (($line = fgets($h, 4096)) !== false) {
+			$aryTmp = explode(',', trim($line));
+			$aryFile[] = array_combine($aryField, $aryTmp);
+		}
+		if (!feof($h)) {
+			echo "Error: unexpected fgets() fail\n";
+		}
+		fclose($h);
+	
+		return $aryFile;
+	}
+	
+	public function createDir($aryDir) {
+		$dbFile = 'directory.db';
+		$aryField = array ('id', 'name', 'parentID');
+		$aryTmp = array();
+		$h = fopen($dbFile, 'a');
+		$line = '';
+		foreach ($aryField as $key => $field) {
+			$aryTmp[$field] = $aryDir[$field];
+		}
+		$line = implode(',',$aryTmp);
+		fwrite($h, $line."\n");
+		fclose($h);
+		return true;
+	}
+	
+	public function createFile($aryFile) {
+		$dbFile = 'file.db';
+		$aryField = array ('id', 'name', 'minetype', 'size', 'parentID');
+		$aryTmp = array();
+		$h = fopen($dbFile, 'a+');
+		$line = '';
+		foreach ($aryField as $key => $field) {
+			$aryTmp[$field] = $aryFile[$field];
+		}
+		$line = implode(',',$aryTmp);
+		fwrite($line."\n", $h);
+		fclose($h);
+		return true;
+	}
+	
+	public function deleteDir ($dirID, $delAllChild = FALSE) {
+		$dbFile = 'directory.db';
+		$dirList = $this->getAllDirectory();
+		
+		$lineNumber = 0;
+		
+		foreach ($dirList as $key => $dir) {
+			if ($dir[0] == $dirID) {
+				$lineNumber = $key;
+			}
+		}	
+		
+		//$aryChildDir =  
+		
+		if ($delAllChild) {
+			
+		}
+		
+		unset($dirList[$lineNumber]);
+		return $this->writeDB ($dbFile, $dirList);
+	}
+	
+	public function deleteFile ($fileID) {
+		$dbFile = 'file.db';
+		$fileList = $this->getAllFile();
+		
+		$lineNumber = 0;
+		
+		foreach ($fileList as $key => $file) {
+			if ($dir[0] == $dirID) {
+				$lineNumber = $key;
+			}
+		}
+		
+		unset($fileList[$lineNumber]);
+		return $this->writeDB ($dbFile, $fileList);
+	}
+	
+	public function getAllFileChild ($dirID) {
+		$fileList = $this->getAllFile();
+		$aryChild = array();
+		
+		$aryDirChild = $this->getAllDirChild($dirID);
+		
+	}
+	
+	public function getAllDirChild ($dirID) {
+		$dirList = $this->getAllDirectory();
+		$aryChild = array();
+		
+		foreach ($dirList as $key => $dir) {
+			if ($dir['parentID'] == $dirID) {
+				$aryChild[$dir['id']] = $dir;
+				
+				$aryChild[$dir['id']]['child'] = $this->getAllDirChild($dir['id']);
+				if (count($aryChild[$dir['id']]['child']) == 0) unset($aryChild[$dir['id']]['child']);
+			}
+		}
+		
+		return $aryChild;
+	}
+	
+	private function writeDB ($file, $aryDataSet, $flag = '') {
+		$flag = ($flag == 'append') ? 'a' : 'w';
+		
+		if (file_exists($file) && count($aryDataSet) > 0) {
+			$h = fopen ($file, $flag);
+			foreach ($aryDataSet as $key => $line) {
+				$line = implode(',',$aryTmp);
+				fwrite($line."\n", $h);
+			}
+			fclose ($h);
+			
+			return true;
+		}else {
+			return false;
+		}
+	}
+	
+	public function getMaxID($isDir) {
+		$list = $isDir = true ? $this->getAllDirectory() : $this->getAllFile();
+		$maxID = 0;
+		foreach ($list as $key => $e) {
+			if ($e['id'] > $maxID) $maxID = $e['id'];
+		}
+		
+		return $maxID;
+	}
+	
 }
