Location: PHPKode > projects > Entier Studio > entierstudio/framework/file.datasource.php
<?php
/**
 * Entier Studio
 *
 * LICENSE
 *
 *	Copyright 2006 Entier Studio team.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 *
 * @package    entier.framework 
 * @version	   $Id: file.datasource.php 84 2008-01-19 23:49:20Z yannromefort $
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefFILEDataSource")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefFILEDataSource", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . "datasource.php");
    //-------------------------------------------------------------------------
    //	Class
    class FILEDataSource extends DataSource {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         * Data source constructor
         * @param	string	host
         * @param	string	port
         * @param	string	user
         * @param	string	pass
         * @param	string	base
         */
        function FILEDataSource($hostName = "", $hostPort = 21, $userName = "", $passWord = "", $directory = "") {
            $this->m_protocol = "file";
            $this->m_hostName = $hostName;
            $this->m_hostPort = $hostPort;
            $this->m_userName = $userName;
            $this->m_passWord = $passWord;
            $this->m_dataBase = @rtrim(@addslashes($directory) , "/\\");
        }
        //---------------------------------------------------------------------
        //	Properties
        
        /**
         * overrided DataSource property
         *
         * @return	object
         * @see
         */
        function getDataHandler() {
            //
            return ($this);
        }
        /**
		 * ~= Database property	
         *
         * @return	string
         */
        function Directory() {
            //
            return ($this->m_dataBase);
        }
        /**
         * overrided DataSource property
         *
         * @return	string
         */
        function errorString() {
            //
            if ($this->isConnectionOpen() == false) return ("File System not available");
            //
            return ("");
        }
        /**
         * overrided DataSource property
         *
         * @return	integer
         */
        function errorNumber() {
            //
            return (0);
        }
        //---------------------------------------------------------------------
        //	Methods
        //
        // DataSource interface
        //
        
        /**
         * overrided DataSource method
         *
         * @param	object	DataSource
         * @return	boolean
         */
        function openConnection() {
            //
            $connection = false;
            $directory = $this->m_dataBase;
            if ($directory != "") {
                //
                $connection = @is_dir($directory);
                //
                @clearstatcache();
            }
            //
            return ($connection);
        }
        /**
         * overrided DataSource method
         *
         * @return	boolean
         */
        function closeConnection() {
            //
            return (true);
        }
        /**
         *
         * @param	object	DataSource
         * @return	boolean
         */
        function openDirectory($directory = "") {
            //
            if ($directory != "")
                $this->m_resource = @opendir($directory);
            else
                $this->m_resource = @opendir($this->m_dataBase);
            //
            return (false !== $this->m_resource);
        }
        /**		
         *
         * @return	boolean
         */
        function closeDirectory() {
            //
            if ($this->isConnectionOpen() == false)
                return (false);
            //
            @closedir($this->m_resource);
            $this->m_resource = false;
            //
            return (true);
        }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio